-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathprocess
More file actions
executable file
·94 lines (81 loc) · 2.09 KB
/
Copy pathprocess
File metadata and controls
executable file
·94 lines (81 loc) · 2.09 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
# false or true
mathjax=false
# echo to stderr
eche () {
echo "$@" 1>&2
}
run_xslt () {
local xslt="$1"
local xml="$2"
local out="$3"
echo "Applying $xslt to $xml to produce $out"
saxonb-xslt -xi -xsl:"$xslt" -s:"$xml" -o:"$out" mathjax=$mathjax
}
run_xslt_s () {
local xslt="$xslt_dir/$1"
eche "Applying $xslt"
saxonb-xslt -xi -xsl:"$xslt" -s:- mathjax=$mathjax
}
action="$1"
xml_path="$2"
out="generated/$xml_path"
xslt_dir=xslt
format=
run_pipeline () {
local xslt=
local index=0
local input_path="$xml_path"
for xslt in "$@"; do
run_xslt "$xslt_dir/$xslt" "$input_path" "$out.$index"
input_path="$out.$index"
let index=index+1
done
cp "$input_path" "$out.$format"
# cat "$out.$format"
}
comment ()
{
:
}
mkdir -p generated
case "$action" in
(html)
format=html
# mathjax=true
# mathxslt=lib-xml-math-latex.xslt
mathjax=false
comment 'cat "$xml_path" \
| run_xslt_s lib-xml-parse-tex-paragraph.xslt \
| run_xslt_s lib-xml-parse-latex-math-delimiter.xslt \
| run_xslt_s lib-xml-normalize.xslt \
| run_xslt_s lib-xml-number.xslt \
| run_xslt_s lib-xml-cite.xslt \
| run_xslt_s lib-xml-math-layout.xslt \
| run_xslt_s lib-xml-math-html-css.xslt \
| run_xslt_s html.xslt \
| tee "$out.$format"
'
mathxslt='lib-xml-math-layout.xslt lib-xml-math-html-css.xslt'
run_pipeline \
lib-xml-parse-tex-paragraph.xslt \
lib-xml-parse-latex-math-delimiter.xslt \
lib-xml-normalize.xslt \
lib-xml-number.xslt \
lib-xml-cite.xslt \
$mathxslt \
html.xslt
eche "Output written to $out.$format"
;;
(latex)
format=tex
run_pipeline \
lib-xml-normalize.xslt \
lib-xml-number.xslt \
lib-xml-cite.xslt \
lib-xml-math-latex.xslt \
latex.xslt
esac