Skip to content

Commit

Permalink
Merge branch 'develop' into master for v3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed Sep 12, 2020
2 parents 3221300 + cc9e40c commit 0e98ab6
Show file tree
Hide file tree
Showing 20 changed files with 74 additions and 37 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');
}
5 changes: 5 additions & 0 deletions components/src/input/tex-full/tex-full.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './lib/tex-full.js';

import {registerTeX} from '../tex/register.js';
import {rename} from '../tex/extensions/rename.js';
import {Loader} from '../../../../js/components/loader.js';
import {AllPackages} from '../../../../js/input/tex/AllPackages.js';
import '../../../../js/input/tex/require/RequireConfiguration.js';
Expand All @@ -12,3 +13,7 @@ Loader.preLoad(
);

registerTeX(['require',...AllPackages]);
rename('amsCd', 'amscd', true);
rename('colorV2', 'colorv2', false);
rename('configMacros', 'configmacros', false);
rename('tagFormat', 'tagformat', true);
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mathjax-full",
"version": "3.1.0",
"version": "3.1.1",
"description": "Beautiful and accessible math in all browsers. MathJax is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all browsers and in server-side node applications. This package includes the source code as well as the packaged components.",
"license": "Apache-2.0",
"main": "components/src/node-main/node-main.js",
Expand Down Expand Up @@ -61,6 +61,6 @@
"dependencies": {
"esm": "^3.2.25",
"mj-context-menu": "^0.6.1",
"speech-rule-engine": "^3.1.0"
"speech-rule-engine": "^3.1.1"
}
}
2 changes: 1 addition & 1 deletion ts/components/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ if (typeof global.MathJax === 'undefined') {
*/
if (!(global.MathJax as MathJaxObject).version) {
global.MathJax = {
version: '3.0.5',
version: '3.1.1',
_: {},
config: global.MathJax
};
Expand Down
10 changes: 8 additions & 2 deletions ts/core/MathDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,9 @@ export abstract class AbstractMathDocument<N, T, D> implements MathDocument<N, T
* @override
*/
public convert(math: string, options: OptionList = {}) {
let {format, display, end, ex, em, containerWidth, lineWidth, scale} = userOptions({
let {format, display, end, ex, em, containerWidth, lineWidth, scale, family} = userOptions({
format: this.inputJax[0].name, display: true, end: STATE.LAST,
em: 16, ex: 8, containerWidth: null, lineWidth: 1000000, scale: 1
em: 16, ex: 8, containerWidth: null, lineWidth: 1000000, scale: 1, family: ''
}, options);
if (containerWidth === null) {
containerWidth = 80 * ex;
Expand All @@ -698,6 +698,12 @@ export abstract class AbstractMathDocument<N, T, D> implements MathDocument<N, T
const mitem = new this.options.MathItem(math, jax, display);
mitem.start.node = this.adaptor.body(this.document);
mitem.setMetrics(em, ex, containerWidth, lineWidth, scale);
if (this.outputJax.options.mtextInheritFont) {
mitem.outputData.mtextFamily = family;
}
if (this.outputJax.options.merrorInheritFont) {
mitem.outputData.merrorFamily = family;
}
mitem.convert(this, end);
return (mitem.typesetRoot || mitem.root);
}
Expand Down
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
8 changes: 5 additions & 3 deletions ts/input/tex/ParseUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,16 @@ namespace ParseUtil {
* @param {TexParser} parser The calling parser.
* @param {string} text The text in the math expression to parse.
* @param {number|string=} level The scriptlevel.
* @param {string} font The mathvariant to use
* @return {MmlNode[]} The nodes corresponding to the internal math expression.
*/
export function internalMath(parser: TexParser, text: string,
level?: number | string): MmlNode[] {
level?: number | string, font?: string): MmlNode[] {
if (parser.configuration.options.internalMath) {
return parser.configuration.options.internalMath(parser, text, level);
return parser.configuration.options.internalMath(parser, text, level, font);
}
let def = (parser.stack.env['font'] ? {mathvariant: parser.stack.env['font']} : {});
let mathvariant = font || parser.stack.env.font;
let def = (mathvariant ? {mathvariant} : {});
let mml: MmlNode[] = [], i = 0, k = 0, c, node, match = '', braces = 0;
if (text.match(/\\?[${}\\]|\\\(|\\(eq)?ref\s*\{/)) {
while (i < text.length) {
Expand Down
2 changes: 1 addition & 1 deletion ts/input/tex/TexParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export default class TexParser {
* @return {string} Get and return a control-sequence name
*/
public GetCS(): string {
let CS = this.string.slice(this.i).match(/^([a-z]+|[\uD800-\uDBFF].|.) ?/i);
let CS = this.string.slice(this.i).match(/^([a-z]+ ?|[\uD800-\uDBFF].|.)/i);
if (CS) {
this.i += CS[0].length;
return CS[1];
Expand Down
2 changes: 1 addition & 1 deletion ts/input/tex/amscd/AmsCdMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ AmsCdMethods.arrow = function(parser: TexParser, name: string) {
a = '\\kern ' + top.getProperty('minw');
} // minsize needs work
if (a || b) {
let pad: EnvList = {width: '+11mu', lspace: '6mu'};
let pad: EnvList = {width: '.67em', lspace: '.33em'};
mml = parser.create('node', 'munderover', [mml]) as MmlMunderover;
if (a) {
let nodeA = new TexParser(a, parser.stack.env, parser.configuration).mml();
Expand Down
6 changes: 5 additions & 1 deletion ts/input/tex/autoload/AutoloadConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ function Autoload(parser: TexParser, name: string, extension: string, isMacro: b
for (const env of envs) {
AutoloadEnvironments.remove(env);
}
parser.i -= name.length + (isMacro ? 0 : 7); // back up and read the macro or \begin again
//
// Put back the macro or \begin and read it again
//
parser.string = (isMacro ? name : '\\begin{' + name.slice(1) + '}' ) + parser.string.slice(parser.i);
parser.i = 0;
}
RequireLoad(parser, extension);
}
Expand Down
10 changes: 5 additions & 5 deletions ts/input/tex/base/BaseMappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,11 @@ new sm.CommandMap('macros', {
mathfrak: ['Macro', '{\\frak #1}', 1],
mathsf: ['Macro', '{\\sf #1}', 1],
mathtt: ['Macro', '{\\tt #1}', 1],
textrm: ['Macro', '\\mathord{\\rm\\text{#1}}', 1],
textit: ['Macro', '\\mathord{\\it\\text{#1}}', 1],
textbf: ['Macro', '\\mathord{\\bf\\text{#1}}', 1],
textsf: ['Macro', '\\mathord{\\sf\\text{#1}}', 1],
texttt: ['Macro', '\\mathord{\\tt\\text{#1}}', 1],
textrm: ['HBox', null, TexConstant.Variant.NORMAL],
textit: ['HBox', null, TexConstant.Variant.ITALIC],
textbf: ['HBox', null, TexConstant.Variant.BOLD],
textsf: ['HBox', null, TexConstant.Variant.SANSSERIF],
texttt: ['HBox', null, TexConstant.Variant.MONOSPACE],
pmb: ['Macro', '\\rlap{#1}\\kern1px{#1}', 1],
TeX: ['Macro', 'T\\kern-.14em\\lower.5ex{E}\\kern-.115em X'],
LaTeX: ['Macro', 'L\\kern-.325em\\raise.21em' +
Expand Down
5 changes: 3 additions & 2 deletions ts/input/tex/base/BaseMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,11 @@ BaseMethods.BuildRel = function(parser: TexParser, name: string) {
* @param {TexParser} parser The calling parser.
* @param {string} name The macro name.
* @param {string} style Box style.
* @param {string} font The mathvariant to use
*/
BaseMethods.HBox = function(parser: TexParser, name: string, style: string) {
BaseMethods.HBox = function(parser: TexParser, name: string, style: string, font?: string) {
// @test Hbox
parser.PushAll(ParseUtil.internalMath(parser, parser.GetArgument(name), style));
parser.PushAll(ParseUtil.internalMath(parser, parser.GetArgument(name), style, font));
};

/**
Expand Down
5 changes: 3 additions & 2 deletions ts/input/tex/textmacros/TextMacrosConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ export const textBase = Configuration.local({
* @param {TexParser} parser The TexParser calling this function
* @param {string} text The text-mode string to be processed
* @param {number|string} level The scriptlevel of the text
* @param {string} mathvariant The mathvariant for the text
* @return {MmlNode[]} The final MmlNode generated for the text
*/
function internalMath(parser: TexParser, text: string, level?: number | string): MmlNode[] {
function internalMath(parser: TexParser, text: string, level?: number | string, mathvariant?: string): MmlNode[] {
const config = parser.configuration.packageData.get('textmacros');
if (!(parser instanceof TextParser)) {
config.texParser = parser;
}
return [(new TextParser(text, {}, config.parseOptions, level)).mml()];
return [(new TextParser(text, mathvariant ? {mathvariant} : {}, config.parseOptions, level)).mml()];
}

//
Expand Down
2 changes: 2 additions & 0 deletions ts/input/tex/textmacros/TextMacrosMappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ new CommandMap('text-macros', {
'\\': 'SelfQuote',

'\'': ['Accent', '\u00B4'],
'\u2019': ['Accent', '\u00B4'],
'`': ['Accent', '\u0060'],
'\u2018': ['Accent', '\u0060'],
'^': ['Accent', '^'],
'\"': ['Accent', '\u00A8'],
'~': ['Accent', '~'],
Expand Down
3 changes: 2 additions & 1 deletion ts/input/tex/textmacros/TextMacrosMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ export const TextMacrosMethods = {
Spacer: BaseMethods.Spacer,
Hskip: BaseMethods.Hskip,
rule: BaseMethods.rule,
Rule: BaseMethods.Rule
Rule: BaseMethods.Rule,
HandleRef: BaseMethods.HandleRef

};

16 changes: 12 additions & 4 deletions ts/input/tex/textmacros/TextParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ export class TextParser extends TexParser {
return this.configuration.packageData.get('textmacros').texParser;
}

/**
* @override
*/
public get tags() {
return this.texParser.tags;
}

/**
* @override
* @constructor
Expand Down Expand Up @@ -99,10 +106,8 @@ export class TextParser extends TexParser {
*/
public saveText() {
if (this.text) {
const text = ParseUtil.internalText(this, this.text, {});
if (this.stack.env.mathvariant) {
NodeUtil.setAttribute(text, 'mathvariant', this.stack.env.mathvariant);
}
const mathvariant = this.stack.env.mathvariant;
const text = ParseUtil.internalText(this, this.text, mathvariant ? {mathvariant} : {});
this.text = '';
this.Push(text);
}
Expand Down Expand Up @@ -144,6 +149,9 @@ export class TextParser extends TexParser {
NodeUtil.setAttribute(mml, name, env[name]);
}
}
if (mml.isKind('inferredMrow')) {
mml = this.create('node', 'mrow', mml.childNodes);
}
this.nodes.push(mml);
}

Expand Down
2 changes: 1 addition & 1 deletion ts/mathjax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const mathjax = {
/**
* The MathJax version number
*/
version: '3.1.0',
version: '3.1.1',

/**
* The list of registers document handlers
Expand Down

0 comments on commit 0e98ab6

Please sign in to comment.