-
Notifications
You must be signed in to change notification settings - Fork 227
Mathtools update #697
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
Mathtools update #697
Changes from all commits
a44ad18
a2f8364
7c4f3af
f12b24b
d27024f
4fe0239
b1915ea
75e3631
dafcfe1
7989667
46e88ec
cdc97af
435dad2
4a6ecbe
350af34
96bd2cf
b299037
3bf820c
34439e7
d5ec98e
88fed2f
ced45f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"component": "input/tex/extensions/mathtools", | ||
"targets": ["input/tex/mathtools"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './lib/mathtools.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const PACKAGE = require('../../../../../webpack.common.js'); | ||
|
||
module.exports = PACKAGE( | ||
'input/tex/extensions/mathtools', // the package to build | ||
'../../../../../../js', // location of the MathJax js library | ||
[ // packages to link to | ||
'components/src/input/tex/extensions/ams/lib', | ||
'components/src/input/tex/extensions/newcommand/lib', | ||
'components/src/input/tex-base/lib', | ||
'components/src/core/lib' | ||
], | ||
__dirname // our directory | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ import NodeUtil from './NodeUtil.js'; | |
import TexParser from './TexParser.js'; | ||
import TexError from './TexError.js'; | ||
import {entities} from '../../util/Entities.js'; | ||
import {MmlMunderover} from '../../core/MmlTree/MmlNodes/munderover.js'; | ||
import {em} from '../../util/lengths.js'; | ||
|
||
|
||
|
@@ -360,6 +361,40 @@ namespace ParseUtil { | |
return parser.create('node', 'mtext', [], def, textNode); | ||
} | ||
|
||
/** | ||
* Create an munderover node with the given script position. | ||
* @param {TexParser} parser The current TeX parser. | ||
* @param {MmlNode} base The base node. | ||
* @param {MmlNode} script The under- or over-script. | ||
* @param {string} pos Either 'over' or 'under'. | ||
* @param {boolean} stack True if super- or sub-scripts should stack. | ||
* @return {MmlNode} The generated node (MmlMunderover or TeXAtom) | ||
*/ | ||
export function underOver(parser: TexParser, base: MmlNode, script: MmlNode, pos: string, stack: boolean): MmlNode { | ||
// @test Overline | ||
const symbol = NodeUtil.getForm(base); | ||
if ((symbol && symbol[3] && symbol[3]['movablelimits']) || NodeUtil.getProperty(base, 'movablelimits')) { | ||
// @test Overline Sum | ||
NodeUtil.setProperties(base, {'movablelimits': false}); | ||
} | ||
if (NodeUtil.isType(base, 'munderover') && NodeUtil.isEmbellished(base)) { | ||
// @test Overline Limits | ||
NodeUtil.setProperties(NodeUtil.getCoreMO(base), {lspace: 0, rspace: 0}); | ||
const mo = parser.create('node', 'mo', [], {rspace: 0}); | ||
base = parser.create('node', 'mrow', [mo, base]); | ||
// TODO? add an empty <mi> so it's not embellished any more | ||
} | ||
const mml = parser.create('node', 'munderover', [base]) as MmlMunderover; | ||
NodeUtil.setChild(mml, pos === 'over' ? mml.over : mml.under, script); | ||
let node: MmlNode = mml; | ||
if (stack) { | ||
// @test Overbrace 1 2 3, Underbrace, Overbrace Op 1 2 | ||
node = parser.create('node', 'TeXAtom', [mml], {texClass: TEXCLASS.OP, movesupsub: true}); | ||
} | ||
NodeUtil.setProperty(node, 'subsupOK', true); | ||
return node; | ||
} | ||
|
||
/** | ||
* Trim spaces from a string. | ||
* @param {string} text The string to clean. | ||
|
@@ -391,7 +426,7 @@ namespace ParseUtil { | |
} else if (align === 'b') { | ||
array.arraydef.align = 'baseline -1'; | ||
} else if (align === 'c') { | ||
array.arraydef.align = 'center'; | ||
array.arraydef.align = 'axis'; | ||
} else if (align) { | ||
array.arraydef.align = align; | ||
} // FIXME: should be an error? | ||
|
@@ -458,6 +493,26 @@ namespace ParseUtil { | |
return s1 + s2; | ||
} | ||
|
||
/** | ||
* Report an error if there are too many macro substitutions. | ||
* @param {TexParser} parser The current TeX parser. | ||
* @param {boolean} isMacro True if we are substituting a macro, false for environment. | ||
*/ | ||
export function checkMaxMacros(parser: TexParser, isMacro: boolean = true) { | ||
if (++parser.macroCount <= parser.configuration.options['maxMacros']) { | ||
return; | ||
} | ||
if (isMacro) { | ||
throw new TexError('MaxMacroSub1', | ||
'MathJax maximum macro substitution count exceeded; ' + | ||
'is here a recursive macro call?'); | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for the else. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know that you prefer to reduce indentation when possible, but the indentation sometimes has meaning. In this case, the function will produce one of two error messages, neither of which is more important than the other. The indentation of both shows that they are comparable alternatives. Leaving out the "else" would make the second be the "main" message and the first be a subordinate one. It makes the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless you strongly object, I'd like to keep it as is. |
||
throw new TexError('MaxMacroSub2', | ||
'MathJax maximum substitution count exceeded; ' + | ||
'is there a recursive latex environment?'); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Check for bad nesting of equation environments | ||
|
@@ -513,8 +568,7 @@ namespace ParseUtil { | |
for (let key of Object.keys(def)) { | ||
if (!allowed.hasOwnProperty(key)) { | ||
if (error) { | ||
throw new TexError('InvalidOption', | ||
'Invalid optional argument: %1', key); | ||
throw new TexError('InvalidOption', 'Invalid option: %1', key); | ||
} | ||
delete def[key]; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.