Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline images don't have a scaledwidth with docbook5 output #4552

Closed
kurthuwig opened this issue Feb 19, 2024 · 5 comments
Closed

Inline images don't have a scaledwidth with docbook5 output #4552

kurthuwig opened this issue Feb 19, 2024 · 5 comments
Assignees
Labels
area/docbook Issues related to DocBook output and the DocBook converter compliance v2.0.21 Issues resolved in the 2.0.21 release
Milestone

Comments

@kurthuwig
Copy link

If I use scaledwidth on an inline image like this.

image:Png-Logo.png[scaledwidth=2cm]

then the resulting DocBook5 xml lacks the width attribute:

<imagedata fileref="Png-Logo.png"/>

Longer example:

image::Png-Logo.png[scaledwidth=2cm]

image::Png-Logo.png[width=2cm]

image:Png-Logo.png[scaledwidth=2cm]

image:Png-Logo.png[width=2cm]

yields

<imagedata fileref="Png-Logo.png" width="2cm"/>
<imagedata fileref="Png-Logo.png" contentwidth="2cm"/>
<imagedata fileref="Png-Logo.png"/>
<imagedata fileref="Png-Logo.png" contentwidth="2cm"/>

Asciidoctor 2.0.20 [https://asciidoctor.org]
Runtime Environment (ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux-musl]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)

Sample project (you need a PNG to actually run it - any one will work): inline-image-scale.zip

@mojavelinux
Copy link
Member

The scaledwidth attribute value is, in fact, carried through. However, it gets remapped to the width attribute in DocBook, whereas the width attribute gets mapped to the contentwidth attribute in DocBook. So the behavior is as expected and documented. See https://docs.asciidoctor.org/asciidoc/latest/macros/image-size/#scaledwidth-attribute and https://tdg.docbook.org/tdg/5.1/imagedata. DocBook doesn't have a scaledwidth attribute (it's named width and acts as a scaled width).

@mojavelinux mojavelinux added this to the support milestone Feb 19, 2024
@mojavelinux mojavelinux self-assigned this Feb 19, 2024
@kurthuwig
Copy link
Author

The scaledwidth attribute is not carried through, if you use an inline image:

image:Png-Logo.png[scaledwidth=2cm]

yields

<imagedata fileref="Png-Logo.png"/>

while the documentation reads

The scaledwidth attribute in AsciiDoc is mapped to the width attribute on the imagedata tag in DocBook

This behavior breaks pandoc's DOCX export, as it requires the width attribute of the imagedata. Without it, the images appear unscaled.

@mojavelinux
Copy link
Member

mojavelinux commented Feb 20, 2024

I see where the confusion is. The scaledwidth is honored for block images, but not for inline images. (In the back of my mind, I just assumed that what was done for a block image was done for an inline image, but on closer examination that's not the case). You can see that the DocBook converter never checks for the scaledwidth attribute when converting an inline image. https://github.com/asciidoctor/asciidoctor/blob/main/lib/asciidoctor/converter/docbook5.rb#L556-L557

The reason this is the case is because Asciidoctor's predecessor (AsciiDoc.py) never supported scaledwidth on inline images. However, Asciidoctor PDF does...so it's reasonable to expect that the DocBook converter does too.

Note that the only time an inline image should be used is when it's in the middle of a paragraph or a normal table cell. It should never be used in place of a block image.

@mojavelinux mojavelinux reopened this Feb 20, 2024
@mojavelinux mojavelinux removed this from the support milestone Feb 20, 2024
@mojavelinux mojavelinux added compliance area/docbook Issues related to DocBook output and the DocBook converter labels Feb 20, 2024
@mojavelinux mojavelinux added this to the v2.0.x milestone Feb 20, 2024
@kurthuwig
Copy link
Author

My use case is a documentation of an app. I need to add screenshots of the app to show the different features. I like to have them side by side, so that I can put more than 2 screenshots on a page - right now I scale them so that I can put 4 of them in 1 row. This allows me to put the screenshots together with the description text on one page of the DOCX document.

It's internal technical documentation, so we care more about tracking it in Git than the styling. From your answer I understand that I could use tables, but this feels wrong to me. Still, I'll use what is there.

@mojavelinux
Copy link
Member

mojavelinux commented Feb 20, 2024

I wasn't disagreeing that this should be added. Since you mixed block and inline images in the example you provided, I thought you were suggesting that scaledwidth was not supported at all. But when I examined it closer, I realized you were making a distinction between the two image macros. (To your credit, you did write "inline images" in the subject). I'm going to add support for scaledwidth for inline images in the next point release.

mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Feb 20, 2024
…butes on inline image macro in DocBook output
@mojavelinux mojavelinux added the v2.0.21 Issues resolved in the 2.0.21 release label Feb 20, 2024
mojavelinux added a commit that referenced this issue Feb 20, 2024
mojavelinux added a commit that referenced this issue Feb 20, 2024
…es on inline image macro in DocBook output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docbook Issues related to DocBook output and the DocBook converter compliance v2.0.21 Issues resolved in the 2.0.21 release
Projects
None yet
Development

No branches or pull requests

2 participants