I added a feature to add sources to people pages when GEDCOM includes them.
I have a GEDCOM file with several hundred thousand sources. Because of this, there are some weird formatting issues I ran into that I attempted to address with this PR. New tests are written and all tests pass.
Respect GEDCOM CONC vs CONT semantics (concatenate vs newline)
Generate global sources index once (avoid O(N*S) stall)
Repair broken HTML tags spanning GEDCOM lines for whitelist tags
Escape markdown emphasis characters in notes to prevent formatting leakage
Consistent handling of CONT/CONC; skip empty CONT lines; handle trailing spaces for hard breaks
Added tests covering CONT/CONC and source index
Summary by CodeRabbit
New Features
Extract and expose coordinates and FamilySearch ID for individuals, events, and marriages
Added per-individual Sources section and a generated global sources index
Improvements
Better handling and rendering of multi-line notes (CONT/CONC) with preserved paragraph breaks
Improved Markdown output, HTML repair, and whitespace normalization for notes and sources
Tests
Added tests covering notes, sources, events, coordinates, and FS ID extraction
I added a feature to add sources to people pages when GEDCOM includes them.
I have a GEDCOM file with several hundred thousand sources. Because of this, there are some weird formatting issues I ran into that I attempted to address with this PR. New tests are written and all tests pass.
- Respect GEDCOM CONC vs CONT semantics (concatenate vs newline)
- Generate global sources index once (avoid O(N*S) stall)
- Repair broken HTML tags spanning GEDCOM lines for whitelist tags
- Escape markdown emphasis characters in notes to prevent formatting leakage
- Consistent handling of CONT/CONC; skip empty CONT lines; handle trailing spaces for hard breaks
- Added tests covering CONT/CONC and source index
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **New Features**
* Extract and expose coordinates and FamilySearch ID for individuals, events, and marriages
* Added per-individual Sources section and a generated global sources index
* **Improvements**
* Better handling and rendering of multi-line notes (CONT/CONC) with preserved paragraph breaks
* Improved Markdown output, HTML repair, and whitespace normalization for notes and sources
* **Tests**
* Added tests covering notes, sources, events, coordinates, and FS ID extraction
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@Copilot has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 53 minutes and 38 seconds before requesting another review.
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 53 minutes and 38 seconds.
⌛ How to resolve this issue?
After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.
We recommend that you space out your commits to avoid hitting the rate limit.
🚦 How do rate limits work?
CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Reviewing files that changed from the base of the PR and between 676b4014ca and c68264978d.
📒 Files selected for processing (2)
src/individual.py
src/markdown_generator.py
📝 Walkthrough
Walkthrough
Adds GEDCOM text-normalization helpers, coordinate extraction, source and FSID accessors to Individual, and enhances markdown generation to render per-individual Sources and a global sources index. Tests added/updated to validate CONT/CONC handling, source rendering, coordinates, and FSFTID exposure.
Changes
Cohort / File(s)
Summary
Individual core src/individual.py
Added module helpers collapse_single_line, resolve_gedcom_text, and constant EVENT_TAGS. New/updated methods: _collapse_preserve_lines, _resolve_gedcom_text, _get_event_info, _extract_date_place_and_coords, _get_obje_info, get_fs_id, get_sources. Refactored event/date/place extraction to populate lat/long for birth/death/events and marriage_lat/marriage_long for families. Reworked note resolution to follow pointers and properly handle CONT/CONC.
Markdown generation src/markdown_generator.py
Imported GEDCOM utilities, added _sources_index_generated guard, new helpers (_coordinate_values, _collapse_preserve_lines, _format_source_entry, _generate_sources_index, _write_sources, _escape_markdown, _repair_broken_html_tags, _write_multiline_note_block). Now writes per-individual ## Sources, emits coordinates for events/families, and generates global sources/Index.md once. Improved inline-note rendering and HTML repair.
Added new tests validating CONT/CONC concatenation for inline notes, referenced notes, and source notes; tests that get_sources() outputs normalized TITL/PUBL/NOTE, that sources index is generated, and URL/title rendering behavior.
Expanded tests to assert FSFTID via get_fs_id(), multiple event/coordinate extraction scenarios, family marriage coordinate isolation, updated note tests, and frontmatter to include FamilySearch ID. Added _FSFTID to sample fixture.
Sequence Diagram
sequenceDiagram
participant Parser as GEDCOM Parser
participant Individual as Individual
participant Generator as MarkdownGenerator
participant FS as File System
Parser->>Individual: Construct individual elements (including SOUR, NOTE, MAP, PLAC)
Generator->>Individual: Call get_sources(), get_notes(), get_birth_info(), get_events(), get_families()
Individual->>Individual: Resolve pointers, merge CONT/CONC, extract DATE/PLAC and coords (lat/long), resolve OBJE/SOUR pointers
Individual-->>Generator: Return normalized data structures (notes, sources, events with lat/long, FSID)
Generator->>FS: Write individual markdown file (includes "## Sources", coordinates, notes)
alt sources index not yet generated
Generator->>Parser: Read GEDCOM for SOUR records
Generator->>Individual: Resolve source notes and metadata
Generator->>FS: Write sources/Index.md
end
FS-->>Generator: Files written
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
AlexKucera/gedcom-to-markdown#1 — Modifies the same src/individual.py implementation and introduces helpers, event/coordinate extraction, and source/FSID-related changes similar to this PR.
Poem
🐰 Hopping through lines of GEDCOM lore,
I stitch CONT and CONC and hunt for more.
Sources gather, coordinates shine,
Indexes bloom from pointer and line.
A carrot for tests — all green and fine!
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
✅ Passed
The title 'feat: add source parsing and linking' clearly reflects the main changes: new source parsing capability and integration with markdown generation for source display/linking.
Docstring Coverage
✅ Passed
Docstring coverage is 89.53% which is sufficient. The required threshold is 80.00%.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches🧪 Generate unit tests (beta)
Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- This is an auto-generated comment: rate limited by coderabbit.ai -->
> [!WARNING]
> ## Rate limit exceeded
>
> `@Copilot` has exceeded the limit for the number of commits that can be reviewed per hour. Please wait **53 minutes and 38 seconds** before requesting another review.
>
> Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in **53 minutes and 38 seconds**.
>
> <details>
> <summary>⌛ How to resolve this issue?</summary>
>
> After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR.
>
> We recommend that you space out your commits to avoid hitting the rate limit.
>
> </details>
>
>
> <details>
> <summary>🚦 How do rate limits work?</summary>
>
> CodeRabbit enforces hourly rate limits for each developer per organization.
>
> Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
>
> Please see our [FAQ](https://docs.coderabbit.ai/faq) for further information.
>
> </details>
>
> <details>
> <summary>ℹ️ Review info</summary>
>
> <details>
> <summary>⚙️ Run configuration</summary>
>
> **Configuration used**: defaults
>
> **Review profile**: CHILL
>
> **Plan**: Pro
>
> **Run ID**: `c4c2b9f6-012b-4318-a2fc-a879370d1c89`
>
> </details>
>
> <details>
> <summary>📥 Commits</summary>
>
> Reviewing files that changed from the base of the PR and between 676b4014ca9302ae08127c1cfddac86db0f8f35e and c68264978de73f6b588ed88eeca6f7998887c46d.
>
> </details>
>
> <details>
> <summary>📒 Files selected for processing (2)</summary>
>
> * `src/individual.py`
> * `src/markdown_generator.py`
>
> </details>
>
> </details>
<!-- end of auto-generated comment: rate limited by coderabbit.ai -->
<!-- walkthrough_start -->
<details>
<summary>📝 Walkthrough</summary>
## Walkthrough
Adds GEDCOM text-normalization helpers, coordinate extraction, source and FSID accessors to `Individual`, and enhances markdown generation to render per-individual Sources and a global sources index. Tests added/updated to validate CONT/CONC handling, source rendering, coordinates, and FSFTID exposure.
## Changes
|Cohort / File(s)|Summary|
|---|---|
|**Individual core** <br> `src/individual.py`|Added module helpers `collapse_single_line`, `resolve_gedcom_text`, and constant `EVENT_TAGS`. New/updated methods: `_collapse_preserve_lines`, `_resolve_gedcom_text`, `_get_event_info`, `_extract_date_place_and_coords`, `_get_obje_info`, `get_fs_id`, `get_sources`. Refactored event/date/place extraction to populate `lat`/`long` for birth/death/events and `marriage_lat`/`marriage_long` for families. Reworked note resolution to follow pointers and properly handle `CONT`/`CONC`.|
|**Markdown generation** <br> `src/markdown_generator.py`|Imported GEDCOM utilities, added `_sources_index_generated` guard, new helpers (`_coordinate_values`, `_collapse_preserve_lines`, `_format_source_entry`, `_generate_sources_index`, `_write_sources`, `_escape_markdown`, `_repair_broken_html_tags`, `_write_multiline_note_block`). Now writes per-individual `## Sources`, emits coordinates for events/families, and generates global `sources/Index.md` once. Improved inline-note rendering and HTML repair.|
|**Tests — notes & sources** <br> `tests/test_notes_cont_conc.py`, `tests/test_sources.py`|Added new tests validating CONT/CONC concatenation for inline notes, referenced notes, and source notes; tests that `get_sources()` outputs normalized `TITL`/`PUBL`/`NOTE`, that sources index is generated, and URL/title rendering behavior.|
|**Tests — individual updates** <br> `tests/test_individual.py`, `tests/test_markdown_generator.py`, `tests/conftest.py`|Expanded tests to assert FSFTID via `get_fs_id()`, multiple event/coordinate extraction scenarios, family marriage coordinate isolation, updated note tests, and frontmatter to include FamilySearch ID. Added `_FSFTID` to sample fixture.|
## Sequence Diagram
```mermaid
sequenceDiagram
participant Parser as GEDCOM Parser
participant Individual as Individual
participant Generator as MarkdownGenerator
participant FS as File System
Parser->>Individual: Construct individual elements (including SOUR, NOTE, MAP, PLAC)
Generator->>Individual: Call get_sources(), get_notes(), get_birth_info(), get_events(), get_families()
Individual->>Individual: Resolve pointers, merge CONT/CONC, extract DATE/PLAC and coords (lat/long), resolve OBJE/SOUR pointers
Individual-->>Generator: Return normalized data structures (notes, sources, events with lat/long, FSID)
Generator->>FS: Write individual markdown file (includes "## Sources", coordinates, notes)
alt sources index not yet generated
Generator->>Parser: Read GEDCOM for SOUR records
Generator->>Individual: Resolve source notes and metadata
Generator->>FS: Write sources/Index.md
end
FS-->>Generator: Files written
```
## Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
## Possibly related PRs
- AlexKucera/gedcom-to-markdown#1 — Modifies the same `src/individual.py` implementation and introduces helpers, event/coordinate extraction, and source/FSID-related changes similar to this PR.
## Poem
> 🐰 Hopping through lines of GEDCOM lore,
> > I stitch CONT and CONC and hunt for more.
> > Sources gather, coordinates shine,
> > Indexes bloom from pointer and line.
> > A carrot for tests — all green and fine!
</details>
<!-- walkthrough_end -->
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary>🚥 Pre-merge checks | ✅ 3</summary>
<details>
<summary>✅ Passed checks (3 passed)</summary>
| Check name | Status | Explanation |
| :----------------: | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'feat: add source parsing and linking' clearly reflects the main changes: new source parsing capability and integration with markdown generation for source display/linking. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 89.53% which is sufficient. The required threshold is 80.00%. |
</details>
<sub>✏️ Tip: You can configure your own custom pre-merge checks in the settings.</sub>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary>✨ Finishing Touches</summary>
<details>
<summary>🧪 Generate unit tests (beta)</summary>
- [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests
</details>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->
---
Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=AlexKucera/gedcom-to-markdown&utm_content=8)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
<details>
<summary>❤️ Share</summary>
- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
</details>
<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>
<!-- tips_end -->
<!-- internal state start -->
<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKPR1AGxJcAZiWpcaLT0iPjYFAwkPM6I8BhE6Bj0HnEA1nEJkAYAco4ClFwAHJBZAKo2ADJcsLi43IgcAPSNROqw2AIaTMyNAIJeAB4A0tiRVC103WAEYMzOqbT4AO4YjdzYHh6NxWWIBZBCznSwyx6Y9FkAymERUQJUGAywgcFgoeGRYNwxGZCASYQwZykXCQe6YJ5cOZxEoGS64ajYBr8bhkGEAYQo/ho9ACkAATAAGPEANjABIALGAAIwAdmgVIAnBxyQBWZkEgBaRgAItIGBR4NxxPgMBwDFBesFkGhIH4EZjIAQUI8PNglPYbpFkCKeJRQlhvqRkEtYKjcKbIABxACi3LRAHkALIKDDwuLIc0kZgacWAijA5A2u1O2XwLzGtqQKQuSBnf1RDB5PX8Hwaj7SRI44KYxB7ZCYs7Y2X4ChzWq/c66ig+EtzR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KKUlFqDIPcq1lbUc+2BfWMQskWZLslqGf8PkrdRKLMuZSjeRUsyVVLUgNSpJd3KagqxlApAN5aLPsUtKuATiuJS4swBdLYVd8o2Q1ERUNhkAhQBkNZKjoABSS7ExVQAOBISoMb6K6GUYWhMQL43SS/WkAnA4043SAIUAJAaACQBIclXctsWPKklzytJcirln/LclQKkxUko5n3ywVJQZHE3kLwqKJ4tgMxSUuehKLyQaABkLSAJAMAzpqgKOrQBZAMAGQaAElbQCjo0go6QQBgEaomknSZpLIGkBCUKBoA8Q/ge1WgAJDBAaQDAKaVSAEDEgWQxIKkJ9OGkEhGlUiVRbYDqVKLIghQWgDSA9XdiBAO02gOSAEA+q8QeIV6QyAZCprCQXqnNT4BrQkByQ5IFybyu3b3TU1SgckA6utWFBhp27GyR9NjUGAVV/UuGSZARmTooVl6UBEdLhngI+23wZVKjOFrdSQQ3CKHPGo1XgJJuvQXANOFX4Ezpo6gVyJZFwDkyCQfapqZOvwAH0Z1+pWWGOvwRAA -->
<!-- internal state end -->
copilot-pull-request-reviewer[bot]
(Migrated from github.com)
left a comment
Copy link
Copy source
Pull request overview
Adds end-to-end support for parsing GEDCOM sources/notes (including CONT/CONC semantics) and rendering them into generated person Markdown, plus generating a global sources index.
Changes:
Add Individual.get_sources() and update note parsing to respect CONT vs CONC.
Extend MarkdownGenerator to render a “Sources” section per person and generate a global sources/Index.md once.
Add new tests for sources rendering and for CONT/CONC handling (notes + source notes/index).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
File
Description
tests/test_sources.py
Adds coverage for per-person Sources section formatting and index generation.
tests/test_notes_cont_conc.py
Adds coverage for CONT/CONC handling in notes and source notes (but currently has import-path issues).
src/markdown_generator.py
Implements source section rendering, index generation, markdown escaping, and HTML-tag repair.
src/individual.py
Implements get_sources() and refactors note resolution to properly handle CONT/CONC.
## Pull request overview
Adds end-to-end support for parsing GEDCOM sources/notes (including `CONT`/`CONC` semantics) and rendering them into generated person Markdown, plus generating a global sources index.
**Changes:**
- Add `Individual.get_sources()` and update note parsing to respect `CONT` vs `CONC`.
- Extend `MarkdownGenerator` to render a “Sources” section per person and generate a global `sources/Index.md` once.
- Add new tests for sources rendering and for `CONT`/`CONC` handling (notes + source notes/index).
### Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
| ---- | ----------- |
| `tests/test_sources.py` | Adds coverage for per-person Sources section formatting and index generation. |
| `tests/test_notes_cont_conc.py` | Adds coverage for `CONT`/`CONC` handling in notes and source notes (but currently has import-path issues). |
| `src/markdown_generator.py` | Implements source section rendering, index generation, markdown escaping, and HTML-tag repair. |
| `src/individual.py` | Implements `get_sources()` and refactors note resolution to properly handle `CONT`/`CONC`. |
---
💡 <a href="/AlexKucera/gedcom-to-markdown/new/main?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
Pointer detection for SOUR @X@ should match the stricter pattern used elsewhere (startswith('@') and endswith('@')). Using only startswith('@') can misclassify inline values that happen to begin with '@', and can lead to failed lookups in the element dictionary.
if src_ref and src_ref.startswith("@") and src_ref.endswith("@"):
Pointer detection for `SOUR @X@` should match the stricter pattern used elsewhere (`startswith('@') and endswith('@')`). Using only `startswith('@')` can misclassify inline values that happen to begin with '@', and can lead to failed lookups in the element dictionary.
```suggestion
if src_ref and src_ref.startswith("@") and src_ref.endswith("@"):
```
The docstring says the source NOTE text is “formatted in italic”, but the implementation escapes emphasis characters and writes plain text (no italics). Either update the docstring to reflect actual behavior, or implement the intended italic formatting in a way that won’t conflict with markdown escaping.
and, if present, the source's NOTE text will be written as an indented
escaped note block beneath it.
The docstring says the source NOTE text is “formatted in italic”, but the implementation escapes emphasis characters and writes plain text (no italics). Either update the docstring to reflect actual behavior, or implement the intended italic formatting in a way that won’t conflict with markdown escaping.
```suggestion
and, if present, the source's NOTE text will be written as an indented
escaped note block beneath it.
```
In the non-nested branch, the “last non-empty line” is detected by comparing string values (ln == last_non_empty). If the same text appears earlier in lines, earlier occurrences will be treated as the last line and won’t get the intended trailing spaces/hard-break behavior. Track the last non-empty index instead (or iterate with indices) to make this deterministic.
last_non_empty_idx = next(
(idx for idx in range(len(lines) - 1, -1, -1) if lines[idx].strip()),
None,
)
for idx, ln in enumerate(lines):
if not ln.strip():
f.write("\n")
elif idx == last_non_empty_idx:
In the non-nested branch, the “last non-empty line” is detected by comparing string values (`ln == last_non_empty`). If the same text appears earlier in `lines`, earlier occurrences will be treated as the last line and won’t get the intended trailing spaces/hard-break behavior. Track the last non-empty *index* instead (or iterate with indices) to make this deterministic.
```suggestion
last_non_empty_idx = next(
(idx for idx in range(len(lines) - 1, -1, -1) if lines[idx].strip()),
None,
)
for idx, ln in enumerate(lines):
if not ln.strip():
f.write("\n")
elif idx == last_non_empty_idx:
```
_generate_sources_index accumulates every source (including full note text) into an in-memory sources list before writing. With “several hundred thousand sources”, this can become a large memory spike and/or slow GC. Consider streaming directly to Index.md as you scan elem_dict (write each entry immediately) so memory usage stays bounded.
`_generate_sources_index` accumulates every source (including full note text) into an in-memory `sources` list before writing. With “several hundred thousand sources”, this can become a large memory spike and/or slow GC. Consider streaming directly to `Index.md` as you scan `elem_dict` (write each entry immediately) so memory usage stays bounded.
These imports are inconsistent with the repo’s pytest configuration (pythonpath = src). With src/ added directly to sys.path and no src/__init__.py, from src.gedcom_parser ... will fail (it will look for src/src/gedcom_parser.py). Import the modules the same way other tests do (e.g., from gedcom_parser import GedcomParser, etc.).
from gedcom_parser import GedcomParser
from individual import Individual
from markdown_generator import MarkdownGenerator
These imports are inconsistent with the repo’s pytest configuration (`pythonpath = src`). With `src/` added directly to `sys.path` and no `src/__init__.py`, `from src.gedcom_parser ...` will fail (it will look for `src/src/gedcom_parser.py`). Import the modules the same way other tests do (e.g., `from gedcom_parser import GedcomParser`, etc.).
```suggestion
from gedcom_parser import GedcomParser
from individual import Individual
from markdown_generator import MarkdownGenerator
```
coderabbitai[bot]
(Migrated from github.com)
left a comment
Copy link
Copy source
Actionable comments posted: 4
🧹 Nitpick comments (3)
src/markdown_generator.py (2)
546-577: Recommended: deduplicate NOTE/CONT/CONC resolution with Individual._resolve_gedcom_text.
The pointer and inline branches here reimplement the same logic already present in Individual._resolve_gedcom_text (src/individual.py:375-414). Beyond duplication, the two implementations can drift — e.g. the source-index version doesn't short-circuit when target has no children the same way, and any future bug fix has to be made in two places. Consider either:
accepting a parser into a module-level resolve_gedcom_text(parser, value, element) helper used by both call sites, or
factoring the SOUR-record extraction into an Individual classmethod and having _generate_sources_index build a throwaway Individual-style view per record.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 546 - 577, The NOTE/CONT/CONC
resolution in _generate_sources_index duplicates
Individual._resolve_gedcom_text; refactor by extracting the shared logic into a
single callable (e.g., module-level function resolve_gedcom_text(parser, value,
element) or a classmethod on Individual) and replace the inline pointer and
inline branches in markdown_generator._generate_sources_index with calls to that
shared resolver (invoke Individual._resolve_gedcom_text or the new
resolve_gedcom_text) so both code paths use the same implementation and avoid
drift.
Both the outer except Exception: at 531 and the per-element except Exception: continue at 539-540 swallow errors with no logging context. At minimum log at debug/warning to aid diagnostics on malformed GEDCOMs; ideally narrow to the specific exception types raised by the gedcom library (e.g. AttributeError). Combined with the flag-not-set issue flagged separately, this is also how a one-time parse failure turns into an every-note failure.
🛠️ Proposed fix
- for elem in elem_dict.values():
- try:
- if elem.get_tag() != "SOUR":
- continue
- except Exception:
- continue
+ for elem in elem_dict.values():
+ try:
+ if elem.get_tag() != "SOUR":
+ continue
+ except AttributeError:
+ logger.debug("Skipping element with no get_tag() while building sources index")
+ continue
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 529 - 540, The outer broad except
around parser.get_element_dictionary() and the per-element except around
elem.get_tag() silently swallow errors; change them to catch specific exceptions
(e.g., ValueError, AttributeError, or the gedcom library's specific exception
types) instead of Exception, and log the error with context (including the
exception info) before returning or continuing so malformed GEDCOMs are
diagnosable; update the handlers around parser.get_element_dictionary(),
elem.get_tag(), and the elem_dict -> sources loop to use targeted exception
types and logger.debug/logger.warning with the element id or parser state.
src/individual.py (1)
435-436: Optional: hoist _collapse_single_line to avoid duplication.
The nested _collapse_single_line here is identical in intent to MarkdownGenerator._collapse_single_line (and mirrors the shape of Individual._collapse_preserve_lines). Consider promoting it to a private method on Individual (e.g. _collapse_single_line) or a small module-level utility so both modules share one definition.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/individual.py` around lines 435 - 436, The nested helper
_collapse_single_line in the local scope duplicates
MarkdownGenerator._collapse_single_line and mirrors
Individual._collapse_preserve_lines; hoist it to a single shared private
implementation (either add a new Individual._collapse_single_line class/private
method or a module-level function _collapse_single_line) and replace the
nested/local definition with calls to that shared symbol, updating
MarkdownGenerator and any places using Individual._collapse_preserve_lines to
call the unified helper to remove duplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/markdown_generator.py`:
- Around line 691-701: The non-nested branch in src/markdown_generator.py
compares line content to last_non_empty by value, which breaks when duplicate
lines exist; change the logic in that block (the loop that writes lines) to
compute the index of the last non-empty line (e.g., last_non_empty_index) and
iterate with enumerate over lines, comparing the current index to
last_non_empty_index so only the final non-empty line is written without the
trailing two spaces; update the loop that references last_non_empty (and the
non_empty list creation if needed) to use indices rather than value equality.
- Around line 529-615: The early-return paths in the _generate_sources_index
flow don't set the guard flag, so set self._sources_index_generated = True
before each early return to avoid repeated work: after the outer except block
that currently "return" (the block after parser.get_element_dictionary()) and
before the "return" when not sources (the if not sources: return), assign
self._sources_index_generated = True then return; this ensures subsequent
generate_note() calls see the one-shot guard (_sources_index_generated) and skip
re-scanning the element dictionary.
In `@tests/test_notes_cont_conc.py`:
- Around line 15-45: The test currently exercises the pointer-resolution path of
_resolve_gedcom_text because the INDI uses a NOTE pointer; change the test to
cover the inline NOTE branch by replacing the pointer-style note with an inline
NOTE child on the INDI (e.g., put the CONT/CONC lines as level-2 children under
"1 NOTE" on `@I1`@) or add a new test that follows that structure; update the test
name to reflect whether it now covers the inline branch (e.g.,
test_note_cont_and_conc_inline -> test_note_cont_and_conc_inline_in_indi) and
keep assertions for CONC concatenation and CONT newline behavior.
In `@tests/test_sources.py`:
- Around line 3-5: Update the imports in test_notes_cont_conc.py to remove the
src. prefix so they match pytest.ini's pythonpath and the other tests;
specifically change any imports like from src.gedcom_parser import GedcomParser
(and similarly for Individual, MarkdownGenerator, etc.) to from gedcom_parser
import GedcomParser (and from individual import Individual, from
markdown_generator import MarkdownGenerator) so the test uses the same
non-prefixed module names as the rest of the suite.
---
Nitpick comments:
In `@src/individual.py`:
- Around line 435-436: The nested helper _collapse_single_line in the local
scope duplicates MarkdownGenerator._collapse_single_line and mirrors
Individual._collapse_preserve_lines; hoist it to a single shared private
implementation (either add a new Individual._collapse_single_line class/private
method or a module-level function _collapse_single_line) and replace the
nested/local definition with calls to that shared symbol, updating
MarkdownGenerator and any places using Individual._collapse_preserve_lines to
call the unified helper to remove duplication.
In `@src/markdown_generator.py`:
- Around line 546-577: The NOTE/CONT/CONC resolution in _generate_sources_index
duplicates Individual._resolve_gedcom_text; refactor by extracting the shared
logic into a single callable (e.g., module-level function
resolve_gedcom_text(parser, value, element) or a classmethod on Individual) and
replace the inline pointer and inline branches in
markdown_generator._generate_sources_index with calls to that shared resolver
(invoke Individual._resolve_gedcom_text or the new resolve_gedcom_text) so both
code paths use the same implementation and avoid drift.
- Around line 529-540: The outer broad except around
parser.get_element_dictionary() and the per-element except around elem.get_tag()
silently swallow errors; change them to catch specific exceptions (e.g.,
ValueError, AttributeError, or the gedcom library's specific exception types)
instead of Exception, and log the error with context (including the exception
info) before returning or continuing so malformed GEDCOMs are diagnosable;
update the handlers around parser.get_element_dictionary(), elem.get_tag(), and
the elem_dict -> sources loop to use targeted exception types and
logger.debug/logger.warning with the element id or parser state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
Push a commit to this branch (recommended)
Create a new PR with the fixes
ℹ️ Review info⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 334159b2-5e63-40cb-81ca-b084e6e3ae0b
📥 Commits
Reviewing files that changed from the base of the PR and between 48e339c119 and 6259bfffd6.
📒 Files selected for processing (4)
src/individual.py
src/markdown_generator.py
tests/test_notes_cont_conc.py
tests/test_sources.py
**Actionable comments posted: 4**
<details>
<summary>🧹 Nitpick comments (3)</summary><blockquote>
<details>
<summary>src/markdown_generator.py (2)</summary><blockquote>
`546-577`: **Recommended: deduplicate NOTE/CONT/CONC resolution with `Individual._resolve_gedcom_text`.**
The pointer and inline branches here reimplement the same logic already present in `Individual._resolve_gedcom_text` (src/individual.py:375-414). Beyond duplication, the two implementations can drift — e.g. the source-index version doesn't short-circuit when `target` has no children the same way, and any future bug fix has to be made in two places. Consider either:
- accepting a `parser` into a module-level `resolve_gedcom_text(parser, value, element)` helper used by both call sites, or
- factoring the SOUR-record extraction into an `Individual` classmethod and having `_generate_sources_index` build a throwaway `Individual`-style view per record.
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 546 - 577, The NOTE/CONT/CONC
resolution in _generate_sources_index duplicates
Individual._resolve_gedcom_text; refactor by extracting the shared logic into a
single callable (e.g., module-level function resolve_gedcom_text(parser, value,
element) or a classmethod on Individual) and replace the inline pointer and
inline branches in markdown_generator._generate_sources_index with calls to that
shared resolver (invoke Individual._resolve_gedcom_text or the new
resolve_gedcom_text) so both code paths use the same implementation and avoid
drift.
```
</details>
---
`529-540`: **Silent broad `except Exception` blocks (ruff BLE001 / S112).**
Both the outer `except Exception:` at 531 and the per-element `except Exception: continue` at 539-540 swallow errors with no logging context. At minimum log at `debug`/`warning` to aid diagnostics on malformed GEDCOMs; ideally narrow to the specific exception types raised by the gedcom library (e.g. `AttributeError`). Combined with the flag-not-set issue flagged separately, this is also how a one-time parse failure turns into an every-note failure.
<details>
<summary>🛠️ Proposed fix</summary>
```diff
- for elem in elem_dict.values():
- try:
- if elem.get_tag() != "SOUR":
- continue
- except Exception:
- continue
+ for elem in elem_dict.values():
+ try:
+ if elem.get_tag() != "SOUR":
+ continue
+ except AttributeError:
+ logger.debug("Skipping element with no get_tag() while building sources index")
+ continue
```
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 529 - 540, The outer broad except
around parser.get_element_dictionary() and the per-element except around
elem.get_tag() silently swallow errors; change them to catch specific exceptions
(e.g., ValueError, AttributeError, or the gedcom library's specific exception
types) instead of Exception, and log the error with context (including the
exception info) before returning or continuing so malformed GEDCOMs are
diagnosable; update the handlers around parser.get_element_dictionary(),
elem.get_tag(), and the elem_dict -> sources loop to use targeted exception
types and logger.debug/logger.warning with the element id or parser state.
```
</details>
</blockquote></details>
<details>
<summary>src/individual.py (1)</summary><blockquote>
`435-436`: **Optional: hoist `_collapse_single_line` to avoid duplication.**
The nested `_collapse_single_line` here is identical in intent to `MarkdownGenerator._collapse_single_line` (and mirrors the shape of `Individual._collapse_preserve_lines`). Consider promoting it to a private method on `Individual` (e.g. `_collapse_single_line`) or a small module-level utility so both modules share one definition.
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/individual.py` around lines 435 - 436, The nested helper
_collapse_single_line in the local scope duplicates
MarkdownGenerator._collapse_single_line and mirrors
Individual._collapse_preserve_lines; hoist it to a single shared private
implementation (either add a new Individual._collapse_single_line class/private
method or a module-level function _collapse_single_line) and replace the
nested/local definition with calls to that shared symbol, updating
MarkdownGenerator and any places using Individual._collapse_preserve_lines to
call the unified helper to remove duplication.
```
</details>
</blockquote></details>
</blockquote></details>
<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>
```
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/markdown_generator.py`:
- Around line 691-701: The non-nested branch in src/markdown_generator.py
compares line content to last_non_empty by value, which breaks when duplicate
lines exist; change the logic in that block (the loop that writes lines) to
compute the index of the last non-empty line (e.g., last_non_empty_index) and
iterate with enumerate over lines, comparing the current index to
last_non_empty_index so only the final non-empty line is written without the
trailing two spaces; update the loop that references last_non_empty (and the
non_empty list creation if needed) to use indices rather than value equality.
- Around line 529-615: The early-return paths in the _generate_sources_index
flow don't set the guard flag, so set self._sources_index_generated = True
before each early return to avoid repeated work: after the outer except block
that currently "return" (the block after parser.get_element_dictionary()) and
before the "return" when not sources (the if not sources: return), assign
self._sources_index_generated = True then return; this ensures subsequent
generate_note() calls see the one-shot guard (_sources_index_generated) and skip
re-scanning the element dictionary.
In `@tests/test_notes_cont_conc.py`:
- Around line 15-45: The test currently exercises the pointer-resolution path of
_resolve_gedcom_text because the INDI uses a NOTE pointer; change the test to
cover the inline NOTE branch by replacing the pointer-style note with an inline
NOTE child on the INDI (e.g., put the CONT/CONC lines as level-2 children under
"1 NOTE" on `@I1`@) or add a new test that follows that structure; update the test
name to reflect whether it now covers the inline branch (e.g.,
test_note_cont_and_conc_inline -> test_note_cont_and_conc_inline_in_indi) and
keep assertions for CONC concatenation and CONT newline behavior.
In `@tests/test_sources.py`:
- Around line 3-5: Update the imports in test_notes_cont_conc.py to remove the
src. prefix so they match pytest.ini's pythonpath and the other tests;
specifically change any imports like from src.gedcom_parser import GedcomParser
(and similarly for Individual, MarkdownGenerator, etc.) to from gedcom_parser
import GedcomParser (and from individual import Individual, from
markdown_generator import MarkdownGenerator) so the test uses the same
non-prefixed module names as the rest of the suite.
---
Nitpick comments:
In `@src/individual.py`:
- Around line 435-436: The nested helper _collapse_single_line in the local
scope duplicates MarkdownGenerator._collapse_single_line and mirrors
Individual._collapse_preserve_lines; hoist it to a single shared private
implementation (either add a new Individual._collapse_single_line class/private
method or a module-level function _collapse_single_line) and replace the
nested/local definition with calls to that shared symbol, updating
MarkdownGenerator and any places using Individual._collapse_preserve_lines to
call the unified helper to remove duplication.
In `@src/markdown_generator.py`:
- Around line 546-577: The NOTE/CONT/CONC resolution in _generate_sources_index
duplicates Individual._resolve_gedcom_text; refactor by extracting the shared
logic into a single callable (e.g., module-level function
resolve_gedcom_text(parser, value, element) or a classmethod on Individual) and
replace the inline pointer and inline branches in
markdown_generator._generate_sources_index with calls to that shared resolver
(invoke Individual._resolve_gedcom_text or the new resolve_gedcom_text) so both
code paths use the same implementation and avoid drift.
- Around line 529-540: The outer broad except around
parser.get_element_dictionary() and the per-element except around elem.get_tag()
silently swallow errors; change them to catch specific exceptions (e.g.,
ValueError, AttributeError, or the gedcom library's specific exception types)
instead of Exception, and log the error with context (including the exception
info) before returning or continuing so malformed GEDCOMs are diagnosable;
update the handlers around parser.get_element_dictionary(), elem.get_tag(), and
the elem_dict -> sources loop to use targeted exception types and
logger.debug/logger.warning with the element id or parser state.
```
</details>
<details>
<summary>🪄 Autofix (Beta)</summary>
Fix all unresolved CodeRabbit comments on this PR:
- [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)
- [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes
</details>
---
<details>
<summary>ℹ️ Review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
**Configuration used**: defaults
**Review profile**: CHILL
**Plan**: Pro
**Run ID**: `334159b2-5e63-40cb-81ca-b084e6e3ae0b`
</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between 48e339c1199a7abe69ac3c565c77b4d86fa027fd and 6259bfffd6253846b705b0be6660e9bcdfdcb9bd.
</details>
<details>
<summary>📒 Files selected for processing (4)</summary>
* `src/individual.py`
* `src/markdown_generator.py`
* `tests/test_notes_cont_conc.py`
* `tests/test_sources.py`
</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
Major: _sources_index_generated flag is not set on early returns — reintroduces the very O(N·S) behavior this PR targets.
The flag is only set at the very end (line 615). Both early exits — the outer except Exception: return at 531-532 and the if not sources: return at 586-587 — leave the flag False, so every subsequent generate_note() call will call _generate_sources_index again and re-scan the full element dictionary. For a GEDCOM with no SOUR records and hundreds of thousands of individuals, this undoes the one-shot guard completely.
🛠️ Proposed fix
def _generate_sources_index(self, parser):
"""
Generate a summary Index.md in a sources/ subdirectory listing all SOURCE records found in the GEDCOM element dictionary.
"""
try:
elem_dict = parser.get_element_dictionary()
except Exception:
+ # Mark as attempted so we don't retry on every note.
+ self._sources_index_generated = True
+ logger.exception("Failed to access GEDCOM element dictionary for sources index")
return
@@
if not sources:
+ self._sources_index_generated = True
return
🧰 Tools🪛 Ruff (0.15.10)
[warning] 531-531: Do not catch blind exception: Exception
(BLE001)
[error] 539-540: try-except-continue detected, consider logging the exception
(S112)
[warning] 539-539: Do not catch blind exception: Exception
(BLE001)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 529 - 615, The early-return paths in
the _generate_sources_index flow don't set the guard flag, so set
self._sources_index_generated = True before each early return to avoid repeated
work: after the outer except block that currently "return" (the block after
parser.get_element_dictionary()) and before the "return" when not sources (the
if not sources: return), assign self._sources_index_generated = True then
return; this ensures subsequent generate_note() calls see the one-shot guard
(_sources_index_generated) and skip re-scanning the element dictionary.
_⚠️ Potential issue_ | _🟠 Major_
**Major: `_sources_index_generated` flag is not set on early returns — reintroduces the very O(N·S) behavior this PR targets.**
The flag is only set at the very end (line 615). Both early exits — the outer `except Exception: return` at 531-532 and the `if not sources: return` at 586-587 — leave the flag `False`, so every subsequent `generate_note()` call will call `_generate_sources_index` again and re-scan the full element dictionary. For a GEDCOM with no `SOUR` records and hundreds of thousands of individuals, this undoes the one-shot guard completely.
<details>
<summary>🛠️ Proposed fix</summary>
```diff
def _generate_sources_index(self, parser):
"""
Generate a summary Index.md in a sources/ subdirectory listing all SOURCE records found in the GEDCOM element dictionary.
"""
try:
elem_dict = parser.get_element_dictionary()
except Exception:
+ # Mark as attempted so we don't retry on every note.
+ self._sources_index_generated = True
+ logger.exception("Failed to access GEDCOM element dictionary for sources index")
return
@@
if not sources:
+ self._sources_index_generated = True
return
```
</details>
<details>
<summary>🧰 Tools</summary>
<details>
<summary>🪛 Ruff (0.15.10)</summary>
[warning] 531-531: Do not catch blind exception: `Exception`
(BLE001)
---
[error] 539-540: `try`-`except`-`continue` detected, consider logging the exception
(S112)
---
[warning] 539-539: Do not catch blind exception: `Exception`
(BLE001)
</details>
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 529 - 615, The early-return paths in
the _generate_sources_index flow don't set the guard flag, so set
self._sources_index_generated = True before each early return to avoid repeated
work: after the outer except block that currently "return" (the block after
parser.get_element_dictionary()) and before the "return" when not sources (the
if not sources: return), assign self._sources_index_generated = True then
return; this ensures subsequent generate_note() calls see the one-shot guard
(_sources_index_generated) and skip re-scanning the element dictionary.
```
</details>
<!-- fingerprinting:phantom:medusa:nectarine:ccd9701b-1961-486a-aa73-330d7083f6ad -->
<!-- This is an auto-generated comment by CodeRabbit -->
✅ Addressed in commit 96da61c
Minor bug: duplicate lines lose their hard break in the non-nested branch.
last_non_empty = non_empty[-1] is compared by value, so if the note contains two identical non-empty lines, both match ln == last_non_empty and both are written without the trailing two spaces — collapsing the intended hard break between them. Use the last index (or iterate with enumerate and track the index of the last non-empty entry) instead.
🛠️ Proposed fix
- else:
- # Non-nested: add two spaces to all non-empty lines except the last non-empty
- non_empty = [ln for ln in lines if ln.strip()]
- last_non_empty = non_empty[-1] if non_empty else None
- for ln in lines:
- if not ln.strip():
- f.write("\n")
- elif ln == last_non_empty:
- f.write(f"{ln}\n")
- else:
- f.write(f"{ln} \n")
+ else:
+ # Non-nested: add two spaces to all non-empty lines except the last non-empty one.
+ last_non_empty_idx = -1
+ for i, ln in enumerate(lines):
+ if ln.strip():
+ last_non_empty_idx = i
+ for i, ln in enumerate(lines):
+ if not ln.strip():
+ f.write("\n")
+ elif i == last_non_empty_idx:
+ f.write(f"{ln}\n")
+ else:
+ f.write(f"{ln} \n")
📝 Committable suggestion
‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
else:
# Non-nested: add two spaces to all non-empty lines except the last non-empty one.
last_non_empty_idx = -1
for i, ln in enumerate(lines):
if ln.strip():
last_non_empty_idx = i
for i, ln in enumerate(lines):
if not ln.strip():
f.write("\n")
elif i == last_non_empty_idx:
f.write(f"{ln}\n")
else:
f.write(f"{ln} \n")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 691 - 701, The non-nested branch in
src/markdown_generator.py compares line content to last_non_empty by value,
which breaks when duplicate lines exist; change the logic in that block (the
loop that writes lines) to compute the index of the last non-empty line (e.g.,
last_non_empty_index) and iterate with enumerate over lines, comparing the
current index to last_non_empty_index so only the final non-empty line is
written without the trailing two spaces; update the loop that references
last_non_empty (and the non_empty list creation if needed) to use indices rather
than value equality.
_⚠️ Potential issue_ | _🟡 Minor_
**Minor bug: duplicate lines lose their hard break in the non-nested branch.**
`last_non_empty = non_empty[-1]` is compared by value, so if the note contains two identical non-empty lines, both match `ln == last_non_empty` and both are written without the trailing two spaces — collapsing the intended hard break between them. Use the last *index* (or iterate with `enumerate` and track the index of the last non-empty entry) instead.
<details>
<summary>🛠️ Proposed fix</summary>
```diff
- else:
- # Non-nested: add two spaces to all non-empty lines except the last non-empty
- non_empty = [ln for ln in lines if ln.strip()]
- last_non_empty = non_empty[-1] if non_empty else None
- for ln in lines:
- if not ln.strip():
- f.write("\n")
- elif ln == last_non_empty:
- f.write(f"{ln}\n")
- else:
- f.write(f"{ln} \n")
+ else:
+ # Non-nested: add two spaces to all non-empty lines except the last non-empty one.
+ last_non_empty_idx = -1
+ for i, ln in enumerate(lines):
+ if ln.strip():
+ last_non_empty_idx = i
+ for i, ln in enumerate(lines):
+ if not ln.strip():
+ f.write("\n")
+ elif i == last_non_empty_idx:
+ f.write(f"{ln}\n")
+ else:
+ f.write(f"{ln} \n")
```
</details>
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
```suggestion
else:
# Non-nested: add two spaces to all non-empty lines except the last non-empty one.
last_non_empty_idx = -1
for i, ln in enumerate(lines):
if ln.strip():
last_non_empty_idx = i
for i, ln in enumerate(lines):
if not ln.strip():
f.write("\n")
elif i == last_non_empty_idx:
f.write(f"{ln}\n")
else:
f.write(f"{ln} \n")
```
</details>
<!-- suggestion_end -->
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 691 - 701, The non-nested branch in
src/markdown_generator.py compares line content to last_non_empty by value,
which breaks when duplicate lines exist; change the logic in that block (the
loop that writes lines) to compute the index of the last non-empty line (e.g.,
last_non_empty_index) and iterate with enumerate over lines, comparing the
current index to last_non_empty_index so only the final non-empty line is
written without the trailing two spaces; update the loop that references
last_non_empty (and the non_empty list creation if needed) to use indices rather
than value equality.
```
</details>
<!-- fingerprinting:phantom:medusa:nectarine:ccd9701b-1961-486a-aa73-330d7083f6ad -->
<!-- This is an auto-generated comment by CodeRabbit -->
✅ Addressed in commit 96da61c
test_note_cont_and_conc_inline declares an inline NOTE @N1@ pointer on @I1@, which routes through the pointer-resolution branch of _resolve_gedcom_text — the same branch that test_note_reference_to_note_with_cont_conc covers. There is currently no coverage for the inline branch (CONT/CONC as direct children of an INDI-level 1 NOTE <text>). Consider either renaming this test or adding a case like:
0 `@I1`@ INDI
1 NAME John /Doe/
1 NOTE First line
2 CONC -continued
2 CONT Next paragraph
to exercise the element is not None path in _resolve_gedcom_text.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/test_notes_cont_conc.py` around lines 15 - 45, The test currently
exercises the pointer-resolution path of _resolve_gedcom_text because the INDI
uses a NOTE pointer; change the test to cover the inline NOTE branch by
replacing the pointer-style note with an inline NOTE child on the INDI (e.g.,
put the CONT/CONC lines as level-2 children under "1 NOTE" on `@I1`@) or add a new
test that follows that structure; update the test name to reflect whether it now
covers the inline branch (e.g., test_note_cont_and_conc_inline ->
test_note_cont_and_conc_inline_in_indi) and keep assertions for CONC
concatenation and CONT newline behavior.
_⚠️ Potential issue_ | _🟡 Minor_
**Test name doesn't match what it exercises.**
`test_note_cont_and_conc_inline` declares an inline `NOTE `@N1`@` pointer on `@I1@`, which routes through the pointer-resolution branch of `_resolve_gedcom_text` — the same branch that `test_note_reference_to_note_with_cont_conc` covers. There is currently no coverage for the *inline* branch (CONT/CONC as direct children of an INDI-level `1 NOTE <text>`). Consider either renaming this test or adding a case like:
```
0 `@I1`@ INDI
1 NAME John /Doe/
1 NOTE First line
2 CONC -continued
2 CONT Next paragraph
```
to exercise the `element is not None` path in `_resolve_gedcom_text`.
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@tests/test_notes_cont_conc.py` around lines 15 - 45, The test currently
exercises the pointer-resolution path of _resolve_gedcom_text because the INDI
uses a NOTE pointer; change the test to cover the inline NOTE branch by
replacing the pointer-style note with an inline NOTE child on the INDI (e.g.,
put the CONT/CONC lines as level-2 children under "1 NOTE" on `@I1`@) or add a new
test that follows that structure; update the test name to reflect whether it now
covers the inline branch (e.g., test_note_cont_and_conc_inline ->
test_note_cont_and_conc_inline_in_indi) and keep assertions for CONC
concatenation and CONT newline behavior.
```
</details>
<!-- fingerprinting:phantom:medusa:nectarine:ccd9701b-1961-486a-aa73-330d7083f6ad -->
<!-- This is an auto-generated comment by CodeRabbit -->
✅ Addressed in commit 96da61c
#!/bin/bash
# Inspect conftest/pytest config and confirm which import style is supported.
fd -a -H '^(conftest\.py|pytest\.ini|pyproject\.toml|setup\.cfg|tox\.ini)$'echo'--- conftest.py contents (if any) ---'
fd -H '^conftest\.py$' --exec cat {}echo'--- pytest config in pyproject.toml ---'
fd -H '^pyproject\.toml$' --exec rg -n -A5 '\[tool\.pytest'{}echo'--- test import lines across tests/ ---'
rg -n '^from (src\.)?(gedcom_parser|individual|markdown_generator)' tests
Repository: AlexKucera/gedcom-to-markdown
Length of output: 4661
🏁 Script executed:
cat /home/jailuser/git/pytest.ini
Repository: AlexKucera/gedcom-to-markdown
Length of output: 318
Fix import paths to match pytest configuration.
The pytest.ini file configures pythonpath = src, which adds the src/ directory to sys.path. This means imports should use the style from gedcom_parser import ... (without the src. prefix).
The file test_notes_cont_conc.py currently imports from src.gedcom_parser import ..., which contradicts the pytest configuration and differs from the other five test files (test_sources.py, test_individual.py, test_index_generator.py, test_markdown_generator.py, test_gedcom_parser.py) which all use the correct non-prefixed style.
Update test_notes_cont_conc.py to remove the src. prefix from its imports to align with the pytest configuration and the rest of the test suite.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/test_sources.py` around lines 3 - 5, Update the imports in
test_notes_cont_conc.py to remove the src. prefix so they match pytest.ini's
pythonpath and the other tests; specifically change any imports like from
src.gedcom_parser import GedcomParser (and similarly for Individual,
MarkdownGenerator, etc.) to from gedcom_parser import GedcomParser (and from
individual import Individual, from markdown_generator import MarkdownGenerator)
so the test uses the same non-prefixed module names as the rest of the suite.
_⚠️ Potential issue_ | _🟠 Major_
<details>
<summary>🧩 Analysis chain</summary>
🏁 Script executed:
```shell
#!/bin/bash
# Inspect conftest/pytest config and confirm which import style is supported.
fd -a -H '^(conftest\.py|pytest\.ini|pyproject\.toml|setup\.cfg|tox\.ini)$'
echo '--- conftest.py contents (if any) ---'
fd -H '^conftest\.py$' --exec cat {}
echo '--- pytest config in pyproject.toml ---'
fd -H '^pyproject\.toml$' --exec rg -n -A5 '\[tool\.pytest' {}
echo '--- test import lines across tests/ ---'
rg -n '^from (src\.)?(gedcom_parser|individual|markdown_generator)' tests
```
Repository: AlexKucera/gedcom-to-markdown
Length of output: 4661
---
🏁 Script executed:
```shell
cat /home/jailuser/git/pytest.ini
```
Repository: AlexKucera/gedcom-to-markdown
Length of output: 318
---
</details>
**Fix import paths to match pytest configuration.**
The `pytest.ini` file configures `pythonpath = src`, which adds the `src/` directory to `sys.path`. This means imports should use the style `from gedcom_parser import ...` (without the `src.` prefix).
The file `test_notes_cont_conc.py` currently imports `from src.gedcom_parser import ...`, which contradicts the pytest configuration and differs from the other five test files (`test_sources.py`, `test_individual.py`, `test_index_generator.py`, `test_markdown_generator.py`, `test_gedcom_parser.py`) which all use the correct non-prefixed style.
Update `test_notes_cont_conc.py` to remove the `src.` prefix from its imports to align with the pytest configuration and the rest of the test suite.
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@tests/test_sources.py` around lines 3 - 5, Update the imports in
test_notes_cont_conc.py to remove the src. prefix so they match pytest.ini's
pythonpath and the other tests; specifically change any imports like from
src.gedcom_parser import GedcomParser (and similarly for Individual,
MarkdownGenerator, etc.) to from gedcom_parser import GedcomParser (and from
individual import Individual, from markdown_generator import MarkdownGenerator)
so the test uses the same non-prefixed module names as the rest of the suite.
```
</details>
<!-- fingerprinting:phantom:medusa:nectarine:ccd9701b-1961-486a-aa73-330d7083f6ad -->
<!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot]
(Migrated from github.com)
left a comment
Copy link
Copy source
Actionable comments posted: 4
♻️ Duplicate comments (1)
src/markdown_generator.py (1)
132-138: ⚠️ Potential issue | 🟠 Major
Set the one-shot guard when source index generation raises.
If _generate_sources_index() fails after dictionary retrieval, e.g. during mkdir, open, or writing, the flag remains False and later notes retry the expensive index path.
🛠️ Proposed fix
if not getattr(self, '_sources_index_generated', False):
parser = getattr(individual, 'gedcom', None)
if parser:
try:
self._generate_sources_index(parser)
except Exception:
logger.exception('Failed to generate sources index')
+ self._sources_index_generated = True
@@
if parser:
try:
self._generate_sources_index(parser)
except Exception:
logger.exception('Failed to generate sources index')
+ self._sources_index_generated = True
Also applies to: 869-873
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 132 - 138, The one-shot guard
_sources_index_generated isn't set when _generate_sources_index(gedcom) raises,
causing repeated expensive retries; update the block around the call (where
parser = getattr(individual, 'gedcom', None) and _generate_sources_index is
invoked) to ensure _sources_index_generated is set to True regardless of success
(e.g., in a finally-like path) so failures still mark the attempt, while keeping
the existing logger.exception('Failed to generate sources index') on error.
🧹 Nitpick comments (2)
tests/test_individual.py (2)
500-544: Avoid duplicating the note extraction tests.
These two tests duplicate the existing TestNotes.test_get_notes_inline and TestNotes.test_get_notes_empty cases at Lines 563-607, so they add runtime and maintenance cost without new coverage.
♻️ Proposed cleanup
- def test_get_notes_inline(self, temp_dir):
- """Test inline note extraction."""
- gedcom_content = """0 HEAD
-1 SOUR TestApp
-1 GEDC
-2 VERS 5.5.1
-1 CHAR UTF-8
-0 `@I1`@ INDI
-1 NAME Test /Person/
-1 NOTE This is an inline note.
-2 CONT It has multiple lines.
-0 TRLR
-"""
- temp_file = temp_dir / "inline_notes.ged"
- temp_file.write_text(gedcom_content, encoding='utf-8')
-
- parser = GedcomParser(temp_file)
- individuals = parser.get_individuals()
- person = Individual(individuals[0], parser.parser)
-
- notes = person.get_notes()
- assert len(notes) >= 1
- assert 'inline note' in notes[0].lower()
- assert 'multiple lines' in notes[0].lower()
-
- def test_get_notes_empty(self, temp_dir):
- """Test note extraction when no notes are present."""
- gedcom_content = """0 HEAD
-1 SOUR TestApp
-1 GEDC
-2 VERS 5.5.1
-1 CHAR UTF-8
-0 `@I1`@ INDI
-1 NAME Test /Person/
-0 TRLR
-"""
- temp_file = temp_dir / "no_notes.ged"
- temp_file.write_text(gedcom_content, encoding='utf-8')
-
- parser = GedcomParser(temp_file)
- individuals = parser.get_individuals()
- person = Individual(individuals[0], parser.parser)
-
- notes = person.get_notes()
- assert len(notes) == 0
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/test_individual.py` around lines 500 - 544, Remove the duplicated
note-extraction tests in tests/test_individual.py by deleting the two functions
test_get_notes_inline and test_get_notes_empty (they duplicate
TestNotes.test_get_notes_inline and TestNotes.test_get_notes_empty); ensure no
other tests rely on these functions and run the test suite to confirm coverage
remains unchanged.
464-473: Use next(...) for the single expected match.
The code currently violates Ruff's RUF015 rule in three places. Replace list comprehension with index access with next() to get the first matching element.
♻️ Proposed cleanup
- parent = [ind for ind in individuals if ind.get_pointer() == "@I1@"][0]
+ parent = next(ind for ind in individuals if ind.get_pointer() == "@I1@")
parent_obj = Individual(parent, parser.parser)
families = parent_obj.get_families()
assert len(families) == 2
- family_one = [f for f in families if f["marriage_place"] == "Place One"][0]
- family_two = [f for f in families if f["marriage_place"] == "Place Two"][0]
+ family_one = next(f for f in families if f["marriage_place"] == "Place One")
+ family_two = next(f for f in families if f["marriage_place"] == "Place Two")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/test_individual.py` around lines 464 - 473, Replace the
list-comprehension-then-index patterns with next(...) generator expressions to
satisfy RUF015: use next((ind for ind in GedcomParser(...).get_individuals() if
ind.get_pointer() == "@I1@")) instead of [ind for ind in individuals if ...][0]
when selecting the parent, and use next((f for f in parent_obj.get_families() if
f["marriage_place"] == "Place One")) and next((f for f in
parent_obj.get_families() if f["marriage_place"] == "Place Two")) for family_one
and family_two; keep the same predicates and let the assertion behavior remain
the same (no default needed since a match is expected).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/individual.py`:
- Around line 596-599: The current guard `if text and not text.startswith("@")`
incorrectly drops valid inline notes beginning with "@"; instead rely on
_resolve_gedcom_text to return an empty string for unresolved pointer-style
notes and only skip when text is falsy. Update the block that uses
self._resolve_gedcom_text(child.get_value()) so that when text is truthy you
always append self._collapse_preserve_lines(text) to notes (remove the
startswith("@") check); keep using _resolve_gedcom_text and
_collapse_preserve_lines as before.
- Around line 645-648: The current block that handles tag == "NOTE" overwrites
previous notes (raw_note/note_text) and thus loses earlier source notes; change
the logic in src/individual.py inside the tag == "NOTE" branch to append each
resolved note_text (from _resolve_gedcom_text(raw_note, sc)) to a notes
collection on the source (e.g., source.notes or sc.notes) instead of assigning a
single string, ensuring you initialize that collection (empty list) if not
present and use .append(...) for each NOTE encountered so multiple NOTE children
are preserved.
In `@src/markdown_generator.py`:
- Around line 635-638: The NOTE handler currently overwrites note_text for each
NOTE child; change it to accumulate resolved notes instead: when tag == "NOTE"
(inside the source-record parsing loop), call resolve_gedcom_text(parser,
note_val, sc) as before but append the result to a collected list or concatenate
into an existing accumulator (e.g., note_texts or note_text += "\n\n" +
resolved) rather than assigning to note_text; ensure downstream code that emits
sources/Index.md consumes the accumulated notes (join the list or use the
accumulator) so all NOTE children are preserved.
- Around line 657-662: The empty-index cleanup currently swallows all exceptions
(try/except/pass) when calling index_file.unlink(), which hides failures and
triggers lint warnings; change the handler to catch OSError only and log the
error via the available logger (e.g., call logger.error or self.logger.error)
including context that unlinking index_file failed and the exception details, so
replace the bare except with "except OSError as e" and a logger.error(...) call
referencing index_file and e while leaving the rest of the logic intact
(symbols: index_file, written_any).
---
Duplicate comments:
In `@src/markdown_generator.py`:
- Around line 132-138: The one-shot guard _sources_index_generated isn't set
when _generate_sources_index(gedcom) raises, causing repeated expensive retries;
update the block around the call (where parser = getattr(individual, 'gedcom',
None) and _generate_sources_index is invoked) to ensure _sources_index_generated
is set to True regardless of success (e.g., in a finally-like path) so failures
still mark the attempt, while keeping the existing logger.exception('Failed to
generate sources index') on error.
---
Nitpick comments:
In `@tests/test_individual.py`:
- Around line 500-544: Remove the duplicated note-extraction tests in
tests/test_individual.py by deleting the two functions test_get_notes_inline and
test_get_notes_empty (they duplicate TestNotes.test_get_notes_inline and
TestNotes.test_get_notes_empty); ensure no other tests rely on these functions
and run the test suite to confirm coverage remains unchanged.
- Around line 464-473: Replace the list-comprehension-then-index patterns with
next(...) generator expressions to satisfy RUF015: use next((ind for ind in
GedcomParser(...).get_individuals() if ind.get_pointer() == "@I1@")) instead of
[ind for ind in individuals if ...][0] when selecting the parent, and use
next((f for f in parent_obj.get_families() if f["marriage_place"] == "Place
One")) and next((f for f in parent_obj.get_families() if f["marriage_place"] ==
"Place Two")) for family_one and family_two; keep the same predicates and let
the assertion behavior remain the same (no default needed since a match is
expected).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
Push a commit to this branch (recommended)
Create a new PR with the fixes
ℹ️ Review info⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1e70e519-cfc6-4cd8-be6e-f20b5c86e34c
📥 Commits
Reviewing files that changed from the base of the PR and between 6259bfffd6 and 676b4014ca.
📒 Files selected for processing (6)
src/individual.py
src/markdown_generator.py
tests/conftest.py
tests/test_individual.py
tests/test_markdown_generator.py
tests/test_notes_cont_conc.py
✅ Files skipped from review due to trivial changes (1)
tests/conftest.py
🚧 Files skipped from review as they are similar to previous changes (1)
tests/test_notes_cont_conc.py
**Actionable comments posted: 4**
<details>
<summary>♻️ Duplicate comments (1)</summary><blockquote>
<details>
<summary>src/markdown_generator.py (1)</summary><blockquote>
`132-138`: _⚠️ Potential issue_ | _🟠 Major_
**Set the one-shot guard when source index generation raises.**
If `_generate_sources_index()` fails after dictionary retrieval, e.g. during `mkdir`, `open`, or writing, the flag remains `False` and later notes retry the expensive index path.
<details>
<summary>🛠️ Proposed fix</summary>
```diff
if not getattr(self, '_sources_index_generated', False):
parser = getattr(individual, 'gedcom', None)
if parser:
try:
self._generate_sources_index(parser)
except Exception:
logger.exception('Failed to generate sources index')
+ self._sources_index_generated = True
@@
if parser:
try:
self._generate_sources_index(parser)
except Exception:
logger.exception('Failed to generate sources index')
+ self._sources_index_generated = True
```
</details>
Also applies to: 869-873
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 132 - 138, The one-shot guard
_sources_index_generated isn't set when _generate_sources_index(gedcom) raises,
causing repeated expensive retries; update the block around the call (where
parser = getattr(individual, 'gedcom', None) and _generate_sources_index is
invoked) to ensure _sources_index_generated is set to True regardless of success
(e.g., in a finally-like path) so failures still mark the attempt, while keeping
the existing logger.exception('Failed to generate sources index') on error.
```
</details>
</blockquote></details>
</blockquote></details>
<details>
<summary>🧹 Nitpick comments (2)</summary><blockquote>
<details>
<summary>tests/test_individual.py (2)</summary><blockquote>
`500-544`: **Avoid duplicating the note extraction tests.**
These two tests duplicate the existing `TestNotes.test_get_notes_inline` and `TestNotes.test_get_notes_empty` cases at Lines 563-607, so they add runtime and maintenance cost without new coverage.
<details>
<summary>♻️ Proposed cleanup</summary>
```diff
- def test_get_notes_inline(self, temp_dir):
- """Test inline note extraction."""
- gedcom_content = """0 HEAD
-1 SOUR TestApp
-1 GEDC
-2 VERS 5.5.1
-1 CHAR UTF-8
-0 `@I1`@ INDI
-1 NAME Test /Person/
-1 NOTE This is an inline note.
-2 CONT It has multiple lines.
-0 TRLR
-"""
- temp_file = temp_dir / "inline_notes.ged"
- temp_file.write_text(gedcom_content, encoding='utf-8')
-
- parser = GedcomParser(temp_file)
- individuals = parser.get_individuals()
- person = Individual(individuals[0], parser.parser)
-
- notes = person.get_notes()
- assert len(notes) >= 1
- assert 'inline note' in notes[0].lower()
- assert 'multiple lines' in notes[0].lower()
-
- def test_get_notes_empty(self, temp_dir):
- """Test note extraction when no notes are present."""
- gedcom_content = """0 HEAD
-1 SOUR TestApp
-1 GEDC
-2 VERS 5.5.1
-1 CHAR UTF-8
-0 `@I1`@ INDI
-1 NAME Test /Person/
-0 TRLR
-"""
- temp_file = temp_dir / "no_notes.ged"
- temp_file.write_text(gedcom_content, encoding='utf-8')
-
- parser = GedcomParser(temp_file)
- individuals = parser.get_individuals()
- person = Individual(individuals[0], parser.parser)
-
- notes = person.get_notes()
- assert len(notes) == 0
```
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@tests/test_individual.py` around lines 500 - 544, Remove the duplicated
note-extraction tests in tests/test_individual.py by deleting the two functions
test_get_notes_inline and test_get_notes_empty (they duplicate
TestNotes.test_get_notes_inline and TestNotes.test_get_notes_empty); ensure no
other tests rely on these functions and run the test suite to confirm coverage
remains unchanged.
```
</details>
---
`464-473`: **Use `next(...)` for the single expected match.**
The code currently violates Ruff's RUF015 rule in three places. Replace list comprehension with index access with `next()` to get the first matching element.
<details>
<summary>♻️ Proposed cleanup</summary>
```diff
- parent = [ind for ind in individuals if ind.get_pointer() == "@I1@"][0]
+ parent = next(ind for ind in individuals if ind.get_pointer() == "@I1@")
parent_obj = Individual(parent, parser.parser)
families = parent_obj.get_families()
assert len(families) == 2
- family_one = [f for f in families if f["marriage_place"] == "Place One"][0]
- family_two = [f for f in families if f["marriage_place"] == "Place Two"][0]
+ family_one = next(f for f in families if f["marriage_place"] == "Place One")
+ family_two = next(f for f in families if f["marriage_place"] == "Place Two")
```
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@tests/test_individual.py` around lines 464 - 473, Replace the
list-comprehension-then-index patterns with next(...) generator expressions to
satisfy RUF015: use next((ind for ind in GedcomParser(...).get_individuals() if
ind.get_pointer() == "@I1@")) instead of [ind for ind in individuals if ...][0]
when selecting the parent, and use next((f for f in parent_obj.get_families() if
f["marriage_place"] == "Place One")) and next((f for f in
parent_obj.get_families() if f["marriage_place"] == "Place Two")) for family_one
and family_two; keep the same predicates and let the assertion behavior remain
the same (no default needed since a match is expected).
```
</details>
</blockquote></details>
</blockquote></details>
<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>
```
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/individual.py`:
- Around line 596-599: The current guard `if text and not text.startswith("@")`
incorrectly drops valid inline notes beginning with "@"; instead rely on
_resolve_gedcom_text to return an empty string for unresolved pointer-style
notes and only skip when text is falsy. Update the block that uses
self._resolve_gedcom_text(child.get_value()) so that when text is truthy you
always append self._collapse_preserve_lines(text) to notes (remove the
startswith("@") check); keep using _resolve_gedcom_text and
_collapse_preserve_lines as before.
- Around line 645-648: The current block that handles tag == "NOTE" overwrites
previous notes (raw_note/note_text) and thus loses earlier source notes; change
the logic in src/individual.py inside the tag == "NOTE" branch to append each
resolved note_text (from _resolve_gedcom_text(raw_note, sc)) to a notes
collection on the source (e.g., source.notes or sc.notes) instead of assigning a
single string, ensuring you initialize that collection (empty list) if not
present and use .append(...) for each NOTE encountered so multiple NOTE children
are preserved.
In `@src/markdown_generator.py`:
- Around line 635-638: The NOTE handler currently overwrites note_text for each
NOTE child; change it to accumulate resolved notes instead: when tag == "NOTE"
(inside the source-record parsing loop), call resolve_gedcom_text(parser,
note_val, sc) as before but append the result to a collected list or concatenate
into an existing accumulator (e.g., note_texts or note_text += "\n\n" +
resolved) rather than assigning to note_text; ensure downstream code that emits
sources/Index.md consumes the accumulated notes (join the list or use the
accumulator) so all NOTE children are preserved.
- Around line 657-662: The empty-index cleanup currently swallows all exceptions
(try/except/pass) when calling index_file.unlink(), which hides failures and
triggers lint warnings; change the handler to catch OSError only and log the
error via the available logger (e.g., call logger.error or self.logger.error)
including context that unlinking index_file failed and the exception details, so
replace the bare except with "except OSError as e" and a logger.error(...) call
referencing index_file and e while leaving the rest of the logic intact
(symbols: index_file, written_any).
---
Duplicate comments:
In `@src/markdown_generator.py`:
- Around line 132-138: The one-shot guard _sources_index_generated isn't set
when _generate_sources_index(gedcom) raises, causing repeated expensive retries;
update the block around the call (where parser = getattr(individual, 'gedcom',
None) and _generate_sources_index is invoked) to ensure _sources_index_generated
is set to True regardless of success (e.g., in a finally-like path) so failures
still mark the attempt, while keeping the existing logger.exception('Failed to
generate sources index') on error.
---
Nitpick comments:
In `@tests/test_individual.py`:
- Around line 500-544: Remove the duplicated note-extraction tests in
tests/test_individual.py by deleting the two functions test_get_notes_inline and
test_get_notes_empty (they duplicate TestNotes.test_get_notes_inline and
TestNotes.test_get_notes_empty); ensure no other tests rely on these functions
and run the test suite to confirm coverage remains unchanged.
- Around line 464-473: Replace the list-comprehension-then-index patterns with
next(...) generator expressions to satisfy RUF015: use next((ind for ind in
GedcomParser(...).get_individuals() if ind.get_pointer() == "@I1@")) instead of
[ind for ind in individuals if ...][0] when selecting the parent, and use
next((f for f in parent_obj.get_families() if f["marriage_place"] == "Place
One")) and next((f for f in parent_obj.get_families() if f["marriage_place"] ==
"Place Two")) for family_one and family_two; keep the same predicates and let
the assertion behavior remain the same (no default needed since a match is
expected).
```
</details>
<details>
<summary>🪄 Autofix (Beta)</summary>
Fix all unresolved CodeRabbit comments on this PR:
- [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)
- [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes
</details>
---
<details>
<summary>ℹ️ Review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
**Configuration used**: defaults
**Review profile**: CHILL
**Plan**: Pro
**Run ID**: `1e70e519-cfc6-4cd8-be6e-f20b5c86e34c`
</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between 6259bfffd6253846b705b0be6660e9bcdfdcb9bd and 676b4014ca9302ae08127c1cfddac86db0f8f35e.
</details>
<details>
<summary>📒 Files selected for processing (6)</summary>
* `src/individual.py`
* `src/markdown_generator.py`
* `tests/conftest.py`
* `tests/test_individual.py`
* `tests/test_markdown_generator.py`
* `tests/test_notes_cont_conc.py`
</details>
<details>
<summary>✅ Files skipped from review due to trivial changes (1)</summary>
* tests/conftest.py
</details>
<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>
* tests/test_notes_cont_conc.py
</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
resolve_gedcom_text() already returns "" for unresolved pointer-style notes, but this guard also discards legitimate inline note text like @username contributed this.
🛠️ Proposed fix
raw = child.get_value() or ""
text = self._resolve_gedcom_text(raw, child)
- if text and not text.startswith("@"):
+ if text:
notes.append(self._collapse_preserve_lines(text))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/individual.py` around lines 596 - 599, The current guard `if text and not
text.startswith("@")` incorrectly drops valid inline notes beginning with "@";
instead rely on _resolve_gedcom_text to return an empty string for unresolved
pointer-style notes and only skip when text is falsy. Update the block that uses
self._resolve_gedcom_text(child.get_value()) so that when text is truthy you
always append self._collapse_preserve_lines(text) to notes (remove the
startswith("@") check); keep using _resolve_gedcom_text and
_collapse_preserve_lines as before.
_⚠️ Potential issue_ | _🟡 Minor_
**Do not drop valid inline notes that start with `@`.**
`resolve_gedcom_text()` already returns `""` for unresolved pointer-style notes, but this guard also discards legitimate inline note text like `@username contributed this`.
<details>
<summary>🛠️ Proposed fix</summary>
```diff
raw = child.get_value() or ""
text = self._resolve_gedcom_text(raw, child)
- if text and not text.startswith("@"):
+ if text:
notes.append(self._collapse_preserve_lines(text))
```
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/individual.py` around lines 596 - 599, The current guard `if text and not
text.startswith("@")` incorrectly drops valid inline notes beginning with "@";
instead rely on _resolve_gedcom_text to return an empty string for unresolved
pointer-style notes and only skip when text is falsy. Update the block that uses
self._resolve_gedcom_text(child.get_value()) so that when text is truthy you
always append self._collapse_preserve_lines(text) to notes (remove the
startswith("@") check); keep using _resolve_gedcom_text and
_collapse_preserve_lines as before.
```
</details>
<!-- fingerprinting:phantom:medusa:ibis -->
<!-- This is an auto-generated comment by CodeRabbit -->
Verify each finding against the current code and only fix it if needed.
In `@src/individual.py` around lines 645 - 648, The current block that handles tag
== "NOTE" overwrites previous notes (raw_note/note_text) and thus loses earlier
source notes; change the logic in src/individual.py inside the tag == "NOTE"
branch to append each resolved note_text (from _resolve_gedcom_text(raw_note,
sc)) to a notes collection on the source (e.g., source.notes or sc.notes)
instead of assigning a single string, ensuring you initialize that collection
(empty list) if not present and use .append(...) for each NOTE encountered so
multiple NOTE children are preserved.
_⚠️ Potential issue_ | _🟡 Minor_
**Preserve multiple source `NOTE` children.**
This assignment keeps only the last `NOTE` under a source, so earlier source notes are lost from person pages.
<details>
<summary>🛠️ Proposed fix</summary>
```diff
title = ""
publ = ""
- note_text = ""
+ note_parts = []
@@
elif tag == "NOTE":
raw_note = sc.get_value() or ""
- note_text = self._resolve_gedcom_text(raw_note, sc)
+ resolved_note = self._resolve_gedcom_text(raw_note, sc)
+ if resolved_note:
+ note_parts.append(resolved_note)
@@
- note_text = self._collapse_preserve_lines(note_text)
+ note_text = self._collapse_preserve_lines("\n".join(note_parts))
```
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/individual.py` around lines 645 - 648, The current block that handles tag
== "NOTE" overwrites previous notes (raw_note/note_text) and thus loses earlier
source notes; change the logic in src/individual.py inside the tag == "NOTE"
branch to append each resolved note_text (from _resolve_gedcom_text(raw_note,
sc)) to a notes collection on the source (e.g., source.notes or sc.notes)
instead of assigning a single string, ensuring you initialize that collection
(empty list) if not present and use .append(...) for each NOTE encountered so
multiple NOTE children are preserved.
```
</details>
<!-- fingerprinting:phantom:medusa:ibis -->
<!-- This is an auto-generated comment by CodeRabbit -->
#!/bin/bash
# Expect: no S110/BLE001 diagnostics for the empty-index cleanup block.
ruff check src/markdown_generator.py --select S110,BLE001
Repository: AlexKucera/gedcom-to-markdown
Length of output: 1071
🏁 Script executed:
#!/bin/bash
# Check for logger imports and setup in the file
head -50 src/markdown_generator.py | grep -E "^import|^from|logger"
Repository: AlexKucera/gedcom-to-markdown
Length of output: 270
🏁 Script executed:
#!/bin/bash
# Verify the fix by showing the surrounding context and creating a test
cat -n src/markdown_generator.py | sed -n '655,665p'
Repository: AlexKucera/gedcom-to-markdown
Length of output: 539
🏁 Script executed:
#!/bin/bash
# Create a test to verify the proposed fix resolves both diagnostics
cat > /tmp/test_fix.py << 'EOF'
import logging
from pathlib import Path
logger = logging.getLogger(__name__)
# Original code - should trigger S110 and BLE001
def original():
index_file = Path("test.md")
if index_file.exists():
try:
index_file.unlink()
except Exception:
pass
# Proposed fix - should not trigger either diagnostic
def proposed():
index_file = Path("test.md")
if index_file.exists():
try:
index_file.unlink()
except OSError:
logger.exception("Failed to remove empty sources index: %s", index_file)
EOF# Run ruff on the test file to verify the fix
ruff check /tmp/test_fix.py --select S110,BLE001
Repository: AlexKucera/gedcom-to-markdown
Length of output: 956
🏁 Script executed:
#!/bin/bash
# Verify the proposed fix directly by extracting just that section
cat > /tmp/test_fix_only.py << 'EOF'
import logging
from pathlib import Path
logger = logging.getLogger(__name__)
def fixed():
index_file = Path("test.md")
if index_file.exists():
try:
index_file.unlink()
except OSError:
logger.exception("Failed to remove empty sources index: %s", index_file)
EOF
ruff check /tmp/test_fix_only.py --select S110,BLE001
Repository: AlexKucera/gedcom-to-markdown
Length of output: 91
Log cleanup failures instead of swallowing them.
If removing the empty sources/Index.md fails, the stale file remains and the cause is hidden. The current code triggers both Ruff S110 (try-except-pass without logging) and BLE001 (blind exception catch) diagnostics.
🛠️ Proposed fix
if not written_any and index_file.exists():
try:
index_file.unlink()
- except Exception:
- pass
+ except OSError:
+ logger.exception("Failed to remove empty sources index: %s", index_file)
Catch OSError instead of the overly broad Exception, and log the failure using the available logger.
📝 Committable suggestion
‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# If nothing was actually written, remove the empty index file
if not written_any and index_file.exists():
try:
index_file.unlink()
except OSError:
logger.exception("Failed to remove empty sources index: %s", index_file)
🧰 Tools🪛 Ruff (0.15.10)
[error] 661-662: try-except-pass detected, consider logging the exception
(S110)
[warning] 661-661: Do not catch blind exception: Exception
(BLE001)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 657 - 662, The empty-index cleanup
currently swallows all exceptions (try/except/pass) when calling
index_file.unlink(), which hides failures and triggers lint warnings; change the
handler to catch OSError only and log the error via the available logger (e.g.,
call logger.error or self.logger.error) including context that unlinking
index_file failed and the exception details, so replace the bare except with
"except OSError as e" and a logger.error(...) call referencing index_file and e
while leaving the rest of the logic intact (symbols: index_file, written_any).
_⚠️ Potential issue_ | _🟡 Minor_
<details>
<summary>🧩 Analysis chain</summary>
🏁 Script executed:
```shell
#!/bin/bash
# Expect: no S110/BLE001 diagnostics for the empty-index cleanup block.
ruff check src/markdown_generator.py --select S110,BLE001
```
Repository: AlexKucera/gedcom-to-markdown
Length of output: 1071
---
🏁 Script executed:
```shell
#!/bin/bash
# Check for logger imports and setup in the file
head -50 src/markdown_generator.py | grep -E "^import|^from|logger"
```
Repository: AlexKucera/gedcom-to-markdown
Length of output: 270
---
🏁 Script executed:
```shell
#!/bin/bash
# Verify the fix by showing the surrounding context and creating a test
cat -n src/markdown_generator.py | sed -n '655,665p'
```
Repository: AlexKucera/gedcom-to-markdown
Length of output: 539
---
🏁 Script executed:
```shell
#!/bin/bash
# Create a test to verify the proposed fix resolves both diagnostics
cat > /tmp/test_fix.py << 'EOF'
import logging
from pathlib import Path
logger = logging.getLogger(__name__)
# Original code - should trigger S110 and BLE001
def original():
index_file = Path("test.md")
if index_file.exists():
try:
index_file.unlink()
except Exception:
pass
# Proposed fix - should not trigger either diagnostic
def proposed():
index_file = Path("test.md")
if index_file.exists():
try:
index_file.unlink()
except OSError:
logger.exception("Failed to remove empty sources index: %s", index_file)
EOF
# Run ruff on the test file to verify the fix
ruff check /tmp/test_fix.py --select S110,BLE001
```
Repository: AlexKucera/gedcom-to-markdown
Length of output: 956
---
🏁 Script executed:
```shell
#!/bin/bash
# Verify the proposed fix directly by extracting just that section
cat > /tmp/test_fix_only.py << 'EOF'
import logging
from pathlib import Path
logger = logging.getLogger(__name__)
def fixed():
index_file = Path("test.md")
if index_file.exists():
try:
index_file.unlink()
except OSError:
logger.exception("Failed to remove empty sources index: %s", index_file)
EOF
ruff check /tmp/test_fix_only.py --select S110,BLE001
```
Repository: AlexKucera/gedcom-to-markdown
Length of output: 91
---
</details>
**Log cleanup failures instead of swallowing them.**
If removing the empty `sources/Index.md` fails, the stale file remains and the cause is hidden. The current code triggers both Ruff S110 (try-except-pass without logging) and BLE001 (blind exception catch) diagnostics.
<details>
<summary>🛠️ Proposed fix</summary>
```diff
if not written_any and index_file.exists():
try:
index_file.unlink()
- except Exception:
- pass
+ except OSError:
+ logger.exception("Failed to remove empty sources index: %s", index_file)
```
</details>
Catch `OSError` instead of the overly broad `Exception`, and log the failure using the available logger.
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
```suggestion
# If nothing was actually written, remove the empty index file
if not written_any and index_file.exists():
try:
index_file.unlink()
except OSError:
logger.exception("Failed to remove empty sources index: %s", index_file)
```
</details>
<!-- suggestion_end -->
<details>
<summary>🧰 Tools</summary>
<details>
<summary>🪛 Ruff (0.15.10)</summary>
[error] 661-662: `try`-`except`-`pass` detected, consider logging the exception
(S110)
---
[warning] 661-661: Do not catch blind exception: `Exception`
(BLE001)
</details>
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 657 - 662, The empty-index cleanup
currently swallows all exceptions (try/except/pass) when calling
index_file.unlink(), which hides failures and triggers lint warnings; change the
handler to catch OSError only and log the error via the available logger (e.g.,
call logger.error or self.logger.error) including context that unlinking
index_file failed and the exception details, so replace the bare except with
"except OSError as e" and a logger.error(...) call referencing index_file and e
while leaving the rest of the logic intact (symbols: index_file, written_any).
```
</details>
<!-- fingerprinting:phantom:medusa:ibis -->
<!-- This is an auto-generated comment by CodeRabbit -->
Preserve multiple NOTE children on a source record.
This overwrites note_text for each NOTE, so only the last source note appears in sources/Index.md. Accumulate resolved notes instead.
🛠️ Proposed fix
title = ""
publ = ""
- note_text = ""
+ note_parts = []
@@
elif tag == "NOTE":
note_val = sc.get_value() or ""
# Use shared resolver to handle pointer vs inline NOTE with CONT/CONC semantics
- note_text = resolve_gedcom_text(parser, note_val, sc)
+ resolved_note = resolve_gedcom_text(parser, note_val, sc)
+ if resolved_note:
+ note_parts.append(resolved_note)
title = self._collapse_single_line(title)
publ = self._collapse_single_line(publ)
+ note_text = "\n".join(note_parts)
note_text = self._collapse_preserve_lines(note_text)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 635 - 638, The NOTE handler currently
overwrites note_text for each NOTE child; change it to accumulate resolved notes
instead: when tag == "NOTE" (inside the source-record parsing loop), call
resolve_gedcom_text(parser, note_val, sc) as before but append the result to a
collected list or concatenate into an existing accumulator (e.g., note_texts or
note_text += "\n\n" + resolved) rather than assigning to note_text; ensure
downstream code that emits sources/Index.md consumes the accumulated notes (join
the list or use the accumulator) so all NOTE children are preserved.
_⚠️ Potential issue_ | _🟡 Minor_
**Preserve multiple `NOTE` children on a source record.**
This overwrites `note_text` for each `NOTE`, so only the last source note appears in `sources/Index.md`. Accumulate resolved notes instead.
<details>
<summary>🛠️ Proposed fix</summary>
```diff
title = ""
publ = ""
- note_text = ""
+ note_parts = []
@@
elif tag == "NOTE":
note_val = sc.get_value() or ""
# Use shared resolver to handle pointer vs inline NOTE with CONT/CONC semantics
- note_text = resolve_gedcom_text(parser, note_val, sc)
+ resolved_note = resolve_gedcom_text(parser, note_val, sc)
+ if resolved_note:
+ note_parts.append(resolved_note)
title = self._collapse_single_line(title)
publ = self._collapse_single_line(publ)
+ note_text = "\n".join(note_parts)
note_text = self._collapse_preserve_lines(note_text)
```
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 635 - 638, The NOTE handler currently
overwrites note_text for each NOTE child; change it to accumulate resolved notes
instead: when tag == "NOTE" (inside the source-record parsing loop), call
resolve_gedcom_text(parser, note_val, sc) as before but append the result to a
collected list or concatenate into an existing accumulator (e.g., note_texts or
note_text += "\n\n" + resolved) rather than assigning to note_text; ensure
downstream code that emits sources/Index.md consumes the accumulated notes (join
the list or use the accumulator) so all NOTE children are preserved.
```
</details>
<!-- fingerprinting:phantom:medusa:ibis -->
<!-- This is an auto-generated comment by CodeRabbit -->
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
I added a feature to add sources to people pages when GEDCOM includes them.
I have a GEDCOM file with several hundred thousand sources. Because of this, there are some weird formatting issues I ran into that I attempted to address with this PR. New tests are written and all tests pass.
Summary by CodeRabbit
New Features
Improvements
Tests
📝 Walkthrough
Walkthrough
Adds GEDCOM text-normalization helpers, coordinate extraction, source and FSID accessors to
Individual, and enhances markdown generation to render per-individual Sources and a global sources index. Tests added/updated to validate CONT/CONC handling, source rendering, coordinates, and FSFTID exposure.Changes
src/individual.pycollapse_single_line,resolve_gedcom_text, and constantEVENT_TAGS. New/updated methods:_collapse_preserve_lines,_resolve_gedcom_text,_get_event_info,_extract_date_place_and_coords,_get_obje_info,get_fs_id,get_sources. Refactored event/date/place extraction to populatelat/longfor birth/death/events andmarriage_lat/marriage_longfor families. Reworked note resolution to follow pointers and properly handleCONT/CONC.src/markdown_generator.py_sources_index_generatedguard, new helpers (_coordinate_values,_collapse_preserve_lines,_format_source_entry,_generate_sources_index,_write_sources,_escape_markdown,_repair_broken_html_tags,_write_multiline_note_block). Now writes per-individual## Sources, emits coordinates for events/families, and generates globalsources/Index.mdonce. Improved inline-note rendering and HTML repair.tests/test_notes_cont_conc.py,tests/test_sources.pyget_sources()outputs normalizedTITL/PUBL/NOTE, that sources index is generated, and URL/title rendering behavior.tests/test_individual.py,tests/test_markdown_generator.py,tests/conftest.pyget_fs_id(), multiple event/coordinate extraction scenarios, family marriage coordinate isolation, updated note tests, and frontmatter to include FamilySearch ID. Added_FSFTIDto sample fixture.Sequence Diagram
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
src/individual.pyimplementation and introduces helpers, event/coordinate extraction, and source/FSID-related changes similar to this PR.Poem
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands and usage tips.Pull request overview
Adds end-to-end support for parsing GEDCOM sources/notes (including
CONT/CONCsemantics) and rendering them into generated person Markdown, plus generating a global sources index.Changes:
Individual.get_sources()and update note parsing to respectCONTvsCONC.MarkdownGeneratorto render a “Sources” section per person and generate a globalsources/Index.mdonce.CONT/CONChandling (notes + source notes/index).Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
tests/test_sources.pytests/test_notes_cont_conc.pyCONT/CONChandling in notes and source notes (but currently has import-path issues).src/markdown_generator.pysrc/individual.pyget_sources()and refactors note resolution to properly handleCONT/CONC.💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@@ -256,4 +366,1 @@parent_elements = self.gedcom.get_parents(self.element)# Get all family recordsfor family in self.gedcom.get_root_child_elements():Pointer detection for
SOUR @X@should match the stricter pattern used elsewhere (startswith('@') and endswith('@')). Using onlystartswith('@')can misclassify inline values that happen to begin with '@', and can lead to failed lookups in the element dictionary.@@ -415,3 +465,3 @@# Write regular notesfor note in notes:f.write(f"{note}\n\n")# Repair broken HTML tags that may span lines, then split into linesThe docstring says the source NOTE text is “formatted in italic”, but the implementation escapes emphasis characters and writes plain text (no italics). Either update the docstring to reflect actual behavior, or implement the intended italic formatting in a way that won’t conflict with markdown escaping.
In the non-nested branch, the “last non-empty line” is detected by comparing string values (
ln == last_non_empty). If the same text appears earlier inlines, earlier occurrences will be treated as the last line and won’t get the intended trailing spaces/hard-break behavior. Track the last non-empty index instead (or iterate with indices) to make this deterministic._generate_sources_indexaccumulates every source (including full note text) into an in-memorysourceslist before writing. With “several hundred thousand sources”, this can become a large memory spike and/or slow GC. Consider streaming directly toIndex.mdas you scanelem_dict(write each entry immediately) so memory usage stays bounded.@@ -0,0 +1,109 @@from pathlib import PathThese imports are inconsistent with the repo’s pytest configuration (
pythonpath = src). Withsrc/added directly tosys.pathand nosrc/__init__.py,from src.gedcom_parser ...will fail (it will look forsrc/src/gedcom_parser.py). Import the modules the same way other tests do (e.g.,from gedcom_parser import GedcomParser, etc.).Actionable comments posted: 4
🧹 Nitpick comments (3)
🤖 Prompt for all review comments with AI agents
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
334159b2-5e63-40cb-81ca-b084e6e3ae0b📥 Commits
Reviewing files that changed from the base of the PR and between
48e339c119and6259bfffd6.📒 Files selected for processing (4)
src/individual.pysrc/markdown_generator.pytests/test_notes_cont_conc.pytests/test_sources.py@@ -469,3 +808,4 @@Parameters:f: A writable file-like object to which the metadata line will be written.key (str): Metadata key.⚠️ Potential issue | 🟠 Major
Major:
_sources_index_generatedflag is not set on early returns — reintroduces the very O(N·S) behavior this PR targets.The flag is only set at the very end (line 615). Both early exits — the outer
except Exception: returnat 531-532 and theif not sources: returnat 586-587 — leave the flagFalse, so every subsequentgenerate_note()call will call_generate_sources_indexagain and re-scan the full element dictionary. For a GEDCOM with noSOURrecords and hundreds of thousands of individuals, this undoes the one-shot guard completely.🛠️ Proposed fix
🧰 Tools
🪛 Ruff (0.15.10)
[warning] 531-531: Do not catch blind exception:
Exception(BLE001)
[error] 539-540:
try-except-continuedetected, consider logging the exception(S112)
[warning] 539-539: Do not catch blind exception:
Exception(BLE001)
🤖 Prompt for AI Agents
✅ Addressed in commit
96da61c⚠️ Potential issue | 🟡 Minor
Minor bug: duplicate lines lose their hard break in the non-nested branch.
last_non_empty = non_empty[-1]is compared by value, so if the note contains two identical non-empty lines, both matchln == last_non_emptyand both are written without the trailing two spaces — collapsing the intended hard break between them. Use the last index (or iterate withenumerateand track the index of the last non-empty entry) instead.🛠️ Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit
96da61c@@ -0,0 +1,109 @@from pathlib import Path⚠️ Potential issue | 🟡 Minor
Test name doesn't match what it exercises.
test_note_cont_and_conc_inlinedeclares an inlineNOTE@N1@pointer on@I1@, which routes through the pointer-resolution branch of_resolve_gedcom_text— the same branch thattest_note_reference_to_note_with_cont_conccovers. There is currently no coverage for the inline branch (CONT/CONC as direct children of an INDI-level1 NOTE <text>). Consider either renaming this test or adding a case like:to exercise the
element is not Nonepath in_resolve_gedcom_text.🤖 Prompt for AI Agents
✅ Addressed in commit
96da61c@@ -0,0 +2,4 @@from gedcom_parser import GedcomParserfrom individual import Individualfrom markdown_generator import MarkdownGenerator⚠️ Potential issue | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
Repository: AlexKucera/gedcom-to-markdown
Length of output: 4661
🏁 Script executed:
Repository: AlexKucera/gedcom-to-markdown
Length of output: 318
Fix import paths to match pytest configuration.
The
pytest.inifile configurespythonpath = src, which adds thesrc/directory tosys.path. This means imports should use the stylefrom gedcom_parser import ...(without thesrc.prefix).The file
test_notes_cont_conc.pycurrently importsfrom src.gedcom_parser import ..., which contradicts the pytest configuration and differs from the other five test files (test_sources.py,test_individual.py,test_index_generator.py,test_markdown_generator.py,test_gedcom_parser.py) which all use the correct non-prefixed style.Update
test_notes_cont_conc.pyto remove thesrc.prefix from its imports to align with the pytest configuration and the rest of the test suite.🤖 Prompt for AI Agents
Actionable comments posted: 4
♻️ Duplicate comments (1)
🧹 Nitpick comments (2)
🤖 Prompt for all review comments with AI agents
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
1e70e519-cfc6-4cd8-be6e-f20b5c86e34c📥 Commits
Reviewing files that changed from the base of the PR and between
6259bfffd6and676b4014ca.📒 Files selected for processing (6)
src/individual.pysrc/markdown_generator.pytests/conftest.pytests/test_individual.pytests/test_markdown_generator.pytests/test_notes_cont_conc.py✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⚠️ Potential issue | 🟡 Minor
Do not drop valid inline notes that start with
@.resolve_gedcom_text()already returns""for unresolved pointer-style notes, but this guard also discards legitimate inline note text like@username contributed this.🛠️ Proposed fix
🤖 Prompt for AI Agents
⚠️ Potential issue | 🟡 Minor
Preserve multiple source
NOTEchildren.This assignment keeps only the last
NOTEunder a source, so earlier source notes are lost from person pages.🛠️ Proposed fix
🤖 Prompt for AI Agents
⚠️ Potential issue | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
Repository: AlexKucera/gedcom-to-markdown
Length of output: 1071
🏁 Script executed:
Repository: AlexKucera/gedcom-to-markdown
Length of output: 270
🏁 Script executed:
Repository: AlexKucera/gedcom-to-markdown
Length of output: 539
🏁 Script executed:
Repository: AlexKucera/gedcom-to-markdown
Length of output: 956
🏁 Script executed:
Repository: AlexKucera/gedcom-to-markdown
Length of output: 91
Log cleanup failures instead of swallowing them.
If removing the empty
sources/Index.mdfails, the stale file remains and the cause is hidden. The current code triggers both Ruff S110 (try-except-pass without logging) and BLE001 (blind exception catch) diagnostics.🛠️ Proposed fix
Catch
OSErrorinstead of the overly broadException, and log the failure using the available logger.📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.15.10)
[error] 661-662:
try-except-passdetected, consider logging the exception(S110)
[warning] 661-661: Do not catch blind exception:
Exception(BLE001)
🤖 Prompt for AI Agents
⚠️ Potential issue | 🟡 Minor
Preserve multiple
NOTEchildren on a source record.This overwrites
note_textfor eachNOTE, so only the last source note appears insources/Index.md. Accumulate resolved notes instead.🛠️ Proposed fix
🤖 Prompt for AI Agents
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.