-
Notifications
You must be signed in to change notification settings - Fork 32
Description
In the JSON generator, it assumes the Western convention of forename surname. This is a format not specified by GEDCOM, which instead says (in GEDCOM 5.5.5) that:
The surname of an individual, if known, is enclosed between two slash (/) characters. The order of the name parts should be the order that the person would, by custom of their culture,have used when giving it to a recorder.
Examples
William Lee /Parry/ - given name William Lee, surname Parry
William Lee - given name only or surname not known
/Parry/ - surname only
William Lee /Mac Parry/ - both Mac and Parry are part of the surname Mac Parry
William /Parry/ Boatsman - surname Parry embedded in the name string
William Lee /Pa.../ - surname partly unknown (unreadable)
In the current behaviour, any text after the surname is discarded. This is a bug.
The current implementation is the following:
Lines 34 to 40 in f493984
| function extractName(name: string): { firstName?: string; lastName?: string } { | |
| const arr = name.split('/'); | |
| if (arr.length === 1) { | |
| return { firstName: arr[0].trim() }; | |
| } | |
| return { firstName: arr[0].trim(), lastName: arr[1].trim() }; | |
| } |
I propose changing it to something like this:
function extractName(name: string): { firstName?: string; lastName?: string } {
const matches = name.match(/\/([^\/]+)\//);
if (matches) {
const lastName = matches[1].trim();
// Replace the last name part (including slashes) and trim the result
let firstName = name.replace(matches[0], '').trim();
// Replace any occurrence of double spaces with a single space
firstName = firstName.replace(/\s\s+/g, ' ');
return {
firstName: firstName || undefined,
lastName: lastName
};
} else {
// If no last name is found, just return the trimmed and cleaned firstName
return { firstName: name.trim().replace(/\s\s+/g, ' ') };
}
}Which results in:
extractName("William Lee /Mac Pa.../ Boatsman")
// {"firstName": "William Lee Boatsman", "lastName": "Mac Pa..."}This way at least, no information is lost (even if it may not be presented in the desired order on topola).