blob: 067b6a4c3a8075062b31b5fd8060ed3135273a37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
% File load-unicode-math-classes.tex
%
% Copyright 2015-2019 The LaTeX3 Project
%
% It may be distributed and/or modified under the conditions of
% the LaTeX Project Public License (LPPL), either version 1.3c of
% this license or (at your option) any later version. The latest
% version of this license is in the file
% http://www.latex-project.org/lppl.txt.
%
% Issues with this file should be reported at
% https://github.com/latex3/unicode-data
%
% This file parses MathClass.txt, provided by the Unicode Consortium, and sets
% up the following mapping between Unicode classes and TeX math types
% - "L" (large) \mathop
% - "B" (binary) \mathbin
% - "V" (vary) \mathbin
% - "R" (relation) \mathrel
% - "O" (opening) \mathopen
% - "C" (closing) \mathclose
% - "P" (punctuation) \mathpunct
% - "A" (alphabetic) \mathalpha
%
% For each code point processed, the result is of the form
%
% \Umathcode <codepoint> = <type> 1 <codepoint>
%
% =============================================================================
%
% The data can only be loaded by Unicode engines. Currently this is limited to
% XeTeX and LuaTeX, both of which define \Umathcode.
\ifx\Umathcode\undefined
\expandafter\endinput
\fi
% Just in case, check for the e-TeX extensions.
\ifx\eTeXversion\undefined
\expandafter\endinput
\fi
% This file can be loaded in IniTeX mode so the category codes of |{|, |}| and
% |#| may not be correct. Everything is done in a group so that only the
% settings we want to propagate are made available generally.
\begingroup
\catcode`\{=1 %
\catcode`\}=2 %
\catcode`\#=6 %
% Write some basic information to the log.
\catcode`\^=7 %
\newlinechar=`\^^J %
\message{^^J}%
\message{load-unicode-math-classes.tex v1.15 (2021-09-15)^^J}%
\message{Reading math class data^^J}%
% The parser for data lines starts by skipping any comments (which start with
% a |#| and which will be category code~$12$).
\edef\hash{\string#}%
\def\firsttoken#1#2\relax{#1}%
\def\parseunicodedataI#1\relax{%
\unless\if\hash\firsttoken#1?\relax
\parseunicodedataII#1\relax
\fi
}%
% The first entry in each data line is a code point or range of code points:
% set up to find a range if present.
\def\parseunicodedataII#1;#2\relax{%
\parseunicodedataIII#1....\relax{#2}%
}%
\def\parseunicodedataIII#1..#2..#3\relax#4{%
\ifx\relax#2\relax
\parseunicodedataIV{#1}{#1}#4\relax
\else
\parseunicodedataIV{#1}{#2}#4\relax
\fi
}%
% Examine the Unicode class and if known set up the math code appropriately.
\chardef\mathclassL=1 %
\chardef\mathclassB=2 %
\chardef\mathclassV=2 %
\chardef\mathclassR=3 %
\chardef\mathclassO=4 %
\chardef\mathclassC=5 %
\chardef\mathclassP=6 %
\chardef\mathclassA=7 %
\def\parseunicodedataIV#1#2#3#4\relax{%
\begingroup
\count0="#1 %
\loop
\unless\ifnum\count0>"#2 %
\ifcsname mathclass#3\endcsname
\global\Umathcode\count0=\csname mathclass#3\endcsname 1 \count0 %
\fi
\advance\count0 by 1 %
\repeat
\endgroup
}%
% From plain: may not be defined (yet).
\def\loop#1\repeat{\def\body{#1}\iterate}%
\def\iterate{%
\body
\let\next\iterate
\else
\let\next\relax
\fi
\next
}%
\let\repeat\fi
% Now we can load the data.
\catcode`\#=12 %
\def\storedpar{\par}%
\openin0=MathClass-15.txt %
\read0 to \unicodedataline
\message{\unicodedataline ^^J}%
\read0 to \unicodedataline
\message{\unicodedataline ^^J}%
\loop\unless\ifeof0 %
\read0 to \unicodedataline
\unless\ifx\unicodedataline\storedpar
\expandafter\parseunicodedataI\unicodedataline\relax
\fi
\repeat
\closein0 %
\endgroup
|