bavbavhaus.net/pandoc/filters/localize-quotes.lua

32 lines
823 B
Lua
Raw Normal View History

2024-04-12 22:30:16 +02:00
SCRIPT_NAME = "localize-quotes.lua"
os.setlocale("C")
QUOTEMARKS_LANGMAP = {
de = {'', '', '', '' },
en = {'', '', '', '' },
it = {'«', '»', '', '' },
sl = {'»', '«', '', '' },
}
QUOTEMARKS = nil
return {
{ Meta = function (meta)
local lang = pandoc.utils.stringify(meta["lang"] or "en")
QUOTEMARKS = QUOTEMARKS_LANGMAP[lang]
end },
{ Quoted = function (quoted)
if not QUOTEMARKS then return end
if quoted.quotetype == "DoubleQuote" then
quoted.content:insert(1, QUOTEMARKS[1])
quoted.content:insert( QUOTEMARKS[2])
return quoted.content
end
if quoted.quotetype == "SingleQuote" then
quoted.content:insert(1, QUOTEMARKS[3])
quoted.content:insert( QUOTEMARKS[4])
return quoted.content
end
end }
}