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

32 lines
823 B
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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 }
}