-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Let TeX handle multiline strings itself. #22360
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 tasks
rebased. |
QuLogic
reviewed
Feb 2, 2022
QuLogic
approved these changes
Feb 2, 2022
Is the failed doc build relevant? Moving to draft, feel free to move back when tests pass... |
Insert a `\special` at the end of the TeX output and record the baseline position there. This should be more robust than trying to guess the format of the dvi preamble, and more importantly this will also allow detecting the last baseline of *multiline* TeX output, which will then allow letting TeX handle multiline strings itself (while keeping the correct alignment).
Note that it may be worth passing the baselineskip (`Text.get_linespacing()`) as argument to texmanager, but that'll wait for a bigger refactor... for now, let's stick to the old default of 1.25. test_metrics_cache changes as the cache hit pattern changed for usetex strings.
This allows invalidating the cache when the source generation algorithm changes.
It seems spurious, but let's try again... |
jklymak
approved these changes
Mar 29, 2022
2 tasks
timhoffm
added a commit
that referenced
this pull request
Oct 2, 2022
Revert #22360: Let TeX handle multiline strings itself
meeseeksmachine
pushed a commit
to meeseeksmachine/matplotlib
that referenced
this pull request
Oct 2, 2022
… multiline strings itself
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
Previously, multiline strings were split at
\n
and passed one at a time to TeX -- likely, this is a remnant of how multiline strings are handled for the non-TeX case, as Matplotlib also renders one line at a time. This series of commits switches things to instead pass entire multiline strings all at once to TeX, which is useful e.g. if a tex font command must apply to arbitrary strings that may contain newlines. Goes on top of #22359.1st commit: Switch TeX baseline detection to use a dvi special.
Insert a
\special
at the end of the TeX output and record the baselineposition there. This should be more robust than trying to guess the
format of the dvi preamble, and more importantly this will also allow
detecting the last baseline of multiline TeX output, which will then
allow letting TeX handle multiline strings itself (while keeping the
correct alignment).
2nd commit: Let TeX handle newlines itself.
Note that it may be worth passing the baselineskip
(
Text.get_linespacing()
) as argument to texmanager, but that'll waitfor a bigger refactor... for now, let's stick to the old default of
1.25.
test_metrics_cache changes as the cache hit pattern changed for usetex
strings.
Edit: I suspect that the tests are failing on some builds because the tex cache needs to be invalidated (the minver test run is also the only one that clears the cache first). Will do something about that...
3rd commit: Pick TeX cache name based on entire TeX source.
This allows invalidating the cache when the source generation algorithm
changes.
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).