summaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
Diffstat (limited to 'filters')
-rw-r--r--filters/emojis.lua17
-rw-r--r--filters/lib/common.lua13
-rw-r--r--filters/vars.lua15
3 files changed, 32 insertions, 13 deletions
diff --git a/filters/emojis.lua b/filters/emojis.lua
new file mode 100644
index 0000000..5eb9d4b
--- /dev/null
+++ b/filters/emojis.lua
@@ -0,0 +1,17 @@
1local common = require 'filters.lib.common'
2
3function Str(el)
4 local prefix, emojiref, suffix = el.text:match('^(.*):([^ ]+):(.*)$')
5
6 if emojiref then
7 local els = pandoc.List()
8
9 els:insert(pandoc.Str(prefix))
10 els:insert(pandoc.Image(emojiref, "/emojis/" .. emojiref .. ".png", emojiref, { class = 'o-emoji' }))
11 els:insert(pandoc.Str(suffix))
12
13 return els
14 end
15
16 return el
17end
diff --git a/filters/lib/common.lua b/filters/lib/common.lua
index 7654eb9..4d44ff3 100644
--- a/filters/lib/common.lua
+++ b/filters/lib/common.lua
@@ -25,6 +25,17 @@ function dump(o)
25 end 25 end
26end 26end
27 27
28function string.split(str, sep)
29 sep = sep or '%s'
30
31 local parts = pandoc.List()
32
33 for field, s in str:gmatch("([^" .. sep .. "]*)(" .. sep .. "?)") do
34 parts:insert(field)
35 if s == "" then return parts end
36 end
37end
38
28return { 39return {
29 wide = wide 40 wide = wide, dump = dump
30} 41}
diff --git a/filters/vars.lua b/filters/vars.lua
index e60019e..b0fa66c 100644
--- a/filters/vars.lua
+++ b/filters/vars.lua
@@ -1,20 +1,11 @@
1local vars = {} 1local common = require 'filters.lib.common'
2
3function string.split(str, sep)
4 sep = sep or '%s'
5
6 local parts = pandoc.List()
7 2
8 for field, s in str:gmatch("([^" .. sep .. "]*)(" .. sep .. "?)") do 3local vars = {}
9 parts:insert(field)
10 if s == "" then return parts end
11 end
12end
13 4
14function meta(meta) vars = meta end 5function meta(meta) vars = meta end
15 6
16function str(el) 7function str(el)
17 local prefix, varref, suffix = el.text:match('^(.*)%%(.*)%%(.*)$') 8 local prefix, varref, suffix = el.text:match('^(.*)%%([^ ]+)%%(.*)$')
18 9
19 if varref then 10 if varref then
20 local parts = varref:split(".") 11 local parts = varref:split(".")