From 14cd8beadc632acdcab18d0215b89e8dfa01d33c Mon Sep 17 00:00:00 2001 From: Jared Howland <1877384+jaredhowland@users.noreply.github.com> Date: Thu, 16 Apr 2026 13:47:59 -0600 Subject: [PATCH 1/3] feat: add FamilySearch ID to frontmatter --- src/individual.py | 12 ++++++++++++ src/markdown_generator.py | 3 +++ tests/conftest.py | 1 + tests/test_individual.py | 4 ++++ tests/test_markdown_generator.py | 1 + 5 files changed, 21 insertions(+) diff --git a/src/individual.py b/src/individual.py index d37c2dd..aec6b60 100644 --- a/src/individual.py +++ b/src/individual.py @@ -56,6 +56,18 @@ class Individual: """ return self.element.get_pointer() + def get_fs_id(self) -> str: + """ + Return the FamilySearch Tree ID (`_FSFTID`) if present. + + Returns: + str: FamilySearch Tree ID value, or an empty string when not available. + """ + for child in self.element.get_child_elements(): + if child.get_tag() == "_FSFTID": + return child.get_value() or "" + return "" + def get_names(self) -> Tuple[str, str]: """ Return the individual's first and last name with surrounding whitespace removed. diff --git a/src/markdown_generator.py b/src/markdown_generator.py index 7c4cb91..8d9a7b7 100644 --- a/src/markdown_generator.py +++ b/src/markdown_generator.py @@ -123,8 +123,11 @@ class MarkdownGenerator: birth = individual.get_birth_info() death = individual.get_death_info() + fs_id = individual.get_fs_id() f.write(f"ID: {individual.get_id()}\n") + if fs_id: + f.write(f"FamilySearch_ID: {fs_id}\n") f.write(f"Name: {individual.get_full_name()}\n") # Lived years diff --git a/tests/conftest.py b/tests/conftest.py index fe3b1da..4db8cd7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -41,6 +41,7 @@ def sample_gedcom_content(): 1 NAME John /Doe/ 2 GIVN John 2 SURN Doe +1 _FSFTID G123-ABC 1 SEX M 1 BIRT 2 DATE 1 JAN 1950 diff --git a/tests/test_individual.py b/tests/test_individual.py index 49c523e..a02e4c1 100644 --- a/tests/test_individual.py +++ b/tests/test_individual.py @@ -80,6 +80,10 @@ class TestIndividualBasicInfo: """Test gender extraction.""" assert john_doe.get_gender() == 'M' + def test_get_fs_id(self, john_doe): + """Test FamilySearch Tree ID extraction from _FSFTID tag.""" + assert john_doe.get_fs_id() == 'G123-ABC' + def test_get_gender_default_unknown(self, sample_gedcom_file): """Test that missing gender defaults to 'U'.""" gedcom_content = """0 HEAD diff --git a/tests/test_markdown_generator.py b/tests/test_markdown_generator.py index 7127748..385bbc4 100644 --- a/tests/test_markdown_generator.py +++ b/tests/test_markdown_generator.py @@ -129,6 +129,7 @@ class TestMetadataFormatting: # Check for YAML frontmatter metadata assert 'ID: I1' in content + assert 'FamilySearch_ID: G123-ABC' in content assert 'Name: John Doe' in content assert 'Sex: M' in content -- 2.36.6 From a56792ae0d4cd7e1723dce361d8d92b850dcd1d7 Mon Sep 17 00:00:00 2001 From: Jared Howland <1877384+jaredhowland@users.noreply.github.com> Date: Thu, 16 Apr 2026 15:08:15 -0600 Subject: [PATCH 2/3] test: Gedcom file with no FamilySearchID Added a negative-case assertion to ensure get_fs_id returns an empty string when an Individual lacks the _FSFTID tag --- tests/test_individual.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_individual.py b/tests/test_individual.py index a02e4c1..0e66015 100644 --- a/tests/test_individual.py +++ b/tests/test_individual.py @@ -80,10 +80,16 @@ class TestIndividualBasicInfo: """Test gender extraction.""" assert john_doe.get_gender() == 'M' - def test_get_fs_id(self, john_doe): + def test_get_fs_id(self, john_doe, sample_gedcom_file): """Test FamilySearch Tree ID extraction from _FSFTID tag.""" assert john_doe.get_fs_id() == 'G123-ABC' + parser = GedcomParser(sample_gedcom_file) + individuals = parser.get_individuals() + jane = [ind for ind in individuals if 'Jane' in str(ind.get_name())] + jane_doe = Individual(jane[0], parser.parser) + assert jane_doe.get_fs_id() == '' + def test_get_gender_default_unknown(self, sample_gedcom_file): """Test that missing gender defaults to 'U'.""" gedcom_content = """0 HEAD -- 2.36.6 From 97c5f12b863bf99ae87bbcc96281fb3b2c913fc7 Mon Sep 17 00:00:00 2001 From: Jared Howland <1877384+jaredhowland@users.noreply.github.com> Date: Thu, 16 Apr 2026 15:15:33 -0600 Subject: [PATCH 3/3] fix: rename frontmatter FamilySearch_ID Make FamilySearch ID field name more consistent with the other fields in the frontmatter --- src/markdown_generator.py | 2 +- tests/test_markdown_generator.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/markdown_generator.py b/src/markdown_generator.py index 8d9a7b7..b0477e5 100644 --- a/src/markdown_generator.py +++ b/src/markdown_generator.py @@ -127,7 +127,7 @@ class MarkdownGenerator: f.write(f"ID: {individual.get_id()}\n") if fs_id: - f.write(f"FamilySearch_ID: {fs_id}\n") + f.write(f"FamilySearch ID: {fs_id}\n") f.write(f"Name: {individual.get_full_name()}\n") # Lived years diff --git a/tests/test_markdown_generator.py b/tests/test_markdown_generator.py index 385bbc4..179b49b 100644 --- a/tests/test_markdown_generator.py +++ b/tests/test_markdown_generator.py @@ -129,7 +129,7 @@ class TestMetadataFormatting: # Check for YAML frontmatter metadata assert 'ID: I1' in content - assert 'FamilySearch_ID: G123-ABC' in content + assert 'FamilySearch ID: G123-ABC' in content assert 'Name: John Doe' in content assert 'Sex: M' in content -- 2.36.6