Search code examples
htmlhyperlinkasciidocasciidoctor

Using an Image as a Link in AsciiDoc


I'm trying to create a "clickable" image in AsciiDoc lightweight markup language with Asciidoctor.

I tried the following (not working): image::<url1>[<url2>[]]

For example:

image::https://img.shields.io/badge/License-Apache%202.0-blue.svg[http://www.apache.org/licenses/LICENSE-2.0[]]

It should become roughly the following html:

<a href="http://www.apache.org/licenses/LICENSE-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> 

How can I accomplish this in AsciiDoc without passing through raw HTML?


Solution

  • block:

    image::https://img.shields.io/badge/License-Apache%202.0-blue.svg[link="http://www.apache.org/licenses/LICENSE-2.0"]
    

    inline:

    image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[link="http://www.apache.org/licenses/LICENSE-2.0"]
    

    Notice the link attribute on the image.