Skip to content

Commit

Permalink
Add compatibility so old package names (and options) will still work …
Browse files Browse the repository at this point in the history
…after the renaming.
  • Loading branch information
dpvc committed May 9, 2020
1 parent f9ec3ca commit 194c7f2
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 1 deletion.
10 changes: 10 additions & 0 deletions components/src/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,13 @@ export const provides = {
],
'[tex]/all-packages': allPackages
};

//
// Compatibility with v3.0 names for TeX extensions
//
export const compatibility = {
'[tex]/amsCd': '[tex]/amscd',
'[tex]/colorV2': '[tex]/colorv2',
'[tex]/configMacros': '[tex]/configmacros',
'[tex]/tagFormat': '[tex]/tagformat'
};
3 changes: 3 additions & 0 deletions components/src/input/tex/extensions/amscd/amscd.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
import './lib/amscd.js';
import {rename} from '../../rename.js';

rename('amsCd', 'amscd', true);
3 changes: 3 additions & 0 deletions components/src/input/tex/extensions/colorv2/colorv2.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
import './lib/colorv2.js';
import {rename} from '../rename.js';

rename('colorV2', 'colorv2', false);
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
import './lib/configmacros.js';
import {rename} from '../rename.js';

rename('configMacros', 'configmacros', false);
16 changes: 16 additions & 0 deletions components/src/input/tex/extensions/rename.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Look for a package name in the package list and change it to a new name
// rhen rename tex options for it, if there are any.
//
export function rename(oname, nname, options) {
const tex = MathJax.config.tex;
if (tex && tex.packages) {
const packages = tex.packages;
const n = packages.indexOf(oname);
if (n >= 0) packages[n] = nname;
if (options && tex[oname]) {
tex[nname] = tex[oname];
delete tex[oname];
}
}
}
3 changes: 3 additions & 0 deletions components/src/input/tex/extensions/tagformat/tagformat.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
import './lib/tagformat.js';
import {rename} from '../rename.js';

rename('tagFormat', 'tagformat', true);
3 changes: 2 additions & 1 deletion components/src/startup/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import './lib/startup.js';

import {Loader, CONFIG} from '../../../js/components/loader.js';
import {combineDefaults} from '../../../js/components/global.js';
import {dependencies, paths, provides} from '../dependencies.js';
import {dependencies, paths, provides, compatibility} from '../dependencies.js';

combineDefaults(MathJax.config.loader, 'dependencies', dependencies);
combineDefaults(MathJax.config.loader, 'paths', paths);
combineDefaults(MathJax.config.loader, 'provides', provides);
combineDefaults(MathJax.config.loader, 'source', compatibility);

Loader.preLoad('loader');

Expand Down

0 comments on commit 194c7f2

Please sign in to comment.