asciidoc

how to include roles into link text in ASCIIdoc?


I would like to use roles in the text that's displayed for a link. I've tried a lot of different ways, but have not found one that does what I want. Say, I have

https://example.com[Group 1: C1, E1]

but I want the C1 to be of role role1 and the E1 of role role2. Intuitively, I'd use

https://example.com[Group 1: [.role1]#C1#, [.role2]#E1#]

but that seems to make the , be parsed differently...


Solution

  • The “trick” is to turn the comma from Asciidoctor syntax into a literal comma, which you can do by writing it as the html escape.

    https://example.com[Group 1: [.role1]#C1#, [.role2]#E1#]
    

    Result:

    <p><a href="https://example.com">Group 1: <span class="role1">C1</span>&#x2C; <span class="role2">E1</span></a></p>