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

Preserve soft hyphens when advancing line to the next page #1133

Open
mojavelinux opened this issue Nov 14, 2019 · 2 comments
Open

Preserve soft hyphens when advancing line to the next page #1133

mojavelinux opened this issue Nov 14, 2019 · 2 comments

Comments

@mojavelinux
Copy link
Contributor

When there's not enough height for a line of text on the current page, Prawn advances that line to the next page (handled by Prawn::Text::Formatted::Wrap). When this happens, the soft hyphens in that line are stripped. As a result, soft hyphens are absent when the line is rendered. This affects hyphenation. The soft hyphens should be preserved.

@mojavelinux
Copy link
Contributor Author

mojavelinux commented Nov 14, 2019

The problematic line is the call to Fragment#include_trailing_white_space! in Arranger#repack_unretrieved. (See

fragment.include_trailing_white_space!
). That call, in turn, calls Fragment#process_text, which removes soft hyphens.

If we look at the implementation for Fragment#include_trailing_white_space!, we see that it calls @format_state.delete(:exclude_trailing_white_space). So it seems like it was an oversight not to also call @format_state.delete(:normalized_soft_hyphen). Adding that line fixes the problem.

I ran all tests in Prawn and all 750+ tests in Asciidoctor PDF and can report that adding this line does not break any of the tests.

@mojavelinux
Copy link
Contributor Author

Here's the interim patch I've applied to Asciidoctor PDF: https://github.com/asciidoctor/asciidoctor-pdf/pull/1384/files

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

No branches or pull requests

1 participant