Handle encoding better on output
This commit is contained in:
parent
214830583f
commit
98fce00720
@ -5,6 +5,7 @@
|
|||||||
import sys # For argv and stderr
|
import sys # For argv and stderr
|
||||||
import os # For reading directories
|
import os # For reading directories
|
||||||
import re # For parsing lex content
|
import re # For parsing lex content
|
||||||
|
import io # For writing pages out as UTF-8
|
||||||
import networkx # For pagerank analytics
|
import networkx # For pagerank analytics
|
||||||
from collections import defaultdict # For rank inversion in statistics
|
from collections import defaultdict # For rank inversion in statistics
|
||||||
|
|
||||||
@ -511,7 +512,7 @@ def command_build(argv):
|
|||||||
print("Writing written articles...")
|
print("Writing written articles...")
|
||||||
for lex in lexes:
|
for lex in lexes:
|
||||||
page = build_article_page(lex, cite_map, config)
|
page = build_article_page(lex, cite_map, config)
|
||||||
with open("out/" + lex["filename"] + ".html", "w") as f:
|
with io.open("out/" + lex["filename"] + ".html", "w", encoding="utf8") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote " + lex["title"])
|
print(" Wrote " + lex["title"])
|
||||||
# Write the unwritten entries
|
# Write the unwritten entries
|
||||||
@ -520,14 +521,14 @@ def command_build(argv):
|
|||||||
print("Writing phantom articles...")
|
print("Writing phantom articles...")
|
||||||
for title in phantom_entries:
|
for title in phantom_entries:
|
||||||
page = build_phantom_page(title, cite_map, config)
|
page = build_phantom_page(title, cite_map, config)
|
||||||
with open("out/" + as_filename(title) + ".html", "w") as f:
|
with io.open("out/" + as_filename(title) + ".html", "w") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote " + title)
|
print(" Wrote " + title)
|
||||||
elif argv[2] == "full":
|
elif argv[2] == "full":
|
||||||
print("Writing stub articles...")
|
print("Writing stub articles...")
|
||||||
for title in phantom_entries:
|
for title in phantom_entries:
|
||||||
page = build_stub_page(title, cite_map, config)
|
page = build_stub_page(title, cite_map, config)
|
||||||
with open("out/" + as_filename(title) + ".html", "w") as f:
|
with io.open("out/" + as_filename(title) + ".html", "w") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote " + title)
|
print(" Wrote " + title)
|
||||||
else:
|
else:
|
||||||
@ -536,23 +537,23 @@ def command_build(argv):
|
|||||||
# Write the default pages
|
# Write the default pages
|
||||||
print("Writing default pages")
|
print("Writing default pages")
|
||||||
page = build_rules_page(config)
|
page = build_rules_page(config)
|
||||||
with open("out/rules.html", "w") as f:
|
with io.open("out/rules.html", "w") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote Rules")
|
print(" Wrote Rules")
|
||||||
page = build_formatting_page(config)
|
page = build_formatting_page(config)
|
||||||
with open("out/formatting.html", "w") as f:
|
with io.open("out/formatting.html", "w") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote Formatting")
|
print(" Wrote Formatting")
|
||||||
page = build_index_page(cite_map, config)
|
page = build_index_page(cite_map, config)
|
||||||
with open("out/index.html", "w") as f:
|
with io.open("out/index.html", "w") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote Index")
|
print(" Wrote Index")
|
||||||
page = build_session_page(config)
|
page = build_session_page(config)
|
||||||
with open("out/session.html", "w") as f:
|
with io.open("out/session.html", "w") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote Session")
|
print(" Wrote Session")
|
||||||
page = build_statistics_page(cite_map, config)
|
page = build_statistics_page(cite_map, config)
|
||||||
with open("out/stats.html", "w") as f:
|
with io.open("out/stats.html", "w") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote Statistics")
|
print(" Wrote Statistics")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user