summaryrefslogtreecommitdiff
path: root/generator
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2018-01-03 04:27:49 -0800
committeriximeow <me@iximeow.net>2018-01-03 04:27:49 -0800
commitb2074b0f9c3f0def3d6d66ef9b91d69bdd6a19ad (patch)
treed79007c8175fb2090eeb0ac6223a9c463c22f91c /generator
parentef04a36884d3dac175577f46d0807e3b4ff4c0f0 (diff)
add pandoc styling, adjust template
template was indented, resulting in weirdness about <pre> content. insert a newline before adding #include'd content try to decode read lines as utf-8 and report error if any do *not* try to decode for output, just let python deal with it (writing unicode strings causes issues because python may try to write multi-byte codepoints by converting to a byte, then throwing due to out of range values)
Diffstat (limited to 'generator')
-rw-r--r--generator/generate.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/generator/generate.py b/generator/generate.py
index 494ad0c..7d64f6e 100644
--- a/generator/generate.py
+++ b/generator/generate.py
@@ -14,7 +14,7 @@ def replace_references(lines, file_dir):
try:
f = open(filepath)
content = f.read()
- result = result + content
+ result = result + '\n' + content
except Exception as err:
print("Error reading file {}:{}".format(filepath, str(err)))
return None
@@ -32,7 +32,11 @@ def replace_references(lines, file_dir):
return None
else:
# just include the line!
- result = result + line
+ try:
+ result = result + line.decode("utf-8")
+ except Exception as e:
+ print("Error processing line {}:\n {}\nError: {}".format(i, line, e))
+ return None
return result
if __name__ == "__main__":
@@ -73,7 +77,7 @@ if __name__ == "__main__":
if not os.path.isdir(dest_wd):
os.makedirs(dest_wd)
out_file = open(compiled_dest, 'w')
- out_file.write(html.decode('utf-8'))
+ out_file.write(html)
out_file.close()
except IOError as ioerr:
print("Unknown error writing result: " + str(ioerr))