Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Don't insert spurious newlines by joining tex.preamble.#12805
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
The rc validator already makes it a single string.Also reject non-strings in the validator, as there isn't much use tothem anyways in this context.
Thanks! I forgot about that... |
elif isinstance(s, Iterable): | ||
return '\n'.join(s) | ||
else: | ||
raise TypeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The try-except seem unnecessary. Afaics, this can only come from the explicit raise and thus can be simplified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
No, it can also happen if s is not an iterable of strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ok.
There are no reasonable tests for this? |
I'm sure some could be added, but note that text.latex.preamble is "officially not supported". |
The current matplotlib.rcParams validator for the preamble splits thestring on commas. The resulting list is subsequently re-joined withnewlines, causing TeX to fail when the preamble contained commas (e.g.,key-value configuration of a package). Two pull requests switching to aproper TeX validator have been accepted and should be included whenmatplotlib 3.1.0 is released: *matplotlib/matplotlib#12674 *matplotlib/matplotlib#12805In the meantime, we can work around this by replacing the validator witha call to str.splitlines(). The workaround is implemented in afuture-proof manner as it is only installed if the TeX validator couldnot be imported, i.e., as soon as it is used with a version ofmatplotlib containing the validator the workaround should be ignored.This also adds a couple of unit tests which use the preamble to setcustom fonts. The font used is Cotham Sans, released under the SIL OpenFont License 1.1.
The rc validator already makes it a single string.
Also reject non-strings in the validator, as there isn't much use to
them anyways in this context.
Closes#12804, I think.
PR Summary
PR Checklist