handlers.lua

Wed, 08 Dec 2021 23:32:16 +0200

author
Tuomo Valkonen <tuomov@iki.fi>
date
Wed, 08 Dec 2021 23:32:16 +0200
changeset 40
458b3ce6e2f2
parent 38
5c771653d5ac
permissions
-rw-r--r--

highlight.js changes update

2
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
1
7
038275cd92ed Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents: 4
diff changeset
2 --@module handlers
2
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
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
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
9
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
10 local available={
37
d63f9862304a more ignores
Tuomo Valkonen <tuomov@iki.fi>
parents: 34
diff changeset
11 { pattern = "^_build", handler = handlers.ignore},
34
4c7122a505d4 Add ignores
Tuomo Valkonen <tuomov@iki.fi>
parents: 26
diff changeset
12 { pattern = "^%.", handler = handlers.ignore},
4c7122a505d4 Add ignores
Tuomo Valkonen <tuomov@iki.fi>
parents: 26
diff changeset
13 { pattern = "/%.", handler = handlers.ignore},
37
d63f9862304a more ignores
Tuomo Valkonen <tuomov@iki.fi>
parents: 34
diff changeset
14 { pattern = "%.note$", handler = handlers.ignore},
38
5c771653d5ac more ignores
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
15 { pattern = "%.code%-workspace", handler = handlers.ignore},
37
d63f9862304a more ignores
Tuomo Valkonen <tuomov@iki.fi>
parents: 34
diff changeset
16 { pattern = "~$", handler = handlers.ignore},
3
b2df1b3f2c83 Improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 2
diff changeset
17 { 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
18 { pattern = "%.md$", handler = handlers.render},
3
b2df1b3f2c83 Improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 2
diff changeset
19 { pattern = "", handler = handlers.copy},
2
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
20 }
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
21
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
22
7
038275cd92ed Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents: 4
diff changeset
23 function handlers.find(f)
2
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
24 for _, h in ipairs(available) do
3
b2df1b3f2c83 Improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 2
diff changeset
25 if string.match(f, h.pattern) then
2
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
26 return h.handler
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
27 end
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
28 end
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
29 return handlers.ignore
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
30 end
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
31
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
32 local cached={}
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
33
7
038275cd92ed Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents: 4
diff changeset
34 function handlers.choose(f, env)
038275cd92ed Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents: 4
diff changeset
35 cached[f] = handlers.find(f)
2
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
36 end
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
37
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
38 -- load
7
038275cd92ed Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents: 4
diff changeset
39 function handlers.phase1(f, env)
2
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
40 return cached[f].phase1(f, env)
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
41 end
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
42
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
43 -- write
7
038275cd92ed Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents: 4
diff changeset
44 function handlers.phase2(f, env)
2
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
45 return cached[f].phase2(f, env)
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
46 end
3975fa5ed630 (don't know)
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
47
7
038275cd92ed Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents: 4
diff changeset
48 return handlers

mercurial