Skip to content

Commit

Permalink
Merge pull request #1073 from mathjax/textcomp-textmacros
Browse files Browse the repository at this point in the history
Make textcomp package register with textmacros automatically.
  • Loading branch information
dpvc committed Mar 16, 2024
2 parents b869096 + a803e44 commit 7a5dbdc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion ts/input/tex/textcomp/TextcompConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,19 @@
import {Configuration} from '../Configuration.js';
import './TextcompMappings.js';

Configuration.create('text-textcomp', {
parser: 'text',
handler: {macro: ['textcomp-macros']}
});

export const TextcompConfiguration = Configuration.create(
'textcomp', {
handler: {macro: ['textcomp-macros']}
handler: {macro: ['textcomp-macros']},
config(_config, jax) {
const {textConf, parseOptions} = jax.parseOptions.packageData.get('textmacros');
parseOptions.options.textmacros.packages.push('text-textcomp');
textConf.add('text-textcomp', jax, {});
}
}
);

4 changes: 3 additions & 1 deletion ts/input/tex/textmacros/TextMacrosConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import './TextMacrosMappings.js';
*/
export const TextBaseConfiguration = Configuration.create('text-base', {
parser: 'text',
priority: 1,
handler: {
character: ['command', 'text-special'],
macro: ['text-macros']
Expand Down Expand Up @@ -96,6 +97,7 @@ function internalMath(parser: TexParser, text: string, level?: number | string,
// The textmacros package configuration
//
export const TextMacrosConfiguration = Configuration.create('textmacros', {
priority: 1,
/**
* @param {ParserConfiguration} config The configuration object we are being configured within
* @param {TeX<any,any,any>} jax The TeX input jax in which we are running
Expand All @@ -120,7 +122,7 @@ export const TextMacrosConfiguration = Configuration.create('textmacros', {
// and replace the internalMath function with our own.
//
parseOptions.packageData = jax.parseOptions.packageData;
parseOptions.packageData.set('textmacros', {parseOptions, jax, texParser: null});
parseOptions.packageData.set('textmacros', {textConf, parseOptions, jax, texParser: null});
parseOptions.options.internalMath = internalMath;
},
preprocessors: [(data: {data: ParseOptions}) => {
Expand Down

0 comments on commit 7a5dbdc

Please sign in to comment.