-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX DateFormatter for month names when usetex=True #19849
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
Conversation
3f8c0b4
to
6a417bc
Compare
63ba2ea
to
5afc0f2
Compare
5afc0f2
to
5a8fc07
Compare
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.
This looks good to me @aitikgupta ? @anntzer ?
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.
Wouldn't this wrapping fail when we want TeX 'symbols' alongside the date?
For example, ≥ 12th May, 2021, or
≈ August, 2021
import datetime
date = datetime.datetime.today()
str_date = date.strftime('%m/%d/%Y')
label = r"\geq " + str_date
# or
# label = r"\approx " + str_date
_wrap_in_tex(label) -----> $\mathdefault{\}$geq$\mathdefault{ 05/12/2021}$
Whereas, previously it would've returned simply $\mathdefault{\geq 05/12/2021}$
.
I'm not sure if this is a valid usecase, or if _wrap_in_tex
is called like this, or even if this should be handled here, but if it is, it would probably mean adding a condition to escape characters if the word is starting with \
.
If not, this looks good!
Currently its just a private method for |
@aitikgupta Good instinct! However, in this case because this is an internal function to one of our modules and it is only used in our module, we can make more assumptions about the input (like it is only used in |
@meeseeksdev backport to v3.4.x |
…849-on-v3.4.x Backport PR #19849 on branch v3.4.x (FIX DateFormatter for month names when usetex=True)
PR Summary
close #19836
Although a little bit clumsy, this PR can serve as the interim solution to the format of month names when usetex=True. At a long term, some alternative way should be considered, as proposed by @anntzer.
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).