Skip to content

Commit

Permalink
Fix: #5075 - trailing space after empty NOTE tag
Browse files Browse the repository at this point in the history
  • Loading branch information
fisharebest committed Dec 12, 2024
1 parent c563f7f commit 1418e3b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/Services/GedcomImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ private function reformatRecord(string $rec, Tree $tree): string
while (str_contains($data, ' ')) {
$data = strtr($data, [' ' => ' ']);
}
$newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level === '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag !== 'NOTE' ? '' : ' ' . $data);
$newrec .= ($newrec !== '' ? "\n" : '') . $level . ' ' . ($level === '0' && $xref !== '' ? $xref . ' ' : '') . $tag . ($data === '' ? '' : ' ' . $data);
break;
case 'NOTE':
case 'TEXT':
case 'DATA':
case 'CONT':
$newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level === '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag !== 'NOTE' ? '' : ' ' . $data);
$newrec .= ($newrec !== '' ? "\n" : '') . $level . ' ' . ($level === '0' && $xref !== '' ? $xref . ' ' : '') . $tag . ($data === '' ? '' : ' ' . $data);
break;
case 'FILE':
// Strip off the user-defined path prefix
Expand All @@ -213,7 +213,7 @@ private function reformatRecord(string $rec, Tree $tree): string
// convert backslashes in filenames to forward slashes
$data = preg_replace("/\\\\/", '/', $data);

$newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level === '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag !== 'NOTE' ? '' : ' ' . $data);
$newrec .= ($newrec !== '' ? "\n" : '') . $level . ' ' . ($level === '0' && $xref !== '' ? $xref . ' ' : '') . $tag . ($data === '' ? '' : ' ' . $data);
break;
case 'CONC':
// Merge CONC lines, to simplify access later on.
Expand Down

0 comments on commit 1418e3b

Please sign in to comment.