I have the following markdown:
[title]({{url}})
The {{url}}
is needed for templating purposes later, after markdown is parsed to html.
Pandoc outputs:
<a href="%7B%7Burl%7D%7D">title</a>
but I need:
<a href="{{ur}}">title</a>
Is there an option in Pandoc to do so?
The URL encoding happens during the Markdown parsing step. We can revert it with the help of a Lua filter: Save the below to a file urldecode.lua
and pass that file to pandoc via --lua-filter=urldecode.lua
.
local hexchar = function(x)
return string.char(tonumber(x, 16))
end
function Link (link)
link.target = link.target:gsub('%%(%x%x)', hexchar)
return link
end