-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_html.py
32 lines (27 loc) · 971 Bytes
/
update_html.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import subprocess
insert_text = '''
<link rel="shortcut icon" type="image/png" href="https://s3.amazonaws.com/jedwebster.com/static/47.png"/>
<script type="text/javascript" id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
</script>
'''
def update():
bashCommand = "jemdoc index"
process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE)
output, error = process.communicate()
def write(file):
with open(file, 'r+') as f:
lines = f.readlines()
for i, line in enumerate(lines):
if line.startswith('<head>'):
lines[i] = lines[i] + insert_text
elif line.__contains__('latex'):
lines[i] = line.replace('latex', '\(\LaTeX\)')
f.truncate()
f.seek(0)
for line in lines:
f.write(line)
# next: auto upload site to object storage
if __name__ == '__main__':
update()
write('index.html')