Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
163 posts
|
I like to create a link to this page:
http://en.wikipedia.org/wiki/Swing_(Java) This code: [source,asciidoc] ---- Check on this Wikipedia page: http://en.wikipedia.org/wiki/Swing_(Java) ---- The generated code looks like this: [source,html] ---- <p>Check on this Wikipedia page: <a href="http://en.wikipedia.org/wiki/Swing_(Java" class="bare">http://en.wikipedia.org/wiki/Swing_(Java</a>)</p> ---- This is obviously wrong, because the closing bracket is part of the link. An alternative can be to use percent-encoding of the URL: [source,asciidoc] ---- Using URL encoding: http://en.wikipedia.org/wiki/Swing_%28Java%29 ---- At least the link is correct: [source,html] ---- <p>Using URL encoding: <a href="http://en.wikipedia.org/wiki/Swing_%28Java%29" class="bare">http://en.wikipedia.org/wiki/Swing_%28Java%29</a></p> ---- But I would like the text to be decoded: [source,html] ---- <p>Using URL encoding: <a href="http://en.wikipedia.org/wiki/Swing_%28Java%29" class="bare">http://en.wikipedia.org/wiki/Swing_(Java)</a></p> ---- What do you think? Should I file an enhancement request for that? Where? By the way, reading the documentation, AsciiDoc Syntax Quick Reference > Links, section With spaces and special characters, I was guessing that it would work using ++: [source,asciidoc] ---- link:++http://en.wikipedia.org/wiki/Swing_(Java)++[http://en.wikipedia.org/wiki/Swing_(Java)] ---- But it doesn’t. Doing some debugging, I saw that the link in square brackets is first converted. [source,asciidoc] ---- Wrong link with `+` escape: link:++http://en.wikipedia.org/wiki/Swing_(Java)++[http://some.other.site.com/] Second wrong link without: link:http://en.wikipedia.org/wiki/Swing_(Java)[http://test.com/] ---- Produces: [source,html] ---- <p>Wrong link with <code>+</code> escape: <a href="http://en.wikipedia.org/wiki/Swing_(Java)"></a><a href="http://some.other.site.com/" class="bare">http://some.other.site.com/</a></p> <p>Second wrong link without: <a href="http://en.wikipedia.org/wiki/Swing_(Java)"></a><a href="http://test.com/" class="bare">http://test.com/</a></p> ---- This is definitively a bug I can open if you tell me where. The only way for me to have a working link with the text I want, is to use: [source,asciidoc] ---- link:http://en.wikipedia.org/wiki/Swing_%28Java%29[http://en.wikipedia.org/wiki/Swing_(Java)] ---- But this is very noisy. PS: this forum is also wrong with link display. I have no clue how I can disable them |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
2681 posts
|
Jeremie, In this case, the following works: link:<a href="http://en.wikipedia.org/wiki/Swing_(Java)[]">http://en.wikipedia.org/wiki/Swing_(Java)[] The link inline macro provides the strong boundaries to improve parsing accuracy. Another approach is: http://++en.wikipedia.org/wiki/Swing_(Java)++ (though not as pretty). My strongest recommendation with URLs & links is to assign them to attributes. Not only does it solve most of the escaping issues, it also sticks to the DRY principle, so it's a good practice all around. ---- :link-swing-java: link:<a href="http://en.wikipedia.org/wiki/Swing_(Java)[]">http://en.wikipedia.org/wiki/Swing_(Java)[] {link-swing-java} ---- or ---- :uri-swing-java: http://en.wikipedia.org/wiki/Swing_%28Java%29 {uri-swing-java} ---- I hope that helps. (Yes, URLs are tricky. They will always be tricky, but we hope to be able to make parsing of inline URLs more robust as we create a proper inline parser that is based on a grammar). Cheers, -Dan That's just a fact of life atm :/ On Fri, Apr 24, 2015 at 12:33 PM, Jeremie Bresson [via Asciidoctor :: Discussion] <[hidden email]> wrote: I like to create a link to this page: ... [show rest of quote] Dan Allen | http://google.com/profiles/dan.j.allen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
163 posts
|
Hi,
Thank you for your answer. Even if URL parsing is tricky, I think you should capture cases that are not working. I have opened Issue 1326: https://github.com/asciidoctor/asciidoctor/issues/1326 As for the solution you propose with `<a href=` my guess is that it is only working with the HTML backend. This is a no-go for me (we want to produce PDF out of our Asciidoc sources). This form works: [source,asciidoc] ---- link:http://en.wikipedia.org/wiki/Swing_%28Java%29[http://en.wikipedia.org/wiki/Swing_(Java)] ---- and produces the desired output, but you have to write the link twice (first time <a href="http://en.wikipedia.org/wiki/Percent-encoding">percent-encoded, second time percent-decoded). The enhancement request (apply url-decode for the link text especially for the "bare" form) is still pending. Maybe I will open a request for that too. |
Free forum by Nabble | Edit this page |