Skip to content

Commit 5f71a1d

Browse files
committed
Cleaned up version of textcomp.
1 parent 50b6e20 commit 5f71a1d

2 files changed

Lines changed: 27 additions & 50 deletions

File tree

ts/input/tex/textcomp/TextcompConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import './TextcompMappings.js';
2929
export const TextcompConfiguration = Configuration.create(
3030
'textcomp', {
3131
parser: 'tex',
32-
handler: {macro: ['textcomp-macros', 'textcomp-oldstyle']}
32+
handler: {macro: ['textcomp-macros']}
3333
}
3434
);
3535

ts/input/tex/textcomp/TextcompMappings.ts

Lines changed: 26 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
*/
2424

2525

26-
import {CharacterMap, CommandMap} from '../SymbolMap.js';
27-
import {Symbol} from '../Symbol.js';
26+
import {CommandMap} from '../SymbolMap.js';
2827
import {TexConstant} from '../TexConstants.js';
2928
import {TextMacrosMethods} from '../textmacros/TextMacrosMethods.js';
3029
import TexParser from '../TexParser.js';
@@ -159,56 +158,34 @@ new CommandMap('textcomp-macros', {
159158
'textdied': ['Insert', '\u2020'],
160159
'textdivorced': ['Insert', '\u26AE'],
161160
// 'textleaf'
162-
'textmarried': ['Insert', '\u26AD']
163-
}, {
164-
Insert: function(parser: TexParser, name: string, c: string) {
165-
if (parser instanceof TextParser) {
166-
TextMacrosMethods.Insert(parser, name, c);
167-
} else {
168-
parser.Push(ParseUtil.internalText(parser, c, {}));
169-
}
170-
}
171-
});
172-
173-
174-
/**
175-
* Handle old style characters.
176-
* @param {TextParser} parser The current tex parser.
177-
* @param {Symbol} mchar The parsed symbol.
178-
*/
179-
function oldstyleText(parser: TexParser, mchar: Symbol) {
180-
if (!(parser instanceof TextParser)) {
181-
parser.Push(ParseUtil.internalText(
182-
parser, mchar.char, {mathvariant: TexConstant.Variant.OLDSTYLE}));
183-
return;
184-
}
185-
if (parser.stack.env.mathvariant = TexConstant.Variant.OLDSTYLE) {
186-
parser.text += mchar.char;
187-
return;
188-
}
189-
TextMacrosMethods.SetFont(parser, mchar.symbol, TexConstant.Variant.OLDSTYLE);
190-
parser.text = mchar.char;
191-
}
192-
193-
/**
194-
* Identifiers from the Textcomp package.
195-
*/
196-
new CharacterMap('textcomp-oldstyle', oldstyleText, {
161+
'textmarried': ['Insert', '\u26AD'],
197162

198163
// This is not the correct glyph
199-
'textcentoldstyle': '\u00A2',
164+
'textcentoldstyle': ['Insert', '\u00A2', TexConstant.Variant.OLDSTYLE],
200165
// This is not the correct glyph
201-
'textdollaroldstyle': '\u0024',
166+
'textdollaroldstyle': ['Insert', '\u0024', TexConstant.Variant.OLDSTYLE],
202167

203168
// Table 16: textcomp Old-Style Numerals
204-
'textzerooldstyle': '0',
205-
'textoneoldstyle': '1',
206-
'texttwooldstyle': '2',
207-
'textthreeoldstyle': '3',
208-
'textfouroldstyle': '4',
209-
'textfiveoldstyle': '5',
210-
'textsixoldstyle': '6',
211-
'textsevenoldstyle': '7',
212-
'texteightoldstyle': '8',
213-
'textnineoldstyle': '9'
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+
}
214191
});

0 commit comments

Comments
 (0)