asciidoctor / asciidoctor

:gem: A fast, open source text processor and publishing toolchain, written in Ruby, for converting AsciiDoc content to HTML 5, DocBook 5, and other formats.
https://asciidoctor.org
Other
4.75k stars 789 forks source link

image:[link=] produces no href in -b docbook5 #4385

Open arcnmx opened 1 year ago

arcnmx commented 1 year ago

The following example:

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

produces the following xml via asciidoctor -b docbook5:

<simpara><inlinemediaobject>
    <imageobject>
        <imagedata fileref="https://img.shields.io/badge/License-Apache%202.0-blue.svg"/>
    </imageobject>
    <textobject><phrase>License Apache%202.0 blue</phrase></textobject>
</inlinemediaobject></simpara>

note the lack of any link to http://www.apache.org present :disappointed:

while asciidoctor -b html5 works about as expected:

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

Expected Output

I expected something more like this:

<link xlink:href="http://www.apache.org/licenses/LICENSE-2.0"><inlinemediaobject>
      <imageobject>
          <imagedata fileref="https://img.shields.io/badge/License-Apache%202.0-blue.svg" />
      </imageobject>
</inlinemediaobject></link>

(this is what pandoc -t docbook produces at least)

Version

Asciidoctor 2.0.18 [https://asciidoctor.org] Runtime Environment (ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)

arcnmx commented 1 year ago

2018 seems related but is about block images (and proposes an extension to the syntax?). What pandoc does for inline images appears to just be how it's meant to work.

arcnmx commented 1 year ago

Also related to image macros and the docbook backend, titles just don't get converted at all?

asciidoctor -s -b docbook5 - <<< 'image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[alt,title="License"]'
<simpara><inlinemediaobject>
<imageobject>
<imagedata fileref="https://img.shields.io/badge/License-Apache%202.0-blue.svg"/>
</imageobject>
<textobject><phrase>alt</phrase></textobject>
</inlinemediaobject></simpara>

(note the lack of "License" appearing anywhere)

mojavelinux commented 1 year ago

Your observation is correct that support for the link attribute on the image macros has never been added to the DocBook converter. If you, or someone else who is available, submits a PR to implement it, I will review it and see that it gets merged into main for the next minor release (2.1.x).

mojavelinux commented 1 year ago

Also related to image macros and the docbook backend...

Please keep issues to a single topic.