gemini.git

going-flying.com gemini git repository

summary

tree

log

refs

9a33c76686b6538efab9106802a033a34dad6224 - Matthew Ernisse - 1716913666

fix some html to gemtext edge cases

view tree

view raw

diff --git a/files/thoughts-to-gemini.py b/files/thoughts-to-gemini.py
index 83eec41..e130482 100755
--- a/files/thoughts-to-gemini.py
+++ b/files/thoughts-to-gemini.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 # -*- coding: UTF-8 -*-
-'''thoughts-to-gemini.py (c) 2020-2023 Matthew J Ernisse <matt@going-flying.com>
+'''thoughts-to-gemini.py (c) 2020-2024 Matthew J Ernisse <matt@going-flying.com>
 All Rights Reserved.
 
 Redistribution and use in source and binary forms,
@@ -157,6 +157,9 @@ class DeHTMLizer(object):
 
 			return f'«{tag.string}»{sNum!s}'
 
+		elif tag.name == 'br':
+			return '\n'
+
 		elif tag.name == 'del':
 			return f'{tag.string}^W'
 
@@ -177,8 +180,17 @@ class DeHTMLizer(object):
 
 			return buf
 
+		# These are also nestable, sort of?.
 		elif tag.name in ['em', 'strong']:
-			return f'*{tag.string}*'
+			buf = ''
+			if hasattr(tag, 'contents'):
+				for el in tag.contents:
+					buf += self.parseElement(el)
+			else:
+				if tag.string is not None:
+					buf += tag.string
+
+			return f'*{buf}*'
 
 		elif tag.name in noprint:
 			return ''