Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
rebased. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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 baselineposition there. This should be more robust than trying to guess theformat of the dvi preamble, and more importantly this will also allowdetecting the last baseline of *multiline* TeX output, which will thenallow letting TeX handle multiline strings itself (while keeping thecorrect alignment).
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 of1.25.test_metrics_cache changes as the cache hit pattern changed for usetexstrings.
This allows invalidating the cache when the source generation algorithmchanges.
anntzer commentedMar 28, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
It seems spurious, but let's try again... |
Revert#22360: Let TeX handle multiline strings itself
… multiline strings itself
Uh oh!
There was an error while loading.Please reload this page.
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 ofmultiline 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).