From 347d7c0da13079fefce6d8741a5604adb89eb97c Mon Sep 17 00:00:00 2001 From: Volpeon Date: Thu, 4 Aug 2022 10:26:57 +0200 Subject: Overhauled metadata handling --- filters/emojis.lua | 14 +++++++++++++- filters/vars.lua | 12 ++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'filters') diff --git a/filters/emojis.lua b/filters/emojis.lua index 427d04b..24a9fc3 100644 --- a/filters/emojis.lua +++ b/filters/emojis.lua @@ -1,4 +1,14 @@ -function Str(el) +local common = require 'scripts.lib.common' + +local vars = {} + +function meta(meta) vars = meta end + +function str(el) + if vars.build and vars.build.file_out:match(".xml$") then + return el + end + local prefix, emojiref, suffix = el.text:match('^(.*):([^ ]+):(.*)$') if emojiref then @@ -13,3 +23,5 @@ function Str(el) return el end + +return { { Meta = meta }, { Str = str } } diff --git a/filters/vars.lua b/filters/vars.lua index 99cedc4..61803cb 100644 --- a/filters/vars.lua +++ b/filters/vars.lua @@ -1,3 +1,4 @@ +local utils = require 'pandoc.utils' local common = require 'scripts.lib.common' local vars = {} @@ -12,15 +13,14 @@ function str(el) local var = vars for i = 1, #parts do - local part = parts[i] - local v = var[part] + var = var[parts[i]] - if not v then return el end - - var = v + if not var then + return el + end end - if var then return pandoc.Str(prefix .. var .. suffix) end + return pandoc.Str(prefix .. utils.stringify(var) .. suffix) end return el -- cgit v1.2.3-70-g09d2