pandoc-cl/format-quote.lua

26 lines
882 B
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- fully copied from https://gist.github.com/niklaskorz/c9d55b157078dd1e1f5badad15093a72
local double_quotes = {"»", "«"}
local single_quotes = {"", ""}
function get_preferences(m)
if m.double_quotes and m.double_quotes[1] and m.double_quotes[2] then
double_quotes = { m.double_quotes[1][1].c, m.double_quotes[2][1].c }
end
if m.single_quotes and m.single_quotes[1] and m.single_quotes[2] then
single_quotes = { m.single_quotes[1][1].c, m.single_quotes[2][1].c }
end
end
function replace_quotes(elem)
local quotes = double_quotes
if elem.quotetype == "SingleQuote" then
quotes = single_quotes
end
return {pandoc.Str(quotes[2]), pandoc.RawInline('latex', '~')} .. elem.content .. {pandoc.RawInline('latex', '~'), pandoc.Str(quotes[1])}
end
return {
{ Meta = get_preferences },
{ Quoted = replace_quotes },
}