Skip to content

Clarify set_parse_math documentation. #21472

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 1 commit into from
Oct 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,8 @@ def _preprocess_math(self, s):
- If *self* is configured to use TeX, return *s* unchanged except that
a single space gets escaped, and the flag "TeX".
- Otherwise, if *s* is mathtext (has an even number of unescaped dollar
signs), return *s* and the flag True.
signs) and ``parse_math`` is not set to False, return *s* and the
flag True.
- Otherwise, return *s* with dollar signs unescaped, and the flag
False.
"""
Expand Down Expand Up @@ -1281,21 +1282,18 @@ def get_usetex(self):

def set_parse_math(self, parse_math):
"""
Override switch to enable/disable any mathtext
parsing for the given `Text` object.
Override switch to disable any mathtext parsing for this `Text`.

Parameters
----------
parse_math : bool
Whether to consider mathtext parsing for the string
If False, this `Text` will never use mathtext. If True, mathtext
will be used if there is an even number of unescaped dollar signs.
"""
self._parse_math = bool(parse_math)

def get_parse_math(self):
"""
Return whether mathtext parsing is considered
for this `Text` object.
"""
"""Return whether mathtext parsing is considered for this `Text`."""
return self._parse_math

def set_fontname(self, fontname):
Expand Down