Skip to content

Commit

Permalink
Handle AsciiMath configuration properly, in particular, displastyle. (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed Sep 4, 2020
1 parent d4b8ff6 commit 43ef3d0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion components/src/input/asciimath/asciimath.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import './lib/asciimath.js';
import {AsciiMath} from '../../../../js/input/asciimath.js';

if (MathJax.startup) {
MathJax.Hub.Config({AsciiMath: MathJax.config.asciimath || {}});
MathJax.startup.registerConstructor('asciimath', AsciiMath);
MathJax.startup.useInput('asciimath');
}
2 changes: 1 addition & 1 deletion ts/input/asciimath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class AsciiMath<N, T, D> extends AbstractInputJax<N, T, D> {
* @override
*/
constructor(options: OptionList) {
let [am, find] = separateOptions(options, FindAsciiMath.OPTIONS);
let [ , find, am] = separateOptions(options, FindAsciiMath.OPTIONS, AsciiMath.OPTIONS);
super(am);
this.findAsciiMath = this.options['FindAsciiMath'] || new FindAsciiMath(find);
}
Expand Down
11 changes: 9 additions & 2 deletions ts/input/asciimath/mathjax2/input/AsciiMath.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
MathJax = Object.assign(global.MathJax || {}, require("../legacy/MathJax.js").MathJax);

//
// Load component-based configuration, if any
//
if (MathJax.config && MathJax.config.asciimath) {
MathJax.Hub.Config({AsciiMath: MathJax.config.asciimath});
}

MathJax.Ajax.Preloading(
"[MathJax]/jax/input/AsciiMath/config.js",
"[MathJax]/jax/input/AsciiMath/jax.js",
Expand All @@ -18,12 +25,12 @@ var factory = new MmlFactory();
exports.LegacyAsciiMath = {
Compile: function (am,display) {
var script = {
type:"math/asciimath",
type: "math/asciimath",
innerText: am,
MathJax: {}
};
var node = MathJax.InputJax.AsciiMath.Translate(script).root.toMmlNode(factory);
node.setInheritedAttributes();
node.setInheritedAttributes({}, display, 0, false);
return node;
},
Translate: function (am,display) {
Expand Down
1 change: 1 addition & 0 deletions ts/input/asciimath/mathjax2/legacy/jax/element/MmlNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
if (copy[names[i]] === 1 && !defaults.hasOwnProperty(names[i])) continue;
value = (this.attr||{})[names[i]];
if (value == null) value = this[names[i]];
if (value === 'true' || value === 'false') value = (value === 'true');
if (value != null) node.attributes.set(names[i],value);
}
},
Expand Down

0 comments on commit 43ef3d0

Please sign in to comment.