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

Add support for inline images #9

Closed
mojavelinux opened this issue Jul 1, 2014 · 14 comments
Closed

Add support for inline images #9

mojavelinux opened this issue Jul 1, 2014 · 14 comments
Assignees

Comments

@mojavelinux
Copy link
Member

Add support for the inline image macro. This requires adding a convenience method for placing an image in the flow of text. It would be nice to have direct support for this in Prawn, though we can get away with using a method in Asciidoctor PDF until it becomes available upstream.

@getreu
Copy link

getreu commented Oct 7, 2014

+1 Jens

@mikeosbornma
Copy link

+1

1 similar comment
@madmas
Copy link

madmas commented Oct 30, 2014

+1

@mojavelinux
Copy link
Member Author

I'll reiterate that it would be nice to have direct support in Prawn, though I'm open to doing what we have to do in Asciidoctor PDF to support it before then.

Btw, I did do some experimentation with wrapping text around image in Asciidoctor PDF so you can get an idea of the type of logic we need to do.

https://github.com/opendevise/editions/blob/master/lib/editions/pdf_extensions.rb#L88

Another approach is to take the approach the DocBook toolchain takes, which is to assume that inline images should be centered on the line vertically and thus we only have to worry about reserving blank space for them horizontally.

This is definitely something we take for granted when using HTML :)

@mojavelinux mojavelinux added this to the v1.5.0 milestone Oct 31, 2014
@mojavelinux
Copy link
Member Author

I'd say going into the 1.5.0 release, we should have some basic support in some form...even if it's rough. We can then enhance from there.

@plaindocs
Copy link

+1

@mojavelinux
Copy link
Member Author

To help move this along, I was thinking that part of the challenge here is a design issue. An inline image means that text needs to be wrapped around it...that is, if it's a larger image. If we can assume that inline images fit within a line (like the DocBook toolchain assumes), then we could easily implement this by leaving enough horizontal space for the image and coming back to insert it. Would that fit some of the requirements up front, or is support for wrapping text around the image critical? Maybe we could handle this as two separate issues.

@getreu
Copy link

getreu commented Feb 3, 2015

I think at this stage reproducing the behaviour of the Docbook toolchain as best as possbile is a good idea. We still need the docbook toolchain for production environments but asciidoctor-pdf gives already good results in many usecases. We should make sure they produce the same. (BTW. I recently discoverd small difference in treating callouts. I will file a bug report as soon I have some time).

@mojavelinux
Copy link
Member Author

at this stage reproducing the behaviour of the Docbook toolchain as best as possbile is a good idea.

👍

@thomseno
Copy link

thomseno commented Jun 3, 2015

+1

@mojavelinux
Copy link
Member Author

I've got a prototype of this working. The code is very ugly at the moment, but the result is already looking quite nice. Here's a preview.

inline-image-screenshot

As you can see, the idea is to give enough room for the width of the image and allow the height to grow outwards (up and down) from the center of the line. This allows us to accommodate images without squishing them vertically. However, if they grow too tall, they will overlap the text on the line above and below. But you can just adjust the width of the image until it fits :)

@mojavelinux
Copy link
Member Author

The way I have to implement this is quite strange, but perhaps a good opportunity for an API improvement in Prawn. I have to calculate the width of the image (or the explicit width) and insert the appropriate number of non-breaking spaces in the text to make room for the image. Then, I intercept the printing of the spaces and put the image there instead.

What I'd like to be able to do is tell Prawn to reserve a certain amount of width of a fragment and just skip writing anything. Seems reasonable enough. But this hack will work for our purposes now.

mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jun 9, 2015
- arrange and embed inline images (currently don't affecting line height)
- support remote inline images
- move text formatter code under Asciidoctor::Pdf::FormattedText namespace
- only match formatted text that the converter creates
- optimize how Prawn extension code is loaded
- code cleanups
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jun 9, 2015
- arrange and embed inline images (currently don't affecting line height)
- support remote inline images
- use alt text if image can't be found or read
- move text formatter code under Asciidoctor::Pdf::FormattedText namespace
- only match formatted text that the converter creates
- optimize how Prawn extension code is loaded
- code cleanups
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jun 11, 2015
- arrange and embed inline images (currently don't affecting line height)
- support remote inline images
- use alt text if image can't be found or read
- move text formatter code under Asciidoctor::Pdf::FormattedText namespace
- only match formatted text that the converter creates
- optimize how Prawn extension code is loaded
- code cleanups
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jun 20, 2015
- arrange and embed inline images (currently don't affecting line height)
- support remote inline images
- use alt text if image can't be found or read
- move text formatter code under Asciidoctor::Pdf::FormattedText namespace
- only match formatted text that the converter creates
- optimize how Prawn extension code is loaded
- code cleanups
mojavelinux added a commit that referenced this issue Jun 22, 2015
resolves #9 support inline images
@mojavelinux
Copy link
Member Author

Support for inline images is now in master, and I think it goes beyond what even DocBook supports. We're more on par with HTML, though vertical alignment is still primitive (as described in the pull request). Feel free to test!

mojavelinux added a commit that referenced this issue Jun 22, 2015
@mojavelinux
Copy link
Member Author

Missing files restored. Now you should be able to test ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants