-
Notifications
You must be signed in to change notification settings - Fork 1
/
pretext-old.py
43 lines (37 loc) · 1.34 KB
/
pretext-old.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
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
# import subprocess
import lxml.etree as ET
def build_html():
import os
xsltfile = "../../mathbook/xsl/mathbook-html.xsl"
ptxfile = "../../mathbook/examples/minimal/minimal.xml"
outputdir = "./html"
os.chdir("./html-test") #change to output dir.
if not os.path.exists('knowl'):
os.makedirs('knowl')
# Need to ensure folders exist first.
dom = ET.parse(ptxfile)
xslt = ET.parse(xsltfile)
transform = ET.XSLT(xslt)
transform(dom)
# newdom = transform(dom)
# # print(ET.tostring(newdom, pretty_print=True))
# # infile = str((ET.tostring(newdom, pretty_print=True)))
# outfile = open("output-test.tex", 'w', encoding="utf-8", newline='')
# outfile.write(str(newdom))
# outfile.close()
def build_latex():
xsltfile = "../mathbook/xsl/mathbook-latex.xsl"
ptxfile = "../mathbook/examples/minimal/minimal.xml"
dom = ET.parse(ptxfile)
xslt = ET.parse(xsltfile)
transform = ET.XSLT(xslt)
# transform(dom)
newdom = transform(dom)
# print(ET.tostring(newdom, pretty_print=True))
# infile = str((ET.tostring(newdom, pretty_print=True)))
outfile = open("output-test.tex", 'w', encoding="utf-8", newline='')
outfile.write(str(newdom))
outfile.close()
build_html()
# build_latex()