Skip to content

Commit 3adc221

Browse files
authored
Merge pull request #724 from mathjax/textcomp_package
Textcomp package
2 parents a2da259 + 319487d commit 3adc221

9 files changed

Lines changed: 249 additions & 2 deletions

File tree

components/src/dependencies.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const dependencies = {
3030
'[tex]/require': ['input/tex-base'],
3131
'[tex]/setoptions': ['input/tex-base'],
3232
'[tex]/tagformat': ['input/tex-base'],
33+
'[tex]/textcomp': ['input/tex-base', '[tex]/textmacros'],
3334
'[tex]/textmacros': ['input/tex-base'],
3435
'[tex]/unicode': ['input/tex-base'],
3536
'[tex]/verb': ['input/tex-base'],
@@ -68,6 +69,7 @@ const allPackages = [
6869
'[tex]/require',
6970
'[tex]/setoptions',
7071
'[tex]/tagformat',
72+
'[tex]/textcomp',
7173
'[tex]/textmacros',
7274
'[tex]/unicode',
7375
'[tex]/verb',
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"component": "input/tex/extensions/textcomp",
3+
"targets": ["input/tex/textcomp"]
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './lib/textcomp.js';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const PACKAGE = require('../../../../../webpack.common.js');
2+
3+
module.exports = PACKAGE(
4+
'input/tex/extensions/textcomp', // the package to build
5+
'../../../../../../js', // location of the MathJax js library
6+
[ // packages to link to
7+
'components/src/input/tex/extensions/textmacros/lib',
8+
'components/src/input/tex-base/lib',
9+
'components/src/core/lib'
10+
],
11+
__dirname // our directory
12+
);

ts/input/tex/AllPackages.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import './noundefined/NoUndefinedConfiguration.js';
4949
import './physics/PhysicsConfiguration.js';
5050
import './setoptions/SetOptionsConfiguration.js';
5151
import './tagformat/TagFormatConfiguration.js';
52+
import './textcomp/TextcompConfiguration.js';
5253
import './textmacros/TextMacrosConfiguration.js';
5354
import './upgreek/UpgreekConfiguration.js';
5455
import './unicode/UnicodeConfiguration.js';
@@ -86,6 +87,7 @@ if (typeof MathJax !== 'undefined' && MathJax.loader) {
8687
'[tex]/verb',
8788
'[tex]/configmacros',
8889
'[tex]/tagformat',
90+
'[tex]/textcomp',
8991
'[tex]/textmacros',
9092
'[tex]/setoptions',
9193
);
@@ -120,5 +122,6 @@ export const AllPackages: string[] = [
120122
'verb',
121123
'configmacros',
122124
'tagformat',
125+
'textcomp',
123126
'textmacros'
124127
];

ts/input/tex/Configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export class ParserConfiguration {
331331
}
332332

333333
/**
334-
* Retrieves and adds configuration for a pacakge with priority.
334+
* Retrieves and adds configuration for a package with priority.
335335
* @param {(string | [string, number]} pkg Package with priority.
336336
*/
337337
public addPackage(pkg: (string | [string, number])) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*************************************************************
2+
*
3+
* Copyright (c) 2021 The MathJax Consortium
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
19+
/**
20+
* @fileoverview Configuration file for the textcomp package.
21+
*
22+
* @author v.sorge@mathjax.org (Volker Sorge)
23+
*/
24+
25+
import {Configuration} from '../Configuration.js';
26+
import './TextcompMappings.js';
27+
28+
29+
export const TextcompConfiguration = Configuration.create(
30+
'textcomp', {
31+
handler: {macro: ['textcomp-macros']}
32+
}
33+
);
34+
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
/*************************************************************
2+
*
3+
* Copyright (c) 2021 The MathJax Consortium
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
19+
/**
20+
* @fileoverview Mappings for the textcomp package.
21+
*
22+
* @author v.sorge@mathjax.org (Volker Sorge)
23+
*/
24+
25+
26+
import {CommandMap} from '../SymbolMap.js';
27+
import {TexConstant} from '../TexConstants.js';
28+
import {TextMacrosMethods} from '../textmacros/TextMacrosMethods.js';
29+
import TexParser from '../TexParser.js';
30+
import ParseUtil from '../ParseUtil.js';
31+
import {TextParser} from '../textmacros/TextParser.js';
32+
33+
34+
/**
35+
* Identifiers from the Textcomp package.
36+
*/
37+
new CommandMap('textcomp-macros', {
38+
39+
// Table 3: Predefined LATEX 2ε Text-Mode Commands
40+
'textasciicircum': ['Insert', '\u005E'],
41+
'textasciitilde': ['Insert', '\u007E'],
42+
'textasteriskcentered': ['Insert', '\u002A'],
43+
'textbackslash': ['Insert', '\u005C'],
44+
'textbar': ['Insert', '\u007C'],
45+
'textbraceleft': ['Insert', '\u007B'],
46+
'textbraceright': ['Insert', '\u007D'],
47+
'textbullet': ['Insert', '\u2022'],
48+
'textdagger': ['Insert', '\u2020'],
49+
'textdaggerdbl': ['Insert', '\u2021'],
50+
'textellipsis': ['Insert', '\u2026'],
51+
'textemdash': ['Insert', '\u2014'],
52+
'textendash': ['Insert', '\u2013'],
53+
'textexclamdown': ['Insert', '\u00A1'],
54+
'textgreater': ['Insert', '\u003E'],
55+
'textless': ['Insert', '\u003C'],
56+
'textordfeminine': ['Insert', '\u00AA'],
57+
'textordmasculine': ['Insert', '\u00BA'],
58+
'textparagraph': ['Insert', '\u00B6'],
59+
'textperiodcentered': ['Insert', '\u00B7'],
60+
'textquestiondown': ['Insert', '\u00BF'],
61+
'textquotedblleft': ['Insert', '\u201C'],
62+
'textquotedblright': ['Insert', '\u201D'],
63+
'textquoteleft': ['Insert', '\u2018'],
64+
'textquoteright': ['Insert', '\u2019'],
65+
'textsection': ['Insert', '\u00A7'],
66+
'textunderscore': ['Insert', '\u005F'],
67+
'textvisiblespace': ['Insert', '\u2423'],
68+
69+
// Table 12: textcomp Diacritics
70+
'textacutedbl': ['Insert', '\u02DD'],
71+
'textasciiacute': ['Insert', '\u00B4'],
72+
'textasciibreve': ['Insert', '\u02D8'],
73+
'textasciicaron': ['Insert', '\u02C7'],
74+
'textasciidieresis': ['Insert', '\u00A8'],
75+
'textasciimacron': ['Insert', '\u00AF'],
76+
'textgravedbl': ['Insert', '\u02F5'],
77+
'texttildelow': ['Insert', '\u02F7'],
78+
79+
// Table 13: textcomp Currency Symbols
80+
'textbaht': ['Insert', '\u0E3F'],
81+
'textcent': ['Insert', '\u00A2'],
82+
'textcolonmonetary': ['Insert', '\u20A1'],
83+
'textcurrency': ['Insert', '\u00A4'],
84+
'textdollar': ['Insert', '\u0024'],
85+
'textdong': ['Insert', '\u20AB'],
86+
'texteuro': ['Insert', '\u20AC'],
87+
'textflorin': ['Insert', '\u0192'],
88+
'textguarani': ['Insert', '\u20B2'],
89+
'textlira': ['Insert', '\u20A4'],
90+
'textnaira': ['Insert', '\u20A6'],
91+
'textpeso': ['Insert', '\u20B1'],
92+
'textsterling': ['Insert', '\u00A3'],
93+
'textwon': ['Insert', '\u20A9'],
94+
'textyen': ['Insert', '\u00A5'],
95+
96+
// Table 15: textcomp Legal Symbols
97+
'textcircledP': ['Insert', '\u2117'],
98+
'textcompwordmark': ['Insert', '\u200C'],
99+
'textcopyleft': ['Insert', '\u{1F12F}'],
100+
'textcopyright': ['Insert', '\u00A9'],
101+
'textregistered': ['Insert', '\u00AE'],
102+
'textservicemark': ['Insert', '\u2120'],
103+
'texttrademark': ['Insert', '\u2122'],
104+
105+
// Table 20: Miscellaneous textcomp Symbol
106+
'textbardbl': ['Insert', '\u2016'],
107+
'textbigcircle': ['Insert', '\u25EF'],
108+
'textblank': ['Insert', '\u2422'],
109+
'textbrokenbar': ['Insert', '\u00A6'],
110+
'textdiscount': ['Insert', '\u2052'],
111+
'textestimated': ['Insert', '\u212E'],
112+
'textinterrobang': ['Insert', '\u203D'],
113+
'textinterrobangdown': ['Insert', '\u2E18'],
114+
'textmusicalnote': ['Insert', '\u266A'],
115+
'textnumero': ['Insert', '\u2116'],
116+
'textopenbullet': ['Insert', '\u25E6'],
117+
'textpertenthousand': ['Insert', '\u2031'],
118+
'textperthousand': ['Insert', '\u2030'],
119+
'textrecipe': ['Insert', '\u211E'],
120+
'textreferencemark': ['Insert', '\u203B'],
121+
// 'textthreequartersemdash'
122+
// 'texttwelveudash'
123+
124+
// Table 51: textcomp Text-Mode Delimiters
125+
'textlangle': ['Insert', '\u2329'],
126+
'textrangle': ['Insert', '\u232A'],
127+
'textlbrackdbl': ['Insert', '\u27E6'],
128+
'textrbrackdbl': ['Insert', '\u27E7'],
129+
'textlquill': ['Insert', '\u2045'],
130+
'textrquill': ['Insert', '\u2046'],
131+
132+
// Table 62: textcomp Text-Mode Math and Science Symbols
133+
'textcelsius': ['Insert', '\u2103'],
134+
'textdegree': ['Insert', '\u00B0'],
135+
'textdiv': ['Insert', '\u00F7'],
136+
'textdownarrow': ['Insert', '\u2193'],
137+
'textfractionsolidus': ['Insert', '\u2044'],
138+
'textleftarrow': ['Insert', '\u2190'],
139+
'textlnot': ['Insert', '\u00AC'],
140+
'textmho': ['Insert', '\u2127'],
141+
'textminus': ['Insert', '\u2212'],
142+
'textmu': ['Insert', '\u00B5'],
143+
'textohm': ['Insert', '\u2126'],
144+
'textonehalf': ['Insert', '\u00BD'],
145+
'textonequarter': ['Insert', '\u00BC'],
146+
'textonesuperior': ['Insert', '\u00B9'],
147+
'textpm': ['Insert', '\u00B1'],
148+
'textrightarrow': ['Insert', '\u2192'],
149+
'textsurd': ['Insert', '\u221A'],
150+
'textthreequarters': ['Insert', '\u00BE'],
151+
'textthreesuperior': ['Insert', '\u00B3'],
152+
'texttimes': ['Insert', '\u00D7'],
153+
'texttwosuperior': ['Insert', '\u00B2'],
154+
'textuparrow': ['Insert', '\u2191'],
155+
156+
// Table 110: textcomp Genealogical Symbols
157+
'textborn': ['Insert', '\u002A'],
158+
'textdied': ['Insert', '\u2020'],
159+
'textdivorced': ['Insert', '\u26AE'],
160+
// 'textleaf'
161+
'textmarried': ['Insert', '\u26AD'],
162+
163+
// This is not the correct glyph
164+
'textcentoldstyle': ['Insert', '\u00A2', TexConstant.Variant.OLDSTYLE],
165+
// This is not the correct glyph
166+
'textdollaroldstyle': ['Insert', '\u0024', TexConstant.Variant.OLDSTYLE],
167+
168+
// Table 16: textcomp Old-Style Numerals
169+
'textzerooldstyle': ['Insert', '0', TexConstant.Variant.OLDSTYLE],
170+
'textoneoldstyle': ['Insert', '1', TexConstant.Variant.OLDSTYLE],
171+
'texttwooldstyle': ['Insert', '2', TexConstant.Variant.OLDSTYLE],
172+
'textthreeoldstyle': ['Insert', '3', TexConstant.Variant.OLDSTYLE],
173+
'textfouroldstyle': ['Insert', '4', TexConstant.Variant.OLDSTYLE],
174+
'textfiveoldstyle': ['Insert', '5', TexConstant.Variant.OLDSTYLE],
175+
'textsixoldstyle': ['Insert', '6', TexConstant.Variant.OLDSTYLE],
176+
'textsevenoldstyle': ['Insert', '7', TexConstant.Variant.OLDSTYLE],
177+
'texteightoldstyle': ['Insert', '8', TexConstant.Variant.OLDSTYLE],
178+
'textnineoldstyle': ['Insert', '9', TexConstant.Variant.OLDSTYLE]
179+
}, {
180+
Insert: function(parser: TexParser, name: string, c: string, font: string) {
181+
if (parser instanceof TextParser) {
182+
if (!font) {
183+
TextMacrosMethods.Insert(parser, name, c);
184+
return;
185+
}
186+
parser.saveText();
187+
}
188+
parser.Push(ParseUtil.internalText(
189+
parser, c, font ? {mathvariant: font} : {}));
190+
}
191+
});

ts/input/tex/textmacros/TextMacrosConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const TextMacrosConfiguration = Configuration.create('textmacros', {
114114
parseOptions.tags.configuration = parseOptions;
115115
//
116116
// Share the TeX input jax's parseOptions packageData object
117-
// so that require and other packagses will work in both parsers,
117+
// so that require and other packages will work in both parsers,
118118
// set the textmacros data (texParser will be filled in later),
119119
// and replace the internalMath function with our own.
120120
//

0 commit comments

Comments
 (0)