diff options
Diffstat (limited to 'scripts/content.lua')
-rw-r--r-- | scripts/content.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/content.lua b/scripts/content.lua new file mode 100644 index 0000000..d77759d --- /dev/null +++ b/scripts/content.lua | |||
@@ -0,0 +1,27 @@ | |||
1 | local path = require 'pandoc.path' | ||
2 | |||
3 | local namespace = '' | ||
4 | local siteUrl = '' | ||
5 | |||
6 | function meta(meta) | ||
7 | namespace = pandoc.utils.stringify(meta.namespace) | ||
8 | siteUrl = pandoc.utils.stringify(meta.site.url):gsub("/$", "") | ||
9 | end | ||
10 | |||
11 | function image(el) | ||
12 | if path.is_relative(el.src) and not el.src:match("^https?://") then | ||
13 | el.src = siteUrl .. path.join({ namespace, el.src }) | ||
14 | end | ||
15 | |||
16 | return el | ||
17 | end | ||
18 | |||
19 | function link(el) | ||
20 | if path.is_relative(el.target) and not el.target:match("^https?://") then | ||
21 | el.target = siteUrl .. path.join({ namespace, el.target }) | ||
22 | end | ||
23 | |||
24 | return el | ||
25 | end | ||
26 | |||
27 | return { { Meta = meta }, { Image = image, Link = link } } | ||