Search code examples
asciidoctor

Create link with asciidoctor that has an ID


I would like to create a external link with an ID using asciidoctorj. I couldn't find anywhere in the manual a way on how to do it.

Asciidoctor Source:

http://stackoverflow.com[Cool Site, id="myId"] ...

Current result:

<a href="http://stackoverflow.com">Cool Site</a> ...

Expected result:

<a id="myId" href="http://stackoverflow.com">Cool Site</a> ...

Solution

  • I don't think it's possible (for now): http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#links

    But you can define role to produce HTML class, for example:

    http://discuss.asciidoctor.org[Discuss Asciidoctor, role="external"]
    

    will produce:

    <a href="http://discuss.asciidoctor.org" class="external">Discuss Asciidoctor</a>
    

    You can also open an issue here to ask for it!