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

LaTeX: prohibit also with xelatex linebreaks at dashes in literal text (not code-blocks) (fixes #9925) #9949

Merged
merged 4 commits into from Dec 9, 2021

Conversation

jfbu
Copy link
Contributor

@jfbu jfbu commented Dec 6, 2021

Fix #9925

The behaviour of xelatex diverged from the one of pdflatex: the latter prohibited linebreaks at dashes in literal text (not code-blocks) as after effect of monospace font. But not so with xelatex. Now it will be prohibited for both, even if not using monospace font for the literal text rendering.

Linebreaks at dashes encountered in regular text will still be happening (on purpose).

The PR also fixes some truly misleading comments in sphinxlatexstyletext.sty file

@jfbu jfbu added this to the 4.3.2 milestone Dec 6, 2021
@jfbu jfbu changed the title 9925 latex LaTeX: prohibit also with xelatex linebreaks at dashes in literal text (not code-blocks) (fixes #9925) Dec 6, 2021
@jfbu
Copy link
Contributor Author

jfbu commented Dec 7, 2021

tbh, not sure if this should go into 4.3.2 or future 4.x release

@marxin
Copy link
Contributor

marxin commented Dec 7, 2021

I've just tried your branch with latex_engine = 'xelatex' and I can still see the line breaks in the options listing.

@marxin
Copy link
Contributor

marxin commented Dec 7, 2021

Can be seen here:

git clone git@github.com:marxin/texi2rst-generated.git
git checkout sphinx-testing
cd texi2rst-generated/sphinx/demo
make latexpdf

@jfbu
Copy link
Contributor Author

jfbu commented Dec 7, 2021

I've just tried your branch with latex_engine = 'xelatex' and I can still see the line breaks in the options listing.

thanks for feedback, but I can't reproduce the problem I compiled your demo, it does use xelatex:

This is XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2021) (preloaded format=xelatex 2021.11.13)  7 DEC 2021 17:47

and I see no problem in pdf

demo.pdf

@jfbu
Copy link
Contributor Author

jfbu commented Dec 7, 2021

edit: this was before I saw your edit "git checkout sphinx-testing"

trying out now... no, it does work for me. I do not see any suspicious linebreak at a dash.

@marxin
Copy link
Contributor

marxin commented Dec 7, 2021

and I see no problem in pdf

demo.pdf

You are right! I forgot to run pip install -e . once I switched sphinx branch.
Thanks for help!

@jfbu
Copy link
Contributor Author

jfbu commented Dec 7, 2021

thanks for test file...

@tk0miya
Copy link
Member

tk0miya commented Dec 9, 2021

I feel this is not a critical bug. So it's better to merge this into the 4.x branch

Whether or not to allow linebreaks is matter of debate because user of
pdf can not reflow the displayed text, and overfull lines may lead to
loss of data beyond page border.

Since Sphinx 1.5, inline literals allow linebreaks after the characters
".", ",", ";", "?", "!", "/" and "\" (cf the inlineliteralwraps key of
latex_elements['sphinxsetup']).

With pdflatex the dash "-" does not allow a linebreak when used with a
monospace font (btw the dash is escaped to \sphinxhyphen{} which expands
back to a dash).  But this failed with xelatex, so previous commits
ensured nobreak behaviour by redefining \sphinxhyphen to be
\sphinxhyphennobreak when encountered in inline and parsed literals.

This commit adds \sphinxhyphenin{inline,parsed}literal macros which
default to \sphinxhyphennobreak and thus allow to customize how the
dashes from sources will behave in such contexts in pdf output.
@jfbu jfbu changed the base branch from 4.3.x to 4.x December 9, 2021 17:14
@jfbu
Copy link
Contributor Author

jfbu commented Dec 9, 2021

thanks @tk0miya I have rebased on 4.x and will merge after testing completes

@jfbu jfbu merged commit e05741e into sphinx-doc:4.x Dec 9, 2021
@jfbu jfbu modified the milestones: 4.3.2, 4.4.0 Dec 9, 2021
@jfbu jfbu deleted the 9925_latex branch December 9, 2021 17:28
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Latex: do not allow splitting for :option: roles
3 participants