summaryrefslogtreecommitdiff
path: root/converters/md_to_gemini.py
diff options
context:
space:
mode:
authoruvok2025-06-23 19:28:41 +0200
committeruvok2025-06-23 19:28:41 +0200
commitb36a43b96f6f5fef1112dc9791eb980979fe70b5 (patch)
tree80d1e0606ba8a7bab5824692f109bea5eda7aa27 /converters/md_to_gemini.py
parentfa059d0d3b1d7b9a0d733d1b36f905d34d713e18 (diff)
gemini: Improve strip logic
Diffstat (limited to 'converters/md_to_gemini.py')
-rw-r--r--converters/md_to_gemini.py18
1 files changed, 5 insertions, 13 deletions
diff --git a/converters/md_to_gemini.py b/converters/md_to_gemini.py
index d7c1596..fad3d4f 100644
--- a/converters/md_to_gemini.py
+++ b/converters/md_to_gemini.py
@@ -9,30 +9,22 @@ def merge_lines(input_text):
last_line = None
for line in lines:
- stripped = line.strip()
+ stripped = line.rstrip()
- if stripped == '' or stripped == '*':
- # 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:
+ if (last_line == '' or last_line == '*') and stripped.startswith('=>'):
+ last_line = None # Skip the previous line
if last_line is not None:
result.append(last_line)
- last_line = None
- result.append(line)
+ last_line = stripped
- # If the last line was held and never flushed
if last_line is not None:
result.append(last_line)
return '\n'.join(result)
-
def convert_md_to_gemini():
for file in os.listdir("output/markdown"):
with open("output/markdown/" + str(file), "r") as f: