diff options
| author | uvok | 2025-06-23 19:04:37 +0200 |
|---|---|---|
| committer | uvok | 2025-06-23 19:04:37 +0200 |
| commit | fa059d0d3b1d7b9a0d733d1b36f905d34d713e18 (patch) | |
| tree | 63177c8ec57a7e9517f17c0b0903ce55a71c556a /converters | |
| parent | 75fc6c6bf08c13f17ccb10908911b47e3a8722f5 (diff) | |
gemini: Clarify, keep leading/trailing to a degree
Diffstat (limited to 'converters')
| -rw-r--r-- | converters/md_to_gemini.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/converters/md_to_gemini.py b/converters/md_to_gemini.py index 80ede7b..d7c1596 100644 --- a/converters/md_to_gemini.py +++ b/converters/md_to_gemini.py @@ -4,18 +4,31 @@ import os.path from md2gemini import md2gemini def merge_lines(input_text): - lines = input_text.strip().splitlines() + lines = input_text.splitlines() result = [] - previous_line_was_arrow = False + last_line = None for line in lines: stripped = line.strip() + if stripped == '' or stripped == '*': - if previous_line_was_arrow: - continue + # Tentatively hold this line + last_line = stripped + continue + + if stripped.startswith('=>') and (last_line == '' or last_line == '*'): + # Skip the held line + last_line = None + + if last_line is not None: + result.append(last_line) + last_line = None result.append(line) - previous_line_was_arrow = stripped.startswith('=>') + + # If the last line was held and never flushed + if last_line is not None: + result.append(last_line) return '\n'.join(result) |
