37 lines
931 B
Lua
37 lines
931 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 = function (meta)
|
|
meta = getVars(meta)
|
|
meta['outputFile'] = os.getenv("OUTPUT_FILE")
|
|
meta['inputDir'] = os.getenv("INPUT_DIR")
|
|
end
|
|
},
|
|
{
|
|
Str = function (el)
|
|
if vars[el.text] then
|
|
return pandoc.Span(vars[el.text])
|
|
else
|
|
return el
|
|
end
|
|
end
|
|
}
|
|
}
|