summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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: