Skip to content

Commit 194c7f2

Browse files
committed
Add compatibility so old package names (and options) will still work after the renaming.
1 parent f9ec3ca commit 194c7f2

File tree

7 files changed

+40
-1
lines changed

7 files changed

+40
-1
lines changed

components/src/dependencies.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,13 @@ export const provides = {
7777
],
7878
'[tex]/all-packages': allPackages
7979
};
80+
81+
//
82+
// Compatibility with v3.0 names for TeX extensions
83+
//
84+
export const compatibility = {
85+
'[tex]/amsCd': '[tex]/amscd',
86+
'[tex]/colorV2': '[tex]/colorv2',
87+
'[tex]/configMacros': '[tex]/configmacros',
88+
'[tex]/tagFormat': '[tex]/tagformat'
89+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
import './lib/amscd.js';
2+
import {rename} from '../../rename.js';
3+
4+
rename('amsCd', 'amscd', true);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
import './lib/colorv2.js';
2+
import {rename} from '../rename.js';
3+
4+
rename('colorV2', 'colorv2', false);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
import './lib/configmacros.js';
2+
import {rename} from '../rename.js';
3+
4+
rename('configMacros', 'configmacros', false);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Look for a package name in the package list and change it to a new name
3+
// rhen rename tex options for it, if there are any.
4+
//
5+
export function rename(oname, nname, options) {
6+
const tex = MathJax.config.tex;
7+
if (tex && tex.packages) {
8+
const packages = tex.packages;
9+
const n = packages.indexOf(oname);
10+
if (n >= 0) packages[n] = nname;
11+
if (options && tex[oname]) {
12+
tex[nname] = tex[oname];
13+
delete tex[oname];
14+
}
15+
}
16+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
import './lib/tagformat.js';
2+
import {rename} from '../rename.js';
3+
4+
rename('tagFormat', 'tagformat', true);

components/src/startup/startup.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import './lib/startup.js';
22

33
import {Loader, CONFIG} from '../../../js/components/loader.js';
44
import {combineDefaults} from '../../../js/components/global.js';
5-
import {dependencies, paths, provides} from '../dependencies.js';
5+
import {dependencies, paths, provides, compatibility} from '../dependencies.js';
66

77
combineDefaults(MathJax.config.loader, 'dependencies', dependencies);
88
combineDefaults(MathJax.config.loader, 'paths', paths);
99
combineDefaults(MathJax.config.loader, 'provides', provides);
10+
combineDefaults(MathJax.config.loader, 'source', compatibility);
1011

1112
Loader.preLoad('loader');
1213

0 commit comments

Comments
 (0)