Sun, 19 Jul 2020 11:12:54 -0500
Replace local links to .md by corresponding .html on build (markdown-it only).
2 | 1 | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
2 | --@module handlers |
2 | 3 | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
4 | local handlers={} |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
5 | |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
6 | handlers.render=require("handlers.render") |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
7 | handlers.copy=require("handlers.copy") |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
8 | handlers.ignore=require("handlers.ignore") |
2 | 9 | |
10 | local available={ | |
3 | 11 | { pattern = "%.lg$", handler = handlers.render}, |
26
77cd7b8fb6a6
Rename path.lua mypath.lua not conflict with other lua path modules.
Tuomo Valkonen <tuomov@iki.fi>
parents:
7
diff
changeset
|
12 | { pattern = "%.md$", handler = handlers.render}, |
4 | 13 | { pattern = "%.note$", handler = handlers.ignore}, |
26
77cd7b8fb6a6
Rename path.lua mypath.lua not conflict with other lua path modules.
Tuomo Valkonen <tuomov@iki.fi>
parents:
7
diff
changeset
|
14 | { pattern = "%.hg/", handler = handlers.ignore}, |
3 | 15 | { pattern = "", handler = handlers.copy}, |
2 | 16 | } |
17 | ||
18 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
19 | function handlers.find(f) |
2 | 20 | for _, h in ipairs(available) do |
3 | 21 | if string.match(f, h.pattern) then |
2 | 22 | return h.handler |
23 | end | |
24 | end | |
25 | return handlers.ignore | |
26 | end | |
27 | ||
28 | local cached={} | |
29 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
30 | function handlers.choose(f, env) |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
31 | cached[f] = handlers.find(f) |
2 | 32 | end |
33 | ||
34 | -- load | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
35 | function handlers.phase1(f, env) |
2 | 36 | return cached[f].phase1(f, env) |
37 | end | |
38 | ||
39 | -- write | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
40 | function handlers.phase2(f, env) |
2 | 41 | return cached[f].phase2(f, env) |
42 | end | |
43 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
4
diff
changeset
|
44 | return handlers |