Pandoc: automatically convert URLs into hyperlinks
Asked Answered
I

2

11

Is there an option which automatically converts URLs into hyperlinks in Pandoc?

E.g.

http://www.test.com

should become

[http://www.test.com](http://www.test.com)

Or even cooler would be without the protocol:

[www.test.com](http://www.test.com)
Invulnerable answered 15/2, 2016 at 16:17 Comment(0)
J
11

Just surround them in <> : <http://www.test.com>

echo "<http://example.com>" | pandoc
<p><a href="http://example.com" class="uri">http://example.com</a></p>

That will not work without the http:// though. See the documentation.

Jog answered 15/2, 2016 at 16:44 Comment(1)
This looks good, but in my case, the link is also surrounded by a <code class="url">...</code>. I'm not sure whether I like this. Is there a way to prevent this?Invulnerable
A
9

Actually now you can use a command line option when you specify the input format

$ echo "http://example.com" | pandoc -f markdown+autolink_bare_uris
<p><a href="http://example.com" class="uri">http://example.com</a></p>

Note: I used pandoc version 2.11.4

Arneson answered 7/4, 2021 at 18:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.