quarto-dev / quarto-dev/quarto-cli
[FR] Offer a way to add link using new ipv6 convention
@cderv is already working on this.
Since Apr 2, 2024.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Definely something with Pandoc which HTML escape the characters when parsing the link
echo '[test](http://[fd04::123]:8080)' | pandoc -f markdown -t native
[ Para
[ Link
( "" , [] , [] )
[ Str "test" ]
( "http://%5Bfd04::123%5D:8080" , "" )
]
]
They do escape at reading time with usual URI escaping
https://github.com/jgm/pandoc/blob/e4ac26d255ad8748c01301b3319975de39a8f43f/src/Text/Pandoc/URI.hs#L29-L32
Note that JS function also does it
> encodeURI('http://[fd04::123]:8080')
'http://%5Bfd04::123%5D:8080'
So I think those URL are quite specific, right ?
It seems it requires a specific handling for ipv6 following recent RFC3986
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI#encoding_for_rfc3986
So it definitely need an update to Pandoc to follow ipv6 compliance if possible.
but you could also for now do that yourself using Lua filter
-- ipv6.lua
Link = function(l)
if l.classes:includes("ipv6") then
_, i = l.classes:find("ipv6")
l.classes:remove(i)
l.target = l.target:gsub("%%5B", "[")
l.target = l.target:gsub("%%5D", "]")
end
return l
end
❯ echo '[test](http://\[fd04::123\]:8080){.ipv6}' | pandoc -f markdown -t native --lua-filter=ipv6.lua
[ Para
[ Link
( "" , [] , [] )
[ Str "test" ]
( "http://[fd04::123]:8080" , "" )
]
]
❯ echo '[test](http://\[fd04::123\]:8080){.ipv6}' | pandoc -f markdown -t html --lua-filter=ipv6.lua
<p><a href="http://[fd04::123]:8080">test</a></p>
Hope it helps
Originally posted by @cderv in https://github.com/quarto-dev/quarto-cli/discussions/9229#discussioncomment-8953991
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.