Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions publish.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/python3
import os, sys

HEADER = """

HEADER_START = """
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<link rel="stylesheet" type="text/css" href="/css/common-vendor.b8ecfc406ac0b5f77a26.css">
Expand Down Expand Up @@ -32,12 +34,18 @@

.math { font-family: MJXc-TeX-math-Iw }
</style>
"""

HEADER_END = """
</head>
<body>
<div id="doc" class="container-fluid markdown-body comment-enabled" data-hard-breaks="true">

"""

FOOTER = """ </div> """
FOOTER = """ </div>
</body>
</html> """

TOC_HEADER = """

Expand Down Expand Up @@ -138,8 +146,10 @@ def make_toc_item(metadata):

os.system('pandoc -o /tmp/temp_output.html {} {}'.format(file_location, options))
total_file_contents = (
HEADER +
HEADER_START +
'<title>{}</title>\n'.format(metadata['title']) +
make_twitter_card(metadata, global_config) +
HEADER_END +
defancify(open('/tmp/temp_output.html').read()) +
FOOTER
)
Expand All @@ -157,11 +167,14 @@ def make_toc_item(metadata):
toc_items = [make_toc_item(metadata) for metadata in sorted_metadatas]

toc = (
HEADER +
HEADER_START +
'<title>{}</title>\n'.format(global_config['title']) +
make_twitter_card(global_config, global_config) +
HEADER_END +
TOC_HEADER.format(global_config['title']) +
''.join(toc_items) +
TOC_FOOTER
TOC_FOOTER +
FOOTER
)

open('site/index.html', 'w').write(toc)