summaryrefslogtreecommitdiffstats
path: root/scripts/pages_content.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/pages_content.lua')
-rw-r--r--scripts/pages_content.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/pages_content.lua b/scripts/pages_content.lua
new file mode 100644
index 0000000..b753b1e
--- /dev/null
+++ b/scripts/pages_content.lua
@@ -0,0 +1,27 @@
1local path = require 'pandoc.path'
2
3local namespace = ''
4local siteUrl = ''
5
6function meta(meta)
7 namespace = pandoc.utils.stringify(meta.namespace.full)
8 siteUrl = pandoc.utils.stringify(meta.site.url):gsub("/$", "")
9end
10
11function 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
17end
18
19function 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
25end
26
27return { { Meta = meta }, { Image = image, Link = link } }