asciidoctor / asciidoctor-extensions-lab

A lab for testing and demonstrating Asciidoctor extensions. Please do not use this code in production. If you want to use one of these extensions in your application, create a new project, import the code, and distribute it as a RubyGem. You can then request to make it a top-level project under the Asciidoctor organization.
Other
104 stars 101 forks source link

ImageSizingTreeprocessor for putting width and height attrs into images #80

Closed danyill closed 2 years ago

danyill commented 6 years ago

I realised I couldn't do height scaling on an image in a table, and discovered that there were some other image handling problems (see Issue 820 and Issue 1116). For my money I would have said that at least being able to set the height rather than the width should be a feature of the core.

I thought for education I would attempt the Treeprocessor for image blocks using fastimage as per the @mojavelinux suggestion.

I took the approach (discussed in the above issues) that aspect ratio must be as per the image sizing and so this Treeprocessor respects the image aspect ratio and doesn't allow it to be changed. There is I guess other reasonable options.

I had difficulty figuring out how to iterate across table cells to deal with block images in asciidoc styled cells. There is quite possibly a better way but it wasn't obvious to me.

Hopefully this is closer to the desired code style as well.

danyill commented 6 years ago

I forgot to reference Issue 1451 where @mojavelinux suggested a TreeProcessor

danyill commented 6 years ago

Thinking about this (and https://github.com/asciidoctor/asciidoctor/issues/1116), maybe I did it wrong. If the user specifies the height, should we just proportionately modify the width and only set that to retain responsiveness?

mojavelinux commented 10 months ago

The width is the only attribute that the processor considers. So the width should be computed from the height and passed through.