From 347d7c0da13079fefce6d8741a5604adb89eb97c Mon Sep 17 00:00:00 2001 From: Volpeon Date: Thu, 4 Aug 2022 10:26:57 +0200 Subject: Overhauled metadata handling --- scripts/content.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 scripts/content.lua (limited to 'scripts/content.lua') 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 @@ +local path = require 'pandoc.path' + +local namespace = '' +local siteUrl = '' + +function meta(meta) + namespace = pandoc.utils.stringify(meta.namespace) + siteUrl = pandoc.utils.stringify(meta.site.url):gsub("/$", "") +end + +function image(el) + if path.is_relative(el.src) and not el.src:match("^https?://") then + el.src = siteUrl .. path.join({ namespace, el.src }) + end + + return el +end + +function link(el) + if path.is_relative(el.target) and not el.target:match("^https?://") then + el.target = siteUrl .. path.join({ namespace, el.target }) + end + + return el +end + +return { { Meta = meta }, { Image = image, Link = link } } -- cgit v1.2.3-70-g09d2