diff --git a/README.md b/README.md new file mode 100644 index 0000000..3435e50 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +HTML classes / used elements: +p.light (light font) +p (default) +p.strong (bold font) +p.heavy (very bold font) +p.comment (italic font, gray) + +pre.terminal (dark background, light green, strictly limited to 80 characters width) +pre.paper (alternating yellow-ish white and light green lines, black, if posible with a typewriter look) + +span.comment (italic font, gray) +li.comment (...) + +h1 (full width, centered, horizontal line below, space below) +ul (use small dots or dashes) + +use different sets of quotes or formatting depending on whether the quoted text is literal speech diff --git a/md2htmlbody.py b/md2htmlbody.py new file mode 100755 index 0000000..59fd13e --- /dev/null +++ b/md2htmlbody.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import sys, os + + +def htmlencode(string): + outstring = "" + for char in string: + if char in ["<", ">", "'", "ā€™", "\"", "&"]: + replacements = { + "<": "<", + ">": ">", + "'": "'", + "ā€™": "'", + "\"": """, + "&": "&" + } + outstring = outstring + replacements[char] + elif ord(char)>127: + outstring = outstring + "&#" + str(ord(char)) + ";" + else: + outstring = outstring + char + return outstring + + +if len(sys.argv)<3: + print("Usage: " + sys.argv[0] + " ") + sys.exit(1) + +if not os.path.isfile(sys.argv[1]): + print("Not a file: " + sys.argv[1]) + sys.exit(2) + +if os.path.isfile(sys.argv[2]): + print("File exists: " + sys.argv[2]) + print("Refusing to operate.") + sys.exit(2) + +source_file = open(sys.argv[1], "r", encoding="utf-8") +destination_file = open(sys.argv[2], "w", encoding="ascii") + +element_type="" +next_source_line = source_file.readline() +while not next_source_line=="": + if next_source_line == "\n": + #TODO: use appropriate end action based on element type + #TODO: deal with closing nested elements + destination_file.write("\n") + element_type="" + next_source_line = source_file.readline() + continue + + if element_type=="": + #TODO: determine appropriate element type + element_type="p" + destination_file.write("<"+element_type+">\n") + + #TODO: deal with multiple spaces appropriately + destination_file.write(" " + htmlencode(next_source_line)) + + next_source_line = source_file.readline() + + if next_source_line=="" and not element_type=="": + #TODO: deal with closing nested elements + destination_file.write("\n") diff --git a/template.html b/template.html new file mode 100644 index 0000000..6bca51d --- /dev/null +++ b/template.html @@ -0,0 +1,62 @@ + + + Layout Test + + + +

Layout Test Page

+

+ This is a test page used for deeloping the stylesheet used for all + the chapters once they have been converted to HTML. +

+

+ Here is some light text. +

+

+ More normal text to fill up the page... +

+

+ Here is some strong text. +

+

+ It should have a slightly higher font weight than normal - ever so + slightly less than bold. +

+

+ Here is some heavy text. +

+

+ It should have a significantly higher font weight than normal - ever + so slightly more than bold. +

+

+ This is a comment paragraph. +

+

+ There are also inline comments . +

+ +

+ Here are two types of pre-formatted text: +

+
+This is text on a terminal.
+Hello World!
+    
+
+This is text printed to tractor feed paper.
+Hello World!
+Do you see them alternating lines?
+Fancy, right?
+I have no idea how Iā€™m gonna actually build this but imagine alternating
+lines on the paper.
+    
+ +