-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.nim
45 lines (38 loc) · 1.5 KB
/
build.nim
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
import strutils, os, re
proc main(file: string) =
discard execShellCmd("nim rst2html $1.rst" % file)
const
patternA = "<span class\\=\"Operator\">***</span>" &
"(.*?)" &
"<span class\\=\"Operator\">***</span>"
proc writeln(buf: var string; x: string) = buf.add x & "\n"
proc tline(line: string): string =
result = line.replacef(re(patternA.replace("***", r"\*\*\*"), {}),
"<span style=\"background-color:#FF7700\">$1</span>")
result = result.replacef(re(patternA.replace("***", r"\+\+\+"), {}),
"<span style=\"background-color:#FFFF00\">$1</span>")
result = result.replacef(re(patternA.replace("***", r"\=\=\="), {}),
"<span style=\"background-color:#7777FF\">$1</span>")
var f = ""
var count = 0
for line in lines("$1.html" % file):
if line.contains("<h1"):
inc count
if count != 1:
f.writeln("</div>")
f.writeln("<div class=\"slide\">")
f.writeln(line.tline)
elif line.contains("<h2 "):
f.writeln("</div><div class=\"slide\" class=\"incremental\">")
let a = line.replace("<h2 ", "<h1 ").replace("</h2>", "</h1>")
f.writeln(a.tline)
elif line.contains("</html>"):
f.writeln("</div>")
f.writeln(line.tline)
else:
f.writeln(line.tline)
for x in os.walkFiles("*.markdeep"):
f = f.replace("<pre>$1</pre>" % x, x.readFile)
writeFile("$1.html" % file, f)
for x in os.walkFiles("*.rst"):
main(x.splitFile.name)