Created
December 1, 2018 11:17
-
-
Save niklaskorz/c9d55b157078dd1e1f5badad15093a72 to your computer and use it in GitHub Desktop.
Pandoc filter for replacing quotation marks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[1])} .. elem.content .. {pandoc.Str(quotes[2])} | |
end | |
return { | |
{ Meta = get_preferences }, | |
{ Quoted = replace_quotes }, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OK good to know!