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: fix #8686 Text can fall out of code-block at end of page #10577

Merged
merged 8 commits into from Jun 26, 2022

Conversation

jfbu
Copy link
Contributor

@jfbu jfbu commented Jun 18, 2022

This is short but deep hack into fancyvrb package which is used for legacy reasons by Sphinx LaTeX. It fixes #8686 issue in a way compatible with emphasized lines and line numbers. However it currently has breaking change that the line number is repeated identically for each piece of a wrapped line, whereas until now it is indicated only once, at the first line coming out from wrapped one.

edit: the breaking changed about code line numbers has been removed in a later commit. And WIP status was thus removed.

Keeping this as WIP for the moment as I need to do some more testing. And I am hesitating if the PR should be on master and not 5.x.

At the LaTeX level, I have made some internal name and interface changes for reasons of coherence but I feel it is very unlikely anyone actually modified or used the internal macros, so I don't consider this a breaking change.

Example of output (from the mwe at #8686):

(this was before removal of repeated code line number)

Capture d’écran 2022-06-18 à 23 30 44

On sees the number 2 is repeated all along. I can add some extras to not repeat but this means some complications. (update: done)

I think it is very unlikely fancyvrb (in view of its recent changes over the last years) will ever change the core stuff we hacked into, so it seems reasonably safe. Nevertheless it is deep hack and things work in a delicate equilibrium with fancvyvrb internal dealings.

Relates

@jfbu
Copy link
Contributor Author

jfbu commented Jun 19, 2022

Ready for review. In case of line wrapping the code line number is printed only once as is currently case. So this fixes #8686 with no other change to output.

Example output:
Capture d’écran 2022-06-19 à 10 02 23

From this project
8686_codeblock.zip

@jfbu jfbu marked this pull request as ready for review June 19, 2022 08:11
@jfbu jfbu added this to the 5.1.0 milestone Jun 19, 2022
@jfbu jfbu merged commit 40841ae into sphinx-doc:5.x Jun 26, 2022
@jfbu
Copy link
Contributor Author

jfbu commented Jun 26, 2022

The squashed commit message was written via the GitHub interface and is not hard-wrapped :-(

@jfbu jfbu deleted the latex_8686 branch June 26, 2022 08:34
jfbu added a commit to jfbu/sphinx that referenced this pull request Jun 29, 2022
This does not fix entirely sphinx-doc#10610 but it does sufficiently for it not to
require reverting sphinx-doc#10577 which tried to solve sphinx-doc#8686 conundrum.  In
extreme cases, the sphinx-doc#8686 problem meant that some contents disappearing
at page bottom, so it is probably better that to maintain sphinx-doc#10577 which
will avoid anysuch overflow of code beyond its frame, even though in
some specific cases (a colored entity such as a long string is partly on
both pages), some syntax highlighting gets lost.

There are anyhow other issues with colors for wrapped code lines, even
with no pagebreaks involved, such as sphinx-doc#10615.  This patch does not change
the situation there.
jfbu added a commit to jfbu/sphinx that referenced this pull request Jun 29, 2022
This does not fix entirely sphinx-doc#10610 but it does sufficiently for it not to
require reverting sphinx-doc#10577 which tried to solve sphinx-doc#8686 conundrum.  In
extreme cases, the sphinx-doc#8686 problem meant that some contents disappeared
at page bottom, so it is probably better to maintain sphinx-doc#10577 which
will avoid any such overflow of code beyond its frame, even though in
some specific cases (a colored entity such as a long string is partly on
both pages), some syntax highlighting gets lost.

There are anyhow other issues with colors for wrapped code lines, even
with no pagebreaks involved, such as sphinx-doc#10615.  This patch does not change
the situation there.
jfbu added a commit to jfbu/sphinx that referenced this pull request Jun 29, 2022
@jfbu
Copy link
Contributor Author

jfbu commented Jul 14, 2022

due to limitations of LaTeX \colorbox/\fcolorbox this required follow-up additions, which were concluded by merge of #10648 for 5.1.0 release

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 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] Text can fall out of code-block at end of page and leave artifact on next page
1 participant