Repository navigation
FIX DateFormatter for month names when usetex=True - #19849
Conversation
3f8c0b4 to
6a417bc
Compare
63ba2ea to
5afc0f2
Compare
5afc0f2 to
5a8fc07
Compare
jklymak
left a comment
There was a problem hiding this comment.
This looks good to me @aitikgupta ? @anntzer ?
There was a problem hiding this comment.
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
pytestpasses).flake8on changed files to check).flake8-docstringsand 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).