Initializes GEDCOM to Markdown converter project #1
No files matched your search
@@ -65,7 +65,9 @@ src/
|
|||||||
- Python 3.7+
|
- Python 3.7+
|
||||||
- python-gedcom==1.0.0
|
- python-gedcom==1.0.0
|
||||||
|
|
||||||
## Line Ending Issue
|
## Common Issues
|
||||||
|
|
||||||
|
### Line Ending Issue
|
||||||
|
|
||||||
**Important**: Some GEDCOM files exported from macOS applications may use old Mac-style line endings (CR only). If the parser finds 0 individuals, convert line endings first:
|
**Important**: Some GEDCOM files exported from macOS applications may use old Mac-style line endings (CR only). If the parser finds 0 individuals, convert line endings first:
|
||||||
|
|
||||||
@@ -77,3 +79,11 @@ with open('file.ged', 'wb') as f:
|
|||||||
f.write(content.replace(b'\r', b'\n'))
|
f.write(content.replace(b'\r', b'\n'))
|
||||||
"
|
"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### GEDCOM Version Compatibility
|
||||||
|
|
||||||
|
This tool works best with **GEDCOM version 5.5.x or 5.x**. If you're using GEDCOM 7.0+, you may encounter issues with custom tags and story extraction. When exporting from your genealogy software:
|
||||||
|
|
||||||
|
1. Choose GEDCOM version 5.5.1 or 5.1.0 if available
|
||||||
|
2. Avoid GEDCOM version 7.0+ for better compatibility
|
||||||
|
3. After export, check and fix line endings if needed (see above)
|
||||||
+42
-16
@@ -307,7 +307,7 @@ class Individual:
|
|||||||
|
|
||||||
return notes
|
return notes
|
||||||
|
|
||||||
def get_stories(self) -> List[Dict[str, str]]:
|
def get_stories(self) -> List[Dict]:
|
||||||
"""
|
"""
|
||||||
Get stories/narratives for this person.
|
Get stories/narratives for this person.
|
||||||
|
|
||||||
@@ -315,7 +315,8 @@ class Individual:
|
|||||||
tags for storing longer narratives and stories about individuals.
|
tags for storing longer narratives and stories about individuals.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
List of dictionaries with 'title' and 'text' keys
|
List of dictionaries with 'title', 'sections' keys
|
||||||
|
Each section has 'subtitle', 'text', 'images'
|
||||||
"""
|
"""
|
||||||
stories = []
|
stories = []
|
||||||
|
|
||||||
@@ -331,24 +332,49 @@ class Individual:
|
|||||||
if story_element:
|
if story_element:
|
||||||
story = {
|
story = {
|
||||||
'title': '',
|
'title': '',
|
||||||
'text': ''
|
'description': '',
|
||||||
|
'sections': []
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get title and text sections
|
# Get main title and metadata
|
||||||
for section in story_element.get_child_elements():
|
for section in story_element.get_child_elements():
|
||||||
if section.get_tag() == 'TITL':
|
tag = section.get_tag()
|
||||||
story['title'] = section.get_value() or ''
|
|
||||||
elif section.get_tag() in ['_STS', 'TEXT']:
|
|
||||||
# Get text content
|
|
||||||
for text_part in section.get_child_elements():
|
|
||||||
if text_part.get_tag() == 'TEXT':
|
|
||||||
story['text'] = text_part.get_value() or ''
|
|
||||||
# Check for CONT lines
|
|
||||||
for cont in text_part.get_child_elements():
|
|
||||||
if cont.get_tag() in ['CONT', 'CONC']:
|
|
||||||
story['text'] += '\n' + (cont.get_value() or '')
|
|
||||||
|
|
||||||
if story['title'] or story['text']:
|
if tag == 'TITL':
|
||||||
|
story['title'] = section.get_value() or ''
|
||||||
|
elif tag == 'DESC':
|
||||||
|
story['description'] = section.get_value() or ''
|
||||||
|
elif tag == '_STS':
|
||||||
|
# Story section with inline content
|
||||||
|
# Format: "1 @12375128@ _STS"
|
||||||
|
# Children at level 2 contain TITL, TEXT, OBJE
|
||||||
|
section_data = {
|
||||||
|
'subtitle': '',
|
||||||
|
'text': '',
|
||||||
|
'images': []
|
||||||
|
}
|
||||||
|
|
||||||
|
# Extract content directly from child elements
|
||||||
|
for sts_child in section.get_child_elements():
|
||||||
|
if sts_child.get_tag() == 'TITL':
|
||||||
|
section_data['subtitle'] = sts_child.get_value() or ''
|
||||||
|
elif sts_child.get_tag() == 'TEXT':
|
||||||
|
text = sts_child.get_value() or ''
|
||||||
|
# Get CONT lines
|
||||||
|
for cont in sts_child.get_child_elements():
|
||||||
|
if cont.get_tag() in ['CONT', 'CONC']:
|
||||||
|
text += '\n' + (cont.get_value() or '')
|
||||||
|
section_data['text'] = text
|
||||||
|
elif sts_child.get_tag() == 'OBJE':
|
||||||
|
# Get image reference
|
||||||
|
img_ref = sts_child.get_value()
|
||||||
|
if img_ref:
|
||||||
|
section_data['images'].append(img_ref)
|
||||||
|
|
||||||
|
if section_data['subtitle'] or section_data['text']:
|
||||||
|
story['sections'].append(section_data)
|
||||||
|
|
||||||
|
if story['title'] or story['sections']:
|
||||||
stories.append(story)
|
stories.append(story)
|
||||||
|
|
||||||
return stories
|
return stories
|
||||||
|
|||||||
@@ -257,13 +257,26 @@ class MarkdownGenerator:
|
|||||||
for note in notes:
|
for note in notes:
|
||||||
f.write(f"{note}\n\n")
|
f.write(f"{note}\n\n")
|
||||||
|
|
||||||
# Write stories with titles
|
# Write stories with their sections
|
||||||
for story in stories:
|
for story in stories:
|
||||||
if story['title']:
|
if story['title']:
|
||||||
f.write(f"### {story['title']}\n\n")
|
f.write(f"### {story['title']}\n\n")
|
||||||
|
|
||||||
if story['text']:
|
if story['description']:
|
||||||
f.write(f"{story['text']}\n\n")
|
f.write(f"*{story['description']}*\n\n")
|
||||||
|
|
||||||
|
# Write each section
|
||||||
|
for section in story['sections']:
|
||||||
|
if section['subtitle']:
|
||||||
|
f.write(f"#### {section['subtitle']}\n\n")
|
||||||
|
|
||||||
|
if section['text']:
|
||||||
|
f.write(f"{section['text']}\n\n")
|
||||||
|
|
||||||
|
# Write images for this section
|
||||||
|
if section['images']:
|
||||||
|
for img in section['images']:
|
||||||
|
f.write(f"\n\n")
|
||||||
|
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user