Skip to content

Commit 50b6e20

Browse files
committed
Old style map separately.
1 parent 86f6d63 commit 50b6e20

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

ts/input/tex/textcomp/TextcompMappings.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import {CharacterMap, CommandMap} from '../SymbolMap.js';
2727
import {Symbol} from '../Symbol.js';
2828
import {TexConstant} from '../TexConstants.js';
2929
import {TextMacrosMethods} from '../textmacros/TextMacrosMethods.js';
30+
import TexParser from '../TexParser.js';
31+
import ParseUtil from '../ParseUtil.js';
3032
import {TextParser} from '../textmacros/TextParser.js';
3133

3234

@@ -158,25 +160,40 @@ new CommandMap('textcomp-macros', {
158160
'textdivorced': ['Insert', '\u26AE'],
159161
// 'textleaf'
160162
'textmarried': ['Insert', '\u26AD']
161-
}, TextMacrosMethods);
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+
});
162172

163173

164174
/**
165175
* Handle old style characters.
166176
* @param {TextParser} parser The current tex parser.
167177
* @param {Symbol} mchar The parsed symbol.
168178
*/
169-
function mathchar0miOldstyle(parser: TextParser, 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);
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;
174191
}
175192

176193
/**
177194
* Identifiers from the Textcomp package.
178195
*/
179-
new CharacterMap('textcomp-oldstyle', mathchar0miOldstyle, {
196+
new CharacterMap('textcomp-oldstyle', oldstyleText, {
180197

181198
// This is not the correct glyph
182199
'textcentoldstyle': '\u00A2',

0 commit comments

Comments
 (0)