diff --git a/src/build.py b/src/build.py
index 6b5ff43..c5ec9b3 100644
--- a/src/build.py
+++ b/src/build.py
@@ -243,7 +243,39 @@ def build_compiled_page(articles, config):
"""
Builds a page compiling all articles in the Lexicon.
"""
- pass
+ # Sort by turn and title
+ turn_order = sorted(
+ articles,
+ key=lambda a: (a.turn, utils.titlesort(a.title)))
+
+ # Build the content of each article
+ css = utils.load_resource("lexicon.css")
+ css += "\n"\
+ "body { background: #ffffff; }\n"
+ content = "\n"\
+ "
\n"\
+ "{lexicon}\n"\
+ "\n"\
+ "\n"\
+ "{lexicon}
".format(
+ lexicon=config["LEXICON_TITLE"],
+ css=css)
+ for article in turn_order:
+ format_map = {
+ format_id: cite_tuple[0] # TODO
+ for format_id, cite_tuple in article.citations.items()
+ }
+ article_body = article.content.format(**format_map)
+ # Stitch a page-break-avoid div around the header and first paragraph
+ article_body = article_body.replace("", "", 1)
+ article_block = "\n"\
+ "
{}
\n"\
+ "{}\n".format(article.title, article_body)
+ content += article_block
+ content += ""
+ return content
def build_all(path_prefix, lexicon_name):
"""
@@ -314,4 +346,10 @@ def build_all(path_prefix, lexicon_name):
print(" Wrote Session")
with open(pathto("statistics", "index.html"), "w", encoding="utf8") as f:
f.write(build_statistics_page(articles, config))
- print(" Wrote Statistics")
\ No newline at end of file
+ print(" Wrote Statistics")
+
+ # Write auxiliary pages
+ if "PRINTABLE_FILE" in config and config["PRINTABLE_FILE"]:
+ with open(pathto(config["PRINTABLE_FILE"]), "w", encoding="utf-8") as f:
+ f.write(build_compiled_page(articles, config))
+ print(" Wrote compiled page to " + config["PRINTABLE_FILE"])
\ No newline at end of file
diff --git a/src/resources/lexicon.cfg b/src/resources/lexicon.cfg
index 5b16ee7..8f0d826 100644
--- a/src/resources/lexicon.cfg
+++ b/src/resources/lexicon.cfg
@@ -43,3 +43,13 @@ PQRS
TUV
WXYZ
<<
>>GRAPHVIZ_FILE>>>
+<<>>PRINTABLE_FILE>>>
+<<