33 lines
766 B
Lua
33 lines
766 B
Lua
local vars = {}
|
|
|
|
local additionalChars = {".", ",", "!", ":", ";"}
|
|
|
|
local function getVars(meta)
|
|
for k, v in pairs(meta) do
|
|
if v.t == 'MetaInlines' then
|
|
local var_key = "$" .. k .. "$"
|
|
local var_value = table.unpack(v)["c"]
|
|
vars[var_key] = var_value
|
|
for _, char in pairs(additionalChars) do
|
|
vars[var_key .. char] = var_value .. char
|
|
vars[char .. var_key] = char .. var_value
|
|
end
|
|
end
|
|
end
|
|
return meta
|
|
end
|
|
|
|
return {
|
|
{
|
|
Meta = getVars
|
|
},
|
|
{
|
|
Str = function (el)
|
|
if vars[el.text] then
|
|
return pandoc.Span(vars[el.text])
|
|
else
|
|
return el
|
|
end
|
|
end
|
|
}
|
|
}
|