Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make textcomp package register with textmacros automatically. #1073

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for the priority?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was so that the base configuration is done first and then others that override anything in it don't need to specify their own priorities. But I think that the packages may be processed in reverse order, which means I should make this 10 instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked, and this does mean text-base will have its init() and config() methods called before the other configurations. So that means the default priority of 5 will put others after this, without having to set the priority.

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