-
Notifications
You must be signed in to change notification settings - Fork 0
/
render_prelude
43 lines (36 loc) · 2.04 KB
/
render_prelude
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
'html-user-input "<div class=\"user-input interactive\"><button class=\"capricon-trigger\">Try It Out</button><label class=\"capricon-input-prefix\">> <input type=\"text\" class=\"capricon-input\" /></label><pre class=\"capricon-output\"></pre></div>" def
'html-output {
'comment { print pop } def
'begin-code-paragraph {
"" 0 2 shift reverse {
swap pop dup "<button class=\"capricon-example\" data-code=\"%a\"><pre class=\"capricon\">%n</pre></button>%s" format
1
} each
{ "<div class=\"capricon-examples\">%s</div>" format }
{ 2 shift 2 - 2 shaft } 2 3 shift pick exec
swap "<pre class=\"capricon capricon-paragraph capricon-context\">%n</pre>" format
html-user-input 3 shaft 2 shift 3 +
"<span class=\"expand-then\" style=\"--num-lines: %v.25\"><div class=\"capricon-steps\">%s%s%s</div></span>" format
"<label class=\"expansible box\"><input type=\"checkbox\" checked=\"checked\" /><span class=\"expand-else capricon-show\"></span><span class=\"expand-then capricon-hide\"></span>%s</label>" format
"%s<div class=\"capricon-paragraphresult\">" printf
} def
'end-code-paragraph { "</div>" printf } def
'begin-code-span { pop "<label class=\"expansible inline\"><span>" printf } def
'end-code-span { "</span><input type=\"checkbox\"><span class=\"expand-then\"><code class=\"capricon capricon-steps\">%n</code></span></label>" printf } def
'newline { "<br/>" print pop } def
'newpage { "<hr/>" print pop } def
} def
'tex-output {
'comment { print pop } def
'begin-code-paragraph { pop swap pop "\\begin{verbatim}\n%s\n\\end{verbatim}\n" printf } def
'end-code-paragraph { "\n" print pop } def
'begin-code-span { pop "\\textit{" print pop } def
'end-code-span { pop "}" print pop } def
'newline { " \\\\ " print pop } def
'newpage { " \\newpage " print pop } def
} def
'module {
dup source-dir "%s%s" format source swap
{ output-dir "%s%s.tex.md" format tex-output redirect } collect pop
output-dir "%s%s.html.md" format html-output redirect
} def