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] 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