diff options
Diffstat (limited to 'filters')
| -rw-r--r-- | filters/emojis.lua | 17 | ||||
| -rw-r--r-- | filters/lib/common.lua | 13 | ||||
| -rw-r--r-- | filters/vars.lua | 15 |
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 @@ | |||
| 1 | local common = require 'filters.lib.common' | ||
| 2 | |||
| 3 | function 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 | ||
| 17 | end | ||
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 |
| 26 | end | 26 | end |
| 27 | 27 | ||
| 28 | function 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 | ||
| 37 | end | ||
| 38 | |||
| 28 | return { | 39 | return { |
| 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 @@ | |||
| 1 | local vars = {} | 1 | local common = require 'filters.lib.common' |
| 2 | |||
| 3 | function 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 | 3 | local vars = {} |
| 9 | parts:insert(field) | ||
| 10 | if s == "" then return parts end | ||
| 11 | end | ||
| 12 | end | ||
| 13 | 4 | ||
| 14 | function meta(meta) vars = meta end | 5 | function meta(meta) vars = meta end |
| 15 | 6 | ||
| 16 | function str(el) | 7 | function 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(".") |
