gemini.git

going-flying.com gemini git repository

summary

tree

log

refs

f9222fb5dc185a94fa274a706cda900cb0e5547a - Matthew Ernisse - 1595982356

handle all special lines in gemini markup

view tree

view raw

diff --git a/build/build.py b/build/build.py
index 394f91f..356ceaf 100755
--- a/build/build.py
+++ b/build/build.py
@@ -124,18 +124,29 @@ class GeminiTextUnfolder(object):
 				out.append(line)
 				continue
 
-			# Always add blank lines.  If we are in a preformatted
-			# block then don't do anything else but if we aren't
-			# we are unfolding a paragraph and we should stop doing
-			# that now and append the buffer.
-			if line.strip() == '':
-				out.append(line)
-
-				if in_pre:
-					continue
+			# We need to directly handle the following cases
+			# * blank lines
+			# * headings	(#)
+			# * unordered lists	(* )
+			# * quotes		(>)
+			# * links		(=>)
+			if line.strip() == '' or \
+				line.startswith('#') or \
+				line.startswith('* ') or \
+				line.startswith('>') or \
+				line.startswith('=>')::
+
+
+				# If we are not in a preformatte block we need
+				# to append and reset the buffer before we
+				# append the line or else we will flip the
+				# ordering which is not ideal.
+				if not in_pre:
+					out.append(buf.strip())
+					buf = ''
 
-				out.append(buf.strip())
-				buf = ''
+				out.append(line)
+				continue
 
 			if in_pre:
 				out.append(line)