diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..34e337f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,60 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.0.0] - 2025-11-02 + +### Added +- GEDCOM to Markdown conversion with Obsidian-compatible WikiLinks +- GEDZIP (ZIP archive) support for packages with media files +- Automatic extraction and processing of GEDZIP archives +- Automatic detection and correction of Mac-style (CR-only) line endings +- Organized directory structure with people/, media/, and stories/ subdirectories +- Flat directory structure option via `--flat` flag +- Obsidian Canvas generation for interactive family tree visualization +- Generational layout for canvas (ancestors right, descendants left) +- Gender-aware vertical positioning in canvas to reduce edge crossings +- Interactive root person selection for canvas generation +- Support for specifying root person by selection number or GEDCOM ID +- Comprehensive individual markdown notes with: + - Names, dates, and life events + - Physical attributes (eyes, hair, height) + - Multiple marriages and families + - Parent and children relationships + - Images and media references + - Notes and documentation +- Separate story file extraction from `_STO` tags +- Bidirectional linking between person notes and story files +- Properly resolved image paths in story files +- Global alphabetical index of all individuals +- Media file management with automatic copying and organization +- Filename collision detection and resolution with numeric suffixes +- Proper file naming convention: "FamilyName FirstName BirthYear.md" +- WikiLinks with proper path prefixes for subdirectory navigation +- Comprehensive test suite using pytest +- Code coverage reporting with pytest-cov +- Modular architecture with separate parsers, generators, and models +- Command-line interface with argparse +- Support for `--input`/`--output` flags (with `-i`/`-o` short forms) +- Verbose logging option with `--verbose`/`-v` +- Option to skip index generation with `--no-index` +- Canvas generation option with `--canvas` +- Root person specification with `--root` +- Support for GEDCOM version 5.5.x and 5.x +- Handling of disconnected family trees in canvas visualization + +### Technical +- Python 3.7+ compatibility +- Uses `python-gedcom==1.0.0` for GEDCOM parsing +- Pytest-based testing infrastructure +- Branch and line coverage analysis +- Comprehensive error handling with specific exceptions +- Module-level logging with configurable verbosity +- Type hints for all function signatures +- Google-style docstrings for all public APIs +- PEP 8 code style compliance + +[1.0.0]: https://github.com/AlexKucera/gedcom-to-markdown/releases/tag/v1.0.0 diff --git a/CLAUDE.md b/CLAUDE.md index dced677..7cf571c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,6 +6,21 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co This is a Python-based GEDCOM (genealogical data) parser that converts family tree data into Obsidian-compatible Markdown notes with WikiLinks. The project extracts comprehensive genealogical data including relationships, events, images, and long-form narratives. +## Key Features + +- **GEDZIP Support**: Automatically extracts and processes ZIP archives with media files +- **Automatic Line Ending Fix**: Detects and corrects Mac-style line endings +- **Organized Directory Structure**: Creates separate subdirectories for people, media, and stories (or flat structure with `--flat`) +- **Canvas Visualization**: Generates Obsidian Canvas files for interactive family tree visualization +- **Complete Individual Notes**: Detailed markdown notes for each person with comprehensive data +- **Separate Story Files**: Extracts long-form narratives to individual markdown files with bidirectional linking +- **WikiLinks**: All relationships use `[[WikiLinks]]` format for Obsidian +- **Multiple Marriages**: Full support for individuals with multiple spouses +- **Media Management**: Automatically copies and organizes image files with collision detection +- **Global Index**: Creates alphabetical index of all individuals +- **Interactive Person Selection**: Choose root person for canvas with sortable list +- **Comprehensive Testing**: pytest-based test suite with coverage reporting + ## Core Architecture The codebase follows a clean modular architecture in `src/`: @@ -15,6 +30,7 @@ The codebase follows a clean modular architecture in `src/`: - Parses GEDCOM files and extracts individuals - Provides element lookup by pointer/ID - Handles line ending issues (CR vs LF) + - Automatically detects and fixes Mac-style line endings 2. **Individual** (`individual.py`): Rich person data model - Comprehensive data extraction: names, dates, relationships, events @@ -29,16 +45,38 @@ The codebase follows a clean modular architecture in `src/`: - Sections: Attributes, Events, Families, Parents, Children, Images, Notes - Uses Obsidian metadata: `[key:: value]` (visible) and `(key:: value)` (hidden) - Handles multiple marriages with proper formatting + - Creates separate story files in stories/ subdirectory (or output root if using --flat) + - Supports both organized (subdirectories) and flat directory structures 4. **IndexGenerator** (`index_generator.py`): Global index creation - Creates alphabetical index by last name - Groups individuals by first letter - Includes life spans where available + - Generates WikiLinks to person notes with proper path prefixes -5. **main.py**: CLI entry point - - Argument parsing with argparse - - Logging configuration - - Orchestrates parsing, generation, and indexing +5. **CanvasGenerator** (`canvas_generator.py`): Obsidian Canvas visualization + - Generates JSON Canvas files for family tree visualization + - Creates generational layout with ancestors to the right, descendants to the left + - Builds tree structure using breadth-first search from root person + - Handles disconnected family trees (adds as separate groups) + - Positions nodes with proper spacing: generations, siblings, couples + - Creates edges for parent-child and spouse relationships + - Includes person images in canvas nodes when available + +6. **PersonSelector** (`person_selector.py`): Interactive root person selection + - Displays all individuals in sortable, numbered list + - Shows name, birth year, death year for each person + - Supports both interactive selection and command-line specification + - Accepts numeric index (e.g., "85") or GEDCOM ID (e.g., "@I253884714@") + - Used for canvas root person selection + +7. **main.py**: CLI entry point + - Argument parsing with argparse (--input, --output, --flat, --canvas, --root, etc.) + - Logging configuration (INFO for main, WARNING for libraries, DEBUG with --verbose) + - Handles GEDZIP extraction to temporary directory + - Orchestrates parsing, generation, indexing, and canvas creation + - Manages media file copying with collision detection + - Cleanup of temporary files ## Development Environment Setup @@ -46,27 +84,62 @@ The codebase follows a clean modular architecture in `src/`: # Install dependencies pip install -r requirements.txt -# The main script is directly executable -python src/main.py +# Run tests (requires pytest and pytest-cov) +pytest + +# Run with coverage report +pytest --cov=src --cov-report=html ``` ## Running the Converter ### Basic Usage ```sh -python src/main.py examples/Stammbaum_Kucera.ged output/ +# With GEDCOM file (creates organized subdirectories) +python src/main.py --input examples/Stammbaum_Kucera.ged --output output/ + +# Short form +python src/main.py -i examples/Stammbaum_Kucera.ged -o output/ + +# With GEDZIP file (recommended - includes media) +python src/main.py -i examples/family.zip -o output/ ``` -### With Options +### Directory Structure Options +```sh +# Organized structure (default): creates people/, media/, stories/ subdirectories +python src/main.py -i input.ged -o output/ + +# Flat structure: all files in output root +python src/main.py -i input.ged -o output/ --flat +``` + +### Canvas Generation +```sh +# Interactive root person selection +python src/main.py -i input.ged -o output/ --canvas + +# Specify root person by selection number +python src/main.py -i input.ged -o output/ --canvas --root 85 + +# Specify root person by GEDCOM ID +python src/main.py -i input.ged -o output/ --canvas --root @I253884714@ +python src/main.py -i input.ged -o output/ --canvas --root I253884714 +``` + +### Other Options ```sh # Verbose logging -python src/main.py input.ged output/ --verbose +python src/main.py -i input.ged -o output/ --verbose # Skip index creation -python src/main.py input.ged output/ --no-index +python src/main.py -i input.ged -o output/ --no-index + +# All options combined +python src/main.py -i family.zip -o output/ --flat --canvas --root 85 --verbose ``` -**Important**: Output directory must exist before running. +**Note**: Output directory will be created automatically if it doesn't exist. ## Key Implementation Details @@ -92,8 +165,9 @@ The Individual class extracts data through several methods: ### Reference Resolution GEDCOM uses pointers (`@ID@`) to reference other records. The Individual class resolves: - NOTE references to actual note text -- Story references (`_STO`) to narrative text +- Story references (`_STO`) to narrative text (extracted to separate files) - Family references to spouse and children data +- Image/media references (OBJE) to file paths ### Multiple Marriages Families are extracted with full context: @@ -102,14 +176,33 @@ Families are extracted with full context: - Children grouped by marriage - All marriages numbered if more than one +### Story Files +Long-form narratives (`_STO` tags) are extracted to separate markdown files: +- Created in stories/ subdirectory (or output root with --flat) +- Bidirectional linking between person notes and story files +- Properly resolved image paths within stories +- Story title and description as metadata + +### Canvas Visualization +The CanvasGenerator creates Obsidian Canvas files: +- Left-to-right timeline layout (descendants left, ancestors right) +- Gender-aware vertical positioning (reduces crossings) +- Automatic handling of disconnected family trees +- Includes person images in nodes when available +- Parent-child edges connect left to right +- Spouse edges are bidirectional (vertical) + ## Common Issues ### Line Ending Problem -Some GEDCOM files (especially from macOS apps) use CR line endings which the parser can't handle. Symptoms: +Some GEDCOM files (especially from macOS apps) use CR line endings which the parser can't handle. **This is now automatically detected and fixed** by the converter. You'll see a warning message but the conversion will proceed. + +Symptoms of CR-only line endings: - Parser reports 0 individuals - No output files created +- Warning message about Mac-style line endings -**Fix**: Convert line endings before parsing (see README.md) +**Fix**: Automatic - the converter detects and converts line endings on the fly. ### Empty Notes If NOTE records exist but appear empty, they may be placeholder records without content. This is valid GEDCOM. @@ -117,9 +210,70 @@ If NOTE records exist but appear empty, they may be placeholder records without ### Story Tags The `_STO` tag is a custom extension used by MobileFamilyTree. Other genealogy programs may use different custom tags for stories. +### GEDCOM Version Compatibility +This tool works best with GEDCOM version 5.5.x or 5.x. GEDCOM 7.0+ may have compatibility issues with custom tags. When exporting from genealogy software, choose GEDCOM 5.5.1 or 5.1.0 if available, and prefer GEDZIP format to include media files. + +### Media File Handling +When using GEDZIP files: +- All media files (jpg, jpeg, png, gif, bmp) are automatically extracted and copied +- Files are organized in media/ subdirectory (or output root with --flat) +- Filename collisions are handled with numeric suffixes +- Relative paths in GEDCOM are preserved + +## Testing + +The project uses pytest for testing with comprehensive coverage: + +### Test Structure +``` +tests/ +├── conftest.py # Shared fixtures +├── test_gedcom_parser.py # Parser tests +├── test_individual.py # Individual model tests +├── test_markdown_generator.py # Markdown generation tests +├── test_index_generator.py # Index generation tests +├── test_main.py # CLI integration tests +└── __init__.py +``` + +### Running Tests +```sh +# Run all tests +pytest + +# Run with verbose output +pytest -v + +# Run specific test file +pytest tests/test_individual.py + +# Run with coverage report +pytest --cov=src --cov-report=term-missing + +# Generate HTML coverage report +pytest --cov=src --cov-report=html +# Open htmlcov/index.html +``` + +### Test Configuration +Tests are configured in `pytest.ini`: +- Test discovery: `tests/` directory +- Python path: `src/` (allows direct imports) +- Coverage: Branch and line coverage enabled +- Coverage reports: Terminal (with missing lines) and HTML + +### Writing Tests +- Use fixtures from `conftest.py` for sample GEDCOM data +- Test both happy path and error cases +- Use descriptive test names: `test__` +- Mock file I/O and external dependencies +- Aim for high coverage on core business logic + ## Dependencies - `python-gedcom==1.0.0`: GEDCOM parsing library +- `pytest>=7.4.0`: Testing framework +- `pytest-cov>=4.1.0`: Coverage plugin - Python 3.7+ Update dependencies: @@ -132,6 +286,9 @@ pip freeze > requirements.txt - Follow PEP 8 - Use type hints for all function signatures -- Docstrings for all public functions and classes -- Logging for important operations +- Docstrings for all public functions and classes (Google style) +- Logging for important operations (use module-level logger) - Proper error handling with specific exceptions +- Clear variable names that explain purpose +- Extract magic numbers to named constants +- Keep functions focused on single responsibility diff --git a/LICENSE.md b/LICENSE similarity index 100% rename from LICENSE.md rename to LICENSE diff --git a/README.md b/README similarity index 59% rename from README.md rename to README index 12f06fe..e4a84e7 100644 --- a/README.md +++ b/README @@ -1,40 +1,76 @@ -![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/AlexKucera/gedcom-to-markdown?utm_source=oss&utm_medium=github&utm_campaign=AlexKucera%2Fgedcom-to-markdown&labelColor=171717&color=FF570A&link=https%3A%2F%2Fcoderabbit.ai&label=CodeRabbit+Reviews) +
+ +![Family Tree Header](assets/header.jpg) # GEDCOM to Markdown Converter -Convert GEDCOM genealogy files to Obsidian-compatible markdown notes with WikiLinks. +**Convert GEDCOM genealogy files to Obsidian-compatible markdown notes with WikiLinks** + +[![Python Version](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/) +[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE) +[![Tests](https://img.shields.io/badge/tests-pytest-orange.svg)](tests/) +[![Code Coverage](https://img.shields.io/badge/coverage-monitored-brightgreen.svg)](.coverage) +[![CodeRabbit Reviews](https://img.shields.io/coderabbit/prs/github/AlexKucera/gedcom-to-markdown?utm_source=oss&utm_medium=github&utm_campaign=AlexKucera%2Fgedcom-to-markdown&labelColor=171717&color=FF570A&link=https%3A%2F%2Fcoderabbit.ai&label=CodeRabbit)](https://coderabbit.ai) + +[Features](#features) • [Installation](#installation) • [Usage](#usage) • [Examples](#examples) • [Documentation](#project-structure) + +
+ +--- ## Features -- **GEDZIP Support**: Automatically extracts and processes ZIP archives with media files -- **Automatic Line Ending Fix**: Detects and corrects Mac-style line endings -- **Organized Directory Structure**: Creates separate subdirectories for people, media, and stories (or flat structure with `--flat` flag) -- **Complete Individual Notes**: Generates detailed markdown notes for each person -- **Separate Story Files**: Extracts long-form narratives to individual markdown files with bidirectional linking -- **WikiLinks**: All relationships use `[[WikiLinks]]` format for Obsidian with proper path prefixes -- **Comprehensive Data**: Captures births, deaths, marriages, events, physical attributes, images, and notes -- **Multiple Marriages**: Supports individuals with multiple spouses -- **Media Management**: Automatically copies and organizes image files with correct relative paths -- **Global Index**: Creates an alphabetical index of all individuals -- **Proper Naming**: Files named as "FamilyName FirstName BirthYear.md" +### Core Capabilities +- 📦 **GEDZIP Support**: Automatically extracts and processes ZIP archives with media files +- 🔧 **Automatic Line Ending Fix**: Detects and corrects Mac-style line endings +- 📁 **Organized Directory Structure**: Creates separate subdirectories for people, media, and stories (or flat structure with `--flat` flag) +- 🎨 **Canvas Visualization**: Generates Obsidian Canvas files for interactive family tree visualization with generational layout + +### Rich Data Extraction +- 👤 **Complete Individual Notes**: Generates detailed markdown notes for each person +- 📖 **Separate Story Files**: Extracts long-form narratives to individual markdown files with bidirectional linking +- 🔗 **WikiLinks**: All relationships use `[[WikiLinks]]` format for Obsidian with proper path prefixes +- 📊 **Comprehensive Data**: Captures births, deaths, marriages, events, physical attributes, images, and notes +- 💑 **Multiple Marriages**: Supports individuals with multiple spouses + +### File Management +- 🖼️ **Media Management**: Automatically copies and organizes image files with correct relative paths +- 📑 **Global Index**: Creates an alphabetical index of all individuals +- 🏷️ **Proper Naming**: Files named as "FamilyName FirstName BirthYear.md" ## Installation ```bash +# Clone the repository +git clone https://github.com/AlexKucera/gedcom-to-markdown.git +cd gedcom-to-markdown + +# Install dependencies pip install -r requirements.txt ``` +## Quick Start + +```bash +# Convert a GEDCOM file with all default options +python src/main.py -i path/to/family.ged -o output/ + +# Convert a GEDZIP archive (recommended - includes media) +python src/main.py -i path/to/family.zip -o output/ + +# Generate with family tree visualization +python src/main.py -i path/to/family.zip -o output/ --canvas +``` + ## Usage ### Basic Usage ```bash +# Full syntax python src/main.py --input path/to/family.ged --output output/directory -``` -or using short form: - -```bash +# Short form python src/main.py -i path/to/family.ged -o output/directory ``` @@ -155,7 +191,17 @@ src/ ├── individual.py # Person data model ├── markdown_generator.py # Note generation ├── index_generator.py # Index file creation +├── canvas_generator.py # Obsidian Canvas visualization +├── person_selector.py # Interactive root person selection └── main.py # CLI entry point + +tests/ +├── conftest.py # Shared test fixtures +├── test_gedcom_parser.py # Parser tests +├── test_individual.py # Individual model tests +├── test_markdown_generator.py # Markdown generation tests +├── test_index_generator.py # Index generation tests +└── test_main.py # CLI integration tests ``` ## Requirements @@ -199,3 +245,42 @@ The GEDZIP format is a standard ZIP archive containing: - All referenced media files (photos, documents, etc.) This is the **recommended export format** for use with this converter. + +--- + +## Contributing + +Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change. + +### Development + +```bash +# Run tests +pytest + +# Run tests with coverage +pytest --cov=src --cov-report=html + +# Run tests in verbose mode +pytest -v +``` + +## License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. + +## Acknowledgments + +- Built with [python-gedcom](https://github.com/nickreynke/python-gedcom) for GEDCOM parsing +- Designed for [Obsidian](https://obsidian.md) - the knowledge base that works on local Markdown files +- Family tree visualization inspired by genealogy research workflows + +--- + +
+ +**Made with ❤️ for genealogy enthusiasts and family historians** + +[⬆ Back to Top](#gedcom-to-markdown-converter) + +
diff --git a/assets/vivian-arcidiacono-WksHX9oosJI-unsplash.jpg b/assets/vivian-arcidiacono-WksHX9oosJI-unsplash.jpg new file mode 100644 index 0000000..4bf780d Binary files /dev/null and b/assets/vivian-arcidiacono-WksHX9oosJI-unsplash.jpg differ diff --git a/src/index_generator.py b/src/index_generator.py index e7eeb88..a52b644 100644 --- a/src/index_generator.py +++ b/src/index_generator.py @@ -23,16 +23,18 @@ class IndexGenerator: The index is organized alphabetically by last name, then first name. """ - def __init__(self, output_dir: Path, people_subdir: str = ""): + def __init__(self, output_dir: Path, people_subdir: str = "", filename_map: dict = None): """ Create an IndexGenerator configured with the target output directory and an optional subdirectory for individual files. - + Parameters: output_dir (Path): Directory where the generated index file will be written. people_subdir (str): Optional subdirectory name to prepend to people file links (empty string means no subdirectory). + filename_map (dict): Optional mapping from individual IDs to actual filenames (for handling duplicates). """ self.output_dir = output_dir self.people_subdir = people_subdir + self.filename_map = filename_map or {} def generate_index( self, individuals: List[Individual], index_filename: str = "Index.md" @@ -80,7 +82,13 @@ class IndexGenerator: f.write(f"\n## {current_letter}\n\n") # Write individual link with life span - filename = individual.get_file_name() + # Use mapped filename if available, otherwise use base filename + individual_id = individual.get_id() + if individual_id in self.filename_map: + filename = self.filename_map[individual_id] + else: + filename = individual.get_file_name() + birth_info = individual.get_birth_info() death_info = individual.get_death_info() diff --git a/src/individual.py b/src/individual.py index aa00f44..a91ec3e 100644 --- a/src/individual.py +++ b/src/individual.py @@ -78,18 +78,13 @@ class Individual: def get_file_name(self) -> str: """ - Build a filename-like string for the individual in the form "FamilyName FirstName" optionally followed by the birth year. + Build a filename-like string for the individual in the form "FamilyName FirstName". Returns: - filename (str): The generated filename string, either "FamilyName FirstName BirthYear" or "FamilyName FirstName" when the birth year is not available; does not include a file extension; preserves original name capitalization. + filename (str): The generated filename string "FamilyName FirstName"; does not include a file extension; preserves original name capitalization. """ first, last = self.get_names() - name_part = f"{last} {first}".strip() - - birth_year = self.element.get_birth_year() - if birth_year != -1: - return f"{name_part} {birth_year}" - return name_part + return f"{last} {first}".strip() def get_birth_info(self) -> Dict[str, str]: """ diff --git a/src/main.py b/src/main.py index b1b22d0..c852143 100755 --- a/src/main.py +++ b/src/main.py @@ -269,7 +269,11 @@ def convert_gedcom_to_markdown( if create_index: logger.info("Generating index file") people_subdir_name = "" if use_flat_structure else "people" - index_gen = IndexGenerator(output_dir, people_subdir=people_subdir_name) + index_gen = IndexGenerator( + output_dir, + people_subdir=people_subdir_name, + filename_map=generator.filename_map + ) index_path = index_gen.generate_index(individuals) logger.info(f"Created index file: {index_path}") diff --git a/src/markdown_generator.py b/src/markdown_generator.py index 9743301..7c4cb91 100644 --- a/src/markdown_generator.py +++ b/src/markdown_generator.py @@ -55,6 +55,31 @@ class MarkdownGenerator: self.stories_dir = stories_dir if stories_dir else output_dir self.use_subdirectories = use_subdirectories self.generated_stories = {} # Track generated story files + self.filename_map = {} # Map from individual ID to actual filename used + + def _get_unique_filename(self, base_name: str, individual_id: str) -> str: + """ + Get a unique filename for an individual, handling duplicates by adding (1), (2), etc. + + Parameters: + base_name (str): Base filename without extension (e.g., "Kucera Alexander Maximilian") + individual_id (str): The individual's GEDCOM ID + + Returns: + str: Unique filename without extension (e.g., "Kucera Alexander Maximilian (1)") + """ + # Check if this base name has been used before + counter = 1 + used_names = set(self.filename_map.values()) + unique_name = base_name + + while unique_name in used_names: + unique_name = f"{base_name} ({counter})" + counter += 1 + + # Store the mapping + self.filename_map[individual_id] = unique_name + return unique_name def generate_note(self, individual: Individual) -> Path: """ @@ -66,7 +91,9 @@ class MarkdownGenerator: Returns: Path: Path to the created markdown file. """ - filename = individual.get_file_name() + ".md" + base_name = individual.get_file_name() + unique_name = self._get_unique_filename(base_name, individual.get_id()) + filename = unique_name + ".md" file_path = self.output_dir / filename logger.info(f"Generating note: {filename}") @@ -203,7 +230,7 @@ class MarkdownGenerator: # Only write partner bullet if partner exists if family["partner"]: - partner_name = family["partner"].get_file_name() + partner_name = self._get_actual_filename(family["partner"]) f.write(f"* Partner: {self._wiki_link(partner_name)}\n") # Write marriage bullets if present @@ -216,7 +243,7 @@ class MarkdownGenerator: if family["children"]: f.write("\n**Children:**\n") for child in family["children"]: - f.write(f"* Child: {self._wiki_link(child.get_file_name())}\n") + f.write(f"* Child: {self._wiki_link(self._get_actual_filename(child))}\n") f.write("\n") @@ -240,7 +267,7 @@ class MarkdownGenerator: f.write("## Parents\n") for parent in parents: - f.write(f"* Parent: {self._wiki_link(parent.get_file_name())}\n") + f.write(f"* Parent: {self._wiki_link(self._get_actual_filename(parent))}\n") f.write("\n") @@ -262,7 +289,7 @@ class MarkdownGenerator: f.write("## Children\n") for child in children: - f.write(f"* Child: {self._wiki_link(child.get_file_name())}\n") + f.write(f"* Child: {self._wiki_link(self._get_actual_filename(child))}\n") f.write("\n") @@ -392,7 +419,7 @@ class MarkdownGenerator: # Generate separate story files and link to them if stories: f.write("### Stories\n\n") - individual_name = individual.get_file_name() + individual_name = self._get_actual_filename(individual) for story in stories: # Generate the story file @@ -446,10 +473,25 @@ class MarkdownGenerator: """ f.write(f"({key}:: {value})\n") + def _get_actual_filename(self, individual: Individual) -> str: + """ + Get the actual filename for an individual, using the mapped name if available. + + Parameters: + individual (Individual): The individual to get the filename for + + Returns: + str: The actual filename without extension + """ + individual_id = individual.get_id() + if individual_id in self.filename_map: + return self.filename_map[individual_id] + return individual.get_file_name() + def _wiki_link(self, text: str) -> str: """ Format text as an Obsidian-style WikiLink. - + Returns: wiki_link (str): The input text wrapped in double square brackets (e.g. `[[Name]]`). """