-
Notifications
You must be signed in to change notification settings - Fork 218
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
Refactor to improve the user experience with non-ASCII characters #3206
Conversation
7d14bfc
to
807ed18
Compare
3d325e9
to
7f95045
Compare
The translated string. | ||
|
||
Examples | ||
-------- | ||
>>> non_ascii_to_octal("•‰“”±°ÿ") | ||
'\\31\\214\\216\\217\\261\\260\\377' | ||
>>> non_ascii_to_octal("αζΔΩ∑π∇") | ||
>>> non_ascii_to_octal("αζ∆Ω∑π∇") |
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.
In [19]: "Ω" == "Ω"
Out[19]: False
In [20]: "Δ" == "∆"
Out[20]: False
In [21]: import unicodedata
In [22]: unicodedata.name("Ω")
Out[22]: 'OHM SIGN'
In [23]: unicodedata.name("Ω")
Out[23]: 'GREEK CAPITAL LETTER OMEGA'
In [24]: unicodedata.name("Δ")
Out[24]: 'GREEK CAPITAL LETTER DELTA'
In [25]: unicodedata.name("∆")
Out[25]: 'INCREMENT'
We were using incorrect characters previously!
@@ -417,7 +417,7 @@ def test_text_nonascii(): | |||
fig.basemap(region=[0, 10, 0, 10], projection="X10c", frame=True) | |||
fig.text(position="TL", text="position-text:°α") # noqa: RUF001 | |||
fig.text(x=1, y=1, text="xytext:°α") # noqa: RUF001 | |||
fig.text(x=[5, 5], y=[3, 5], text=["xytext1:αζΔ❡", "xytext2:∑π∇✉"]) | |||
fig.text(x=[5, 5], y=[3, 5], text=["xytext1:αζ∆❡", "xytext2:∑π∇✉"]) |
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.
"Δ" != "∆"
.
charset["ZapfDingbats"] = dict( | ||
zip( | ||
[*range(0o040, 0o220), *range(0o240, 0o400)], | ||
"\u0020\u2701\u2702\u2703\u2704\u260e\u2706\u2707" |
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.
In previous version, we maintained a big dictionary like:
✁✂✃✄☎✆✇✈✉☛☞✌✍✎✏
but here I decide to use:
\u0020\u2701\u2702\u2703\u2704\u260e\u2706\u2707
The main reasons are:
- Avoid having too many non-ASCII characters in the source code
- Some non-ASCII characters can't be displayed correctly in text editors or GitHub web UI
For similar reasons, in the documentation, I use HTML syntax like
  | ✁ | ✂ | ✃ | ✄ | ☎ | ✆ | ✇ |
Co-authored-by: Yvonne Fröhlich <[email protected]>
@@ -0,0 +1,7 @@ | |||
# Technical Reference |
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.
As discussed in #2834, the documentation group is called "Technical Reference". Here the directory name is techref
. Please let me know if you're OK with the name.
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.
Yep, ok with the title name. We could maybe add a short paragraph under this title to mention what this page is about? Also would be good to link to https://docs.generic-mapping-tools.org/6.5/reference.html.
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.
Added in f2b3dcb.
Ping @GenericMappingTools/pygmt-maintainers for reviews and will self-approve and merge in one week if no further comments. |
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.
Just some minor typos and one suggestion on adding a short descriptive paragraph in the Technical Reference page. Haven't checked every single character in the tables, but I trust that they're ok 🙂
@@ -0,0 +1,7 @@ | |||
# Technical Reference |
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.
Yep, ok with the title name. We could maybe add a short paragraph under this title to mention what this page is about? Also would be good to link to https://docs.generic-mapping-tools.org/6.5/reference.html.
Co-authored-by: Wei Ji <[email protected]>
Co-authored-by: Wei Ji <[email protected]>
See #2204 (comment) for background and the issue.
This PR solves the issue by:
Preview:
The tables of supported encodings are at
https://pygmt-dev--3206.org.readthedocs.build/en/3206/techref/encodings.html.
This page is in the "Technical Reference" section, as discussed in #2834.
Note to maintainers
Below is the script used to generate the Markdown tables in the documentation