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

Link with inline styles is broken up into multiple links #1688

Closed
mrotteveel opened this issue May 10, 2020 · 7 comments
Closed

Link with inline styles is broken up into multiple links #1688

mrotteveel opened this issue May 10, 2020 · 7 comments
Labels
Milestone

Comments

@mrotteveel
Copy link

When a link text has inline styles (eg emphasis), then the rendered link is broken up in multiple links (on the normal text before the line style, the text in the inline style, and on the normal text after the inline style).

This looks a bit off when clicking a link (in Adobe Acrobat), or hovering over a link in Firefox.

As a simple example, take

= Example with link
:doctype: book

[[normal-title]]
== Section with normal title

Some section content

[[with-emphasis]]
== Section with _emphasis_

Some section content

[[with-emphasis-middle]]
== Section with _emphasis_ in middle

Some section content

== links

* <<normal-title>>
* <<with-emphasis>>
* <<with-emphasis-middle>>

In Firefox, hovering over the link looks like:

Normal:
normal-link

Emphasis at end:
emphasis-1-before
emphasis-1-on

Emphasis in middle:
emphasis-2-before
emphasis-2-on
emphasis-2-after

@mojavelinux
Copy link
Member

I'm going to assume you're referring to the PDF viewer in Firefox.

How link annotations get defined is not something that this converter has any control over. That's how Prawn works. Prawn is the PDF generator this converter uses. So you'll need to file an issue in https://github.com/prawnpdf/prawn to collapse adjacent link annotation boxes.

The way text in Prawn works is that each segment of text that has different formatting gets its own fragment, which is then placed onto the page. Here's where the link annotations get defined: https://github.com/prawnpdf/prawn/blob/master/lib/prawn/text/formatted/box.rb

I tried to see if a PDF optimizer would perform this collapsing, but it doesn't seem to be able to.

@mrotteveel
Copy link
Author

I reported prawnpdf/prawn#1157, but as I have no knowledge of Prawn or the internals of asciidoctor-pdf, I'm not sure if I phrased it correctly.

@mojavelinux
Copy link
Member

@mrotteveel It seems like the developers understood your phrasing very well and explained why it's such a difficult behavior to implement.

@mojavelinux
Copy link
Member

This is another example of a feature that we can address with Asciidoctor PDF's browser-based successor. The browser properly tracks the bounding box of a link (even across lines) and thus, when the PDF is generated, the hovering behavior will be as you expect.

@mojavelinux
Copy link
Member

After spending a lot of time in the Prawn text-handling code, my assessment is that it has painted itself into a corner for what it can do with text. It kind of works the way it works and trying to change any part causes all sorts of other behavior to break. Alexander kind of alludes to this in his first reply.

@mrotteveel
Copy link
Author

@mojavelinux Thanks. What is the browser-based successor you're talking about?

@mojavelinux
Copy link
Member

I'll post about it once Asciidoctor PDF 2 is out. You can find an early prototype of it here: https://github.com/mogztter/asciidoctor-pdf.js

@graphitefriction graphitefriction added this to the support milestone May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants