|
| 1 | +import re |
1 | 2 | from docutils.parsers.rst import Directive |
2 | 3 |
|
3 | 4 | from matplotlib import _mathtext, _mathtext_data |
4 | 5 |
|
| 6 | +bb_pattern = re.compile("Bbb[A-Z]") |
| 7 | +scr_pattern = re.compile("scr[a-zA-Z]") |
| 8 | +frak_pattern = re.compile("frak[A-Z]") |
5 | 9 |
|
6 | 10 | symbols = [ |
7 | 11 | ["Lower-case Greek", |
|
18 | 22 | ["Hebrew", |
19 | 23 | 6, |
20 | 24 | (r"\aleph", r"\beth", r"\gimel", r"\daleth")], |
| 25 | + ["Latin named characters", |
| 26 | + 6, |
| 27 | + r"""\aa \AA \ae \AE \oe \OE \O \o \thorn \Thorn \ss \eth \dh \DH""".split()], |
21 | 28 | ["Delimiters", |
22 | 29 | 5, |
23 | 30 | _mathtext.Parser._delims], |
|
27 | 34 | ["Standard function names", |
28 | 35 | 5, |
29 | 36 | {fr"\{fn}" for fn in _mathtext.Parser._function_names}], |
30 | | - ["Binary operation and relation symbols", |
| 37 | + ["Binary operation symbols", |
| 38 | + 4, |
| 39 | + _mathtext.Parser._binary_operators], |
| 40 | + ["Relation symbols", |
31 | 41 | 4, |
32 | | - r"""\ast \pm \slash \cap \star \mp \cup \cdot \uplus |
33 | | - \triangleleft \circ \odot \sqcap \triangleright \bullet \ominus |
34 | | - \sqcup \bigcirc \oplus \wedge \diamond \oslash \vee |
35 | | - \bigtriangledown \times \otimes \dag \bigtriangleup \div \wr |
36 | | - \ddag \barwedge \veebar \boxplus \curlywedge \curlyvee \boxminus |
37 | | - \Cap \Cup \boxtimes \bot \top \dotplus \boxdot \intercal |
38 | | - \rightthreetimes \divideontimes \leftthreetimes \equiv \leq \geq |
39 | | - \perp \cong \prec \succ \mid \neq \preceq \succeq \parallel \sim |
40 | | - \ll \gg \bowtie \simeq \subset \supset \Join \approx \subseteq |
41 | | - \supseteq \ltimes \asymp \sqsubset \sqsupset \rtimes \doteq |
42 | | - \sqsubseteq \sqsupseteq \smile \propto \dashv \vdash \frown |
43 | | - \models \in \ni \notin \approxeq \leqq \geqq \lessgtr \leqslant |
44 | | - \geqslant \lesseqgtr \backsim \lessapprox \gtrapprox \lesseqqgtr |
45 | | - \backsimeq \lll \ggg \gtreqqless \triangleq \lessdot \gtrdot |
46 | | - \gtreqless \circeq \lesssim \gtrsim \gtrless \bumpeq \eqslantless |
47 | | - \eqslantgtr \backepsilon \Bumpeq \precsim \succsim \between |
48 | | - \doteqdot \precapprox \succapprox \pitchfork \Subset \Supset |
49 | | - \fallingdotseq \subseteqq \supseteqq \risingdotseq \sqsubset |
50 | | - \sqsupset \varpropto \preccurlyeq \succcurlyeq \Vdash \therefore |
51 | | - \curlyeqprec \curlyeqsucc \vDash \because \blacktriangleleft |
52 | | - \blacktriangleright \Vvdash \eqcirc \trianglelefteq |
53 | | - \trianglerighteq \neq \vartriangleleft \vartriangleright \ncong |
54 | | - \nleq \ngeq \nsubseteq \nmid \nsupseteq \nparallel \nless \ngtr |
55 | | - \nprec \nsucc \subsetneq \nsim \supsetneq \nVDash \precnapprox |
56 | | - \succnapprox \subsetneqq \nvDash \precnsim \succnsim \supsetneqq |
57 | | - \nvdash \lnapprox \gnapprox \ntriangleleft \ntrianglelefteq |
58 | | - \lneqq \gneqq \ntriangleright \lnsim \gnsim \ntrianglerighteq |
59 | | - \coloneq \eqsim \nequiv \napprox \nsupset \doublebarwedge \nVdash |
60 | | - \Doteq \nsubset \eqcolon \ne |
61 | | - """.split()], |
| 42 | + _mathtext.Parser._relation_symbols], |
62 | 43 | ["Arrow symbols", |
63 | 44 | 4, |
64 | | - r"""\leftarrow \longleftarrow \uparrow \Leftarrow \Longleftarrow |
65 | | - \Uparrow \rightarrow \longrightarrow \downarrow \Rightarrow |
66 | | - \Longrightarrow \Downarrow \leftrightarrow \updownarrow |
67 | | - \longleftrightarrow \updownarrow \Leftrightarrow |
68 | | - \Longleftrightarrow \Updownarrow \mapsto \longmapsto \nearrow |
69 | | - \hookleftarrow \hookrightarrow \searrow \leftharpoonup |
70 | | - \rightharpoonup \swarrow \leftharpoondown \rightharpoondown |
71 | | - \nwarrow \rightleftharpoons \leadsto \dashrightarrow |
72 | | - \dashleftarrow \leftleftarrows \leftrightarrows \Lleftarrow |
73 | | - \Rrightarrow \twoheadleftarrow \leftarrowtail \looparrowleft |
74 | | - \leftrightharpoons \curvearrowleft \circlearrowleft \Lsh |
75 | | - \upuparrows \upharpoonleft \downharpoonleft \multimap |
76 | | - \leftrightsquigarrow \rightrightarrows \rightleftarrows |
77 | | - \rightrightarrows \rightleftarrows \twoheadrightarrow |
78 | | - \rightarrowtail \looparrowright \rightleftharpoons |
79 | | - \curvearrowright \circlearrowright \Rsh \downdownarrows |
80 | | - \upharpoonright \downharpoonright \rightsquigarrow \nleftarrow |
81 | | - \nrightarrow \nLeftarrow \nRightarrow \nleftrightarrow |
82 | | - \nLeftrightarrow \to \Swarrow \Searrow \Nwarrow \Nearrow |
83 | | - \leftsquigarrow |
84 | | - """.split()], |
| 45 | + _mathtext.Parser._arrow_symbols], |
| 46 | + ["Dot symbols", |
| 47 | + 4, |
| 48 | + r"""\cdots \vdots \ldots \ddots \adots \Colon \therefore \because""".split()], |
| 49 | + ["Black-board characters", |
| 50 | + 6, |
| 51 | + [fr"\{symbol}" for symbol in _mathtext_data.tex2uni |
| 52 | + if re.match(bb_pattern, symbol)]], |
| 53 | + ["Script characters", |
| 54 | + 6, |
| 55 | + [fr"\{symbol}" for symbol in _mathtext_data.tex2uni |
| 56 | + if re.match(scr_pattern, symbol)]], |
| 57 | + ["Fraktur characters", |
| 58 | + 6, |
| 59 | + [fr"\{symbol}" for symbol in _mathtext_data.tex2uni |
| 60 | + if re.match(frak_pattern, symbol)]], |
85 | 61 | ["Miscellaneous symbols", |
86 | 62 | 4, |
87 | 63 | r"""\neg \infty \forall \wp \exists \bigstar \angle \partial |
88 | | - \nexists \measuredangle \eth \emptyset \sphericalangle \clubsuit |
| 64 | + \nexists \measuredangle \emptyset \sphericalangle \clubsuit |
89 | 65 | \varnothing \complement \diamondsuit \imath \Finv \triangledown |
90 | | - \heartsuit \jmath \Game \spadesuit \ell \hbar \vartriangle \cdots |
91 | | - \hslash \vdots \blacksquare \ldots \blacktriangle \ddots \sharp |
| 66 | + \heartsuit \jmath \Game \spadesuit \ell \hbar \vartriangle |
| 67 | + \hslash \blacksquare \blacktriangle \sharp \increment |
92 | 68 | \prime \blacktriangledown \Im \flat \backprime \Re \natural |
93 | | - \circledS \P \copyright \ss \circledR \S \yen \AA \checkmark \$ |
94 | | - \cent \triangle \QED \sinewave \nabla \mho""".split()] |
| 69 | + \circledS \P \copyright \circledR \S \yen \checkmark \$ |
| 70 | + \cent \triangle \QED \sinewave \dag \ddag \perthousand \ac |
| 71 | + \lambdabar \L \l \degree \danger \maltese \clubsuitopen |
| 72 | + \i \hermitmatrix \sterling \nabla \mho""".split()], |
95 | 73 | ] |
96 | 74 |
|
97 | 75 |
|
98 | 76 | def run(state_machine): |
99 | 77 |
|
100 | 78 | def render_symbol(sym, ignore_variant=False): |
101 | | - if ignore_variant and sym != r"\varnothing": |
| 79 | + if ignore_variant and sym not in (r"\varnothing", r"\varlrtriangle"): |
102 | 80 | sym = sym.replace(r"\var", "\\") |
103 | 81 | if sym.startswith("\\"): |
104 | 82 | sym = sym.lstrip("\\") |
105 | 83 | if sym not in (_mathtext.Parser._overunder_functions | |
106 | 84 | _mathtext.Parser._function_names): |
107 | 85 | sym = chr(_mathtext_data.tex2uni[sym]) |
108 | | - return f'\\{sym}' if sym in ('\\', '|') else sym |
| 86 | + return f'\\{sym}' if sym in ('\\', '|', '+', '-', '*') else sym |
109 | 87 |
|
110 | 88 | lines = [] |
111 | 89 | for category, columns, syms in symbols: |
@@ -165,7 +143,10 @@ def setup(app): |
165 | 143 | if sym[1:] not in _mathtext_data.tex2uni: |
166 | 144 | print(sym) |
167 | 145 |
|
| 146 | + # Add accents |
| 147 | + all_symbols.update({v[1:]: k for k, v in _mathtext.Parser._accent_map.items()}) |
| 148 | + all_symbols.update({v: v for v in _mathtext.Parser._wide_accents}) |
168 | 149 | print("SYMBOLS NOT IN TABLE:") |
169 | | - for sym in _mathtext_data.tex2uni: |
| 150 | + for sym, val in _mathtext_data.tex2uni.items(): |
170 | 151 | if sym not in all_symbols: |
171 | | - print(sym) |
| 152 | + print(f"{sym} = {chr(val)}") |
0 commit comments