Skip to content

Commit 04353a0

Browse files
committed
Simplifis the oldstyle command table.
1 parent b30fd8d commit 04353a0

1 file changed

Lines changed: 27 additions & 14 deletions

File tree

ts/input/tex/textcomp/TextcompMappings.ts

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
*/
2424

2525

26-
import ParseMethods from '../ParseMethods.js';
2726
import {CharacterMap, CommandMap} from '../SymbolMap.js';
27+
import {Symbol} from '../Symbol.js';
2828
import {TexConstant} from '../TexConstants.js';
2929
import {TextMacrosMethods} from '../textmacros/TextMacrosMethods.js';
30+
import TexParser from '../TexParser.js';
3031

3132

3233
/**
@@ -160,25 +161,37 @@ new CommandMap('textcomp-macros', {
160161
}, TextMacrosMethods);
161162

162163

164+
/**
165+
* Handle old style characters.
166+
* @param {TexParser} parser The current tex parser.
167+
* @param {Symbol} mchar The parsed symbol.
168+
*/
169+
function mathchar0miOldstyle(parser: TexParser, mchar: Symbol) {
170+
const def = mchar.attributes || {};
171+
def.mathvariant = TexConstant.Variant.OLDSTYLE;
172+
const node = parser.create('token', 'mi', def, mchar.char);
173+
parser.Push(node);
174+
}
175+
163176
/**
164177
* Identifiers from the Textcomp package.
165178
*/
166-
new CharacterMap('textcomp-oldstyle', ParseMethods.mathchar0mi, {
179+
new CharacterMap('textcomp-oldstyle', mathchar0miOldstyle, {
167180

168181
// This is not the correct glyph
169-
'textcentoldstyle': ['\u00A2', {mathvariant: TexConstant.Variant.OLDSTYLE}],
182+
'textcentoldstyle': '\u00A2',
170183
// This is not the correct glyph
171-
'textdollaroldstyle': ['\u0024', {mathvariant: TexConstant.Variant.OLDSTYLE}],
184+
'textdollaroldstyle': '\u0024',
172185

173186
// Table 16: textcomp Old-Style Numerals
174-
'textzerooldstyle': ['0', {mathvariant: TexConstant.Variant.OLDSTYLE}],
175-
'textoneoldstyle': ['1', {mathvariant: TexConstant.Variant.OLDSTYLE}],
176-
'texttwooldstyle': ['2', {mathvariant: TexConstant.Variant.OLDSTYLE}],
177-
'textthreeoldstyle': ['3', {mathvariant: TexConstant.Variant.OLDSTYLE}],
178-
'textfouroldstyle': ['4', {mathvariant: TexConstant.Variant.OLDSTYLE}],
179-
'textfiveoldstyle': ['5', {mathvariant: TexConstant.Variant.OLDSTYLE}],
180-
'textsixoldstyle': ['6', {mathvariant: TexConstant.Variant.OLDSTYLE}],
181-
'textsevenoldstyle': ['7', {mathvariant: TexConstant.Variant.OLDSTYLE}],
182-
'texteightoldstyle': ['8', {mathvariant: TexConstant.Variant.OLDSTYLE}],
183-
'textnineoldstyle': ['9', {mathvariant: TexConstant.Variant.OLDSTYLE}]
187+
'textzerooldstyle': '0',
188+
'textoneoldstyle': '1',
189+
'texttwooldstyle': '2',
190+
'textthreeoldstyle': '3',
191+
'textfouroldstyle': '4',
192+
'textfiveoldstyle': '5',
193+
'textsixoldstyle': '6',
194+
'textsevenoldstyle': '7',
195+
'texteightoldstyle': '8',
196+
'textnineoldstyle': '9'
184197
});

0 commit comments

Comments
 (0)