-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Escape # character in matplotlibrc #19288
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
Comments
Fixes matplotlib#19288 When parsing matplotlibrc files, the octothorpe ('#') indicates a comment. Escaping with '\#' allows the parameter value to contain '#'
I'd rather not expand the Instead, I propose to add quoted strings as proposed in #15813 (comment). Then you could do:
|
That sounds reasonable! Is that support for quoted strings being worked on? I can't find a (draft) PR for it, but I did find this now stale PR #9528 for a MEP32 from 3 years ago, which discusses different parsers/formats for matplotlibrc files. |
Currently, nobody is working on any of these. #9528 was discussed controversially and stalled at some point. From the likelihood of getting this forward, I'd estimate: quoted string support > YAML config > python-based config |
This enables using the comment character # within strings. Closes matplotlib#19288. Superseeds matplotlib#22565.
This enables using the comment character # within strings. Closes matplotlib#19288. Superseeds matplotlib#22565.
This enables using the comment character # within strings. Closes matplotlib#19288. Superseeds matplotlib#22565.
Problem
It currently seems impossible to escape the
#
character inside matplotlibrc files. I would like to include it as part of the parameter value fortext.latex.preamble
to add a LaTeX command definition such as\newcommand{\foo}[1]{\bar{#1}}
.When reading the file, each line is split at the
#
character and everything after it assumed as comment and thus discarded.Proposed Solution
One solution would be to replace the line
with a function that escapes
#
character(s). It would look something like this:Additional context and prior art
Potential other use cases:
text.latex.preamble
andpgf.preamble
: Not just limited to\newcommand
's#1
savefig.directory
: File paths might contain#
keymap
: the#
key cannot be remapped currentlyThe text was updated successfully, but these errors were encountered: