itutor-mathlive
Version:
Beautifully typeset math made easy
719 lines (597 loc) • 101 kB
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"><title>addons/maston.js - MathLive Docs</title><meta name="description" content="Beautifully typeset math made easy"><meta name="keywords" content="latex, tex, math, typesetting, documentation, docs">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700|Source+Sans+Pro:400,400i,700,900" rel="stylesheet">
<style>pre.prettyprint{background: #35434e;}</style>
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow-night.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
<link type="text/css" rel="stylesheet" href="styles/custom.css">
</head>
<body>
<div class="forkme"><a href="https://github.com/arnog/mathlive"><img style="position: absolute; top: 0; right: 0; border: 0; z-index:1;" src="https://camo.githubusercontent.com/52760788cde945287fbb584134c4cbc2bc36f904/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f77686974655f6666666666662e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png"></a></div>
<section role="navigation">
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav id="nav">
<h3 class="group-title home"><a href="index.html">MathLive Docs</a></h3><input class="search" placeholder="Search" type="text"><div class="list"><h3 class="group-title">Tutorials</h3><ul><li><a href="tutorial-CONTRIBUTOR_GUIDE.html">Contributor Guide</a></li><li><a href="tutorial-MASTON.html">MASTON</a></li><li><a href="tutorial-USAGE_GUIDE.html">Usage Guide</a></li></ul><h3 class="group-title">Classes</h3><ul><li class="private"><a href="Context.html" class="className">Context</a><ul class='methods private'><li data-type='method' class='private'><a href="Context.html#clone" class="methodName">clone</a></li><li data-type='method' class='private'><a href="Context.html#cloneWith" class="methodName">cloneWith</a></li><li data-type='method' class='private'><a href="Context.html#getBackgroundColor" class="methodName">getBackgroundColor</a></li><li data-type='method' class='private'><a href="Context.html#getColor" class="methodName">getColor</a></li><li data-type='method' class='private'><a href="Context.html#setMathstyle" class="methodName">setMathstyle</a></li><li data-type='method' class='private'><a href="Context.html#withMathstyle" class="methodName">withMathstyle</a></li></ul></li><li><a href="EditableMathlist.html" class="className">EditableMathlist</a><ul class='methods'><li data-type='method'><a href="EditableMathlist.html#_addCell" class="methodName">_addCell</a></li><li data-type='method'><a href="EditableMathlist.html#_deleteAtoms" class="methodName">_deleteAtoms</a></li><li data-type='method'><a href="EditableMathlist.html#addColumnAfter_" class="methodName">addColumnAfter_</a></li><li data-type='method'><a href="EditableMathlist.html#addColumnBefore_" class="methodName">addColumnBefore_</a></li><li data-type='method'><a href="EditableMathlist.html#addRowAfter_" class="methodName">addRowAfter_</a></li><li data-type='method'><a href="EditableMathlist.html#addRowBefore_" class="methodName">addRowBefore_</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#ancestor" class="methodName">ancestor</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#anchor" class="methodName">anchor</a></li><li data-type='method'><a href="EditableMathlist.html#applyStyle" class="methodName">applyStyle</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#commandOffsets" class="methodName">commandOffsets</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#commitCommandStringBeforeInsertionPoint" class="methodName">commitCommandStringBeforeInsertionPoint</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#contains" class="methodName">contains</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#decorateCommandStringAroundInsertionPoint" class="methodName">decorateCommandStringAroundInsertionPoint</a></li><li data-type='method'><a href="EditableMathlist.html#delete" class="methodName">delete</a></li><li data-type='method'><a href="EditableMathlist.html#delete_" class="methodName">delete_</a></li><li data-type='method'><a href="EditableMathlist.html#deleteAll_" class="methodName">deleteAll_</a></li><li data-type='method'><a href="EditableMathlist.html#deleteNextChar_" class="methodName">deleteNextChar_</a></li><li data-type='method'><a href="EditableMathlist.html#deleteNextWord_" class="methodName">deleteNextWord_</a></li><li data-type='method'><a href="EditableMathlist.html#deletePreviousChar_" class="methodName">deletePreviousChar_</a></li><li data-type='method'><a href="EditableMathlist.html#deletePreviousWord_" class="methodName">deletePreviousWord_</a></li><li data-type='method'><a href="EditableMathlist.html#deleteToGroupEnd_" class="methodName">deleteToGroupEnd_</a></li><li data-type='method'><a href="EditableMathlist.html#deleteToGroupStart_" class="methodName">deleteToGroupStart_</a></li><li data-type='method'><a href="EditableMathlist.html#deleteToMathFieldEnd_" class="methodName">deleteToMathFieldEnd_</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#endOffset" class="methodName">endOffset</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#extend" class="methodName">extend</a></li><li data-type='method'><a href="EditableMathlist.html#extendDown_" class="methodName">extendDown_</a></li><li data-type='method'><a href="EditableMathlist.html#extendToGroupEnd_" class="methodName">extendToGroupEnd_</a></li><li data-type='method'><a href="EditableMathlist.html#extendToGroupStart_" class="methodName">extendToGroupStart_</a></li><li data-type='method'><a href="EditableMathlist.html#extendToMathFieldEnd_" class="methodName">extendToMathFieldEnd_</a></li><li data-type='method'><a href="EditableMathlist.html#extendToMathFieldStart_" class="methodName">extendToMathFieldStart_</a></li><li data-type='method'><a href="EditableMathlist.html#extendToNextBoundary_" class="methodName">extendToNextBoundary_</a></li><li data-type='method'><a href="EditableMathlist.html#extendToNextChar_" class="methodName">extendToNextChar_</a></li><li data-type='method'><a href="EditableMathlist.html#extendToNextWord_" class="methodName">extendToNextWord_</a></li><li data-type='method'><a href="EditableMathlist.html#extendToPreviousBoundary_" class="methodName">extendToPreviousBoundary_</a></li><li data-type='method'><a href="EditableMathlist.html#extendToPreviousChar_" class="methodName">extendToPreviousChar_</a></li><li data-type='method'><a href="EditableMathlist.html#extendToPreviousWord_" class="methodName">extendToPreviousWord_</a></li><li data-type='method'><a href="EditableMathlist.html#extendUp_" class="methodName">extendUp_</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#extractCharactersBeforeInsertionPoint" class="methodName">extractCharactersBeforeInsertionPoint</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#extractCommandStringAroundInsertionPoint" class="methodName">extractCommandStringAroundInsertionPoint</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#extractContents" class="methodName">extractContents</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#extractContentsOrdInGroupBeforeInsertionPoint" class="methodName">extractContentsOrdInGroupBeforeInsertionPoint</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#filter" class="methodName">filter</a></li><li data-type='method'><a href="EditableMathlist.html#insert" class="methodName">insert</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#insertFirstAtom" class="methodName">insertFirstAtom</a></li><li data-type='method'><a href="EditableMathlist.html#isCollapsed" class="methodName">isCollapsed</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#jump" class="methodName">jump</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#leap" class="methodName">leap</a></li><li data-type='method'><a href="EditableMathlist.html#moveAfterParent_" class="methodName">moveAfterParent_</a></li><li data-type='method'><a href="EditableMathlist.html#moveBeforeParent_" class="methodName">moveBeforeParent_</a></li><li data-type='method'><a href="EditableMathlist.html#moveDown_" class="methodName">moveDown_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToGroupEnd_" class="methodName">moveToGroupEnd_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToGroupStart_" class="methodName">moveToGroupStart_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToMathFieldEnd_" class="methodName">moveToMathFieldEnd_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToMathFieldStart_" class="methodName">moveToMathFieldStart_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToNextChar_" class="methodName">moveToNextChar_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToNextPlaceholder_" class="methodName">moveToNextPlaceholder_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToNextWord_" class="methodName">moveToNextWord_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToOpposite_" class="methodName">moveToOpposite_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToPreviousChar_" class="methodName">moveToPreviousChar_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToPreviousPlaceholder_" class="methodName">moveToPreviousPlaceholder_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToPreviousWord_" class="methodName">moveToPreviousWord_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToSubscript_" class="methodName">moveToSubscript_</a></li><li data-type='method'><a href="EditableMathlist.html#moveToSuperscript_" class="methodName">moveToSuperscript_</a></li><li data-type='method'><a href="EditableMathlist.html#moveUp_" class="methodName">moveUp_</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#next" class="methodName">next</a></li><li data-type='method'><a href="EditableMathlist.html#selectAll_" class="methodName">selectAll_</a></li><li data-type='method'><a href="EditableMathlist.html#selectGroup_" class="methodName">selectGroup_</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#setExtent" class="methodName">setExtent</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#setRange" class="methodName">setRange</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#setSelection" class="methodName">setSelection</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#sibling" class="methodName">sibling</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#siblings" class="methodName">siblings</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#skip" class="methodName">skip</a></li><li data-type='method'><a href="EditableMathlist.html#speakAll_" class="methodName">speakAll_</a></li><li data-type='method'><a href="EditableMathlist.html#speakAllWithSynchronizedHighlighting_" class="methodName">speakAllWithSynchronizedHighlighting_</a></li><li data-type='method'><a href="EditableMathlist.html#speakGroup_" class="methodName">speakGroup_</a></li><li data-type='method'><a href="EditableMathlist.html#speakLeftSibling_" class="methodName">speakLeftSibling_</a></li><li data-type='method'><a href="EditableMathlist.html#speakParent_" class="methodName">speakParent_</a></li><li data-type='method'><a href="EditableMathlist.html#speakRightSibling_" class="methodName">speakRightSibling_</a></li><li data-type='method'><a href="EditableMathlist.html#speakSelection_" class="methodName">speakSelection_</a></li><li data-type='method'><a href="EditableMathlist.html#speakSelectionWithSynchronizedHighlighting_" class="methodName">speakSelectionWithSynchronizedHighlighting_</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#startOffset" class="methodName">startOffset</a></li><li data-type='method' class='private'><a href="EditableMathlist.html#toString" class="methodName">toString</a></li><li data-type='method'><a href="EditableMathlist.html#transpose_" class="methodName">transpose_</a></li></ul></li><li class="private"><a href="Lexer.html" class="className">Lexer</a><ul class='methods private'><li data-type='method' class='private'><a href="Lexer.html#end" class="methodName">end</a></li><li data-type='method' class='private'><a href="Lexer.html#get" class="methodName">get</a></li><li data-type='method' class='private'><a href="Lexer.html#isWhiteSpace" class="methodName">isWhiteSpace</a></li><li data-type='method' class='private'><a href="Lexer.html#makeToken" class="methodName">makeToken</a></li><li data-type='method' class='private'><a href="Lexer.html#peek" class="methodName">peek</a></li><li data-type='method' class='private'><a href="Lexer.html#scan" class="methodName">scan</a></li></ul></li><li class="private"><a href="MathAtom.html" class="className">MathAtom</a><ul class='methods private'><li data-type='method' class='private'><a href="MathAtom.html#.toSpeakableText" class="methodName">toSpeakableText</a></li><li data-type='method' class='private'><a href="MathAtom.html#bind" class="methodName">bind</a></li><li data-type='method' class='private'><a href="MathAtom.html#decompose" class="methodName">decompose</a></li><li data-type='method' class='private'><a href="MathAtom.html#decomposeGenfrac" class="methodName">decomposeGenfrac</a></li><li data-type='method' class='private'><a href="MathAtom.html#decomposeLeftright" class="methodName">decomposeLeftright</a></li><li data-type='method' class='private'><a href="MathAtom.html#decomposeLine" class="methodName">decomposeLine</a></li><li data-type='method' class='private'><a href="MathAtom.html#decomposeRule" class="methodName">decomposeRule</a></li><li data-type='method' class='private'><a href="MathAtom.html#filter" class="methodName">filter</a></li><li data-type='method' class='private'><a href="MathAtom.html#makeSpan" class="methodName">makeSpan</a></li></ul></li><li><a href="MathField.html" class="className">MathField</a><ul class='methods'><li data-type='method' class='private'><a href="MathField.html#_getCaretPosition" class="methodName">_getCaretPosition</a></li><li data-type='method' class='private'><a href="MathField.html#_onKeystroke" class="methodName">_onKeystroke</a></li><li data-type='method' class='private'><a href="MathField.html#complete_" class="methodName">complete_</a></li><li data-type='method'><a href="MathField.html#el" class="methodName">el</a></li><li data-type='method' class='private'><a href="MathField.html#enterCommandMode_" class="methodName">enterCommandMode_</a></li><li data-type='method'><a href="MathField.html#insert" class="methodName">insert</a></li><li data-type='method'><a href="MathField.html#keystroke" class="methodName">keystroke</a></li><li data-type='method'><a href="MathField.html#latex" class="methodName">latex</a></li><li data-type='method'><a href="MathField.html#perform" class="methodName">perform</a></li><li data-type='method'><a href="MathField.html#perform" class="methodName">perform</a></li><li data-type='method' class='private'><a href="MathField.html#render" class="methodName">render</a></li><li data-type='method'><a href="MathField.html#revertToOriginalContent" class="methodName">revertToOriginalContent</a></li><li data-type='method'><a href="MathField.html#selectedText" class="methodName">selectedText</a></li><li data-type='method'><a href="MathField.html#selectionAtEnd" class="methodName">selectionAtEnd</a></li><li data-type='method'><a href="MathField.html#selectionAtStart" class="methodName">selectionAtStart</a></li><li data-type='method'><a href="MathField.html#selectionDepth" class="methodName">selectionDepth</a></li><li data-type='method'><a href="MathField.html#selectionIsCollapsed" class="methodName">selectionIsCollapsed</a></li><li data-type='method'><a href="MathField.html#setConfig" class="methodName">setConfig</a></li><li data-type='method'><a href="MathField.html#text" class="methodName">text</a></li><li data-type='method'><a href="MathField.html#typedText" class="methodName">typedText</a></li></ul></li><li class="private"><a href="module-mathstyle.Mathstyle.html" class="className">Mathstyle</a></li><li class="private"><a href="Parser.html" class="className">Parser</a><ul class='methods private'><li data-type='method' class='private'><a href="Parser.html#end" class="methodName">end</a></li><li data-type='method' class='private'><a href="Parser.html#hasLiteral" class="methodName">hasLiteral</a></li><li data-type='method' class='private'><a href="Parser.html#hasLiteralPattern" class="methodName">hasLiteralPattern</a></li><li data-type='method' class='private'><a href="Parser.html#hasToken" class="methodName">hasToken</a></li><li data-type='method' class='private'><a href="Parser.html#lastMathAtom" class="methodName">lastMathAtom</a></li><li data-type='method' class='private'><a href="Parser.html#parseAtom" class="methodName">parseAtom</a></li><li data-type='method' class='private'><a href="Parser.html#parseKeyword" class="methodName">parseKeyword</a></li><li data-type='method' class='private'><a href="Parser.html#parseLimits" class="methodName">parseLimits</a></li><li data-type='method' class='private'><a href="Parser.html#parseSupSub" class="methodName">parseSupSub</a></li><li data-type='method' class='private'><a href="Parser.html#parseToken" class="methodName">parseToken</a></li><li data-type='method' class='private'><a href="Parser.html#scanArg" class="methodName">scanArg</a></li><li data-type='method' class='private'><a href="Parser.html#scanColor" class="methodName">scanColor</a></li><li data-type='method' class='private'><a href="Parser.html#scanDelim" class="methodName">scanDelim</a></li><li data-type='method' class='private'><a href="Parser.html#scanDimen" class="methodName">scanDimen</a></li><li data-type='method' class='private'><a href="Parser.html#scanEnvironment" class="methodName">scanEnvironment</a></li><li data-type='method' class='private'><a href="Parser.html#scanGroup" class="methodName">scanGroup</a></li><li data-type='method' class='private'><a href="Parser.html#scanImplicitGroup" class="methodName">scanImplicitGroup</a></li><li data-type='method' class='private'><a href="Parser.html#scanLeftRight" class="methodName">scanLeftRight</a></li><li data-type='method' class='private'><a href="Parser.html#scanModeSet" class="methodName">scanModeSet</a></li><li data-type='method' class='private'><a href="Parser.html#scanModeShift" class="methodName">scanModeShift</a></li><li data-type='method' class='private'><a href="Parser.html#scanNumber" class="methodName">scanNumber</a></li><li data-type='method' class='private'><a href="Parser.html#scanString" class="methodName">scanString</a></li><li data-type='method' class='private'><a href="Parser.html#scanToken" class="methodName">scanToken</a></li></ul></li><li class="private"><a href="Span.html" class="className">Span</a></li><li class="private"><a href="Token.html" class="className">Token</a></li><li class="private"><a href="UndoManager.html" class="className">UndoManager</a><ul class='methods private'><li data-type='method' class='private'><a href="UndoManager.html#canRedo" class="methodName">canRedo</a></li><li data-type='method' class='private'><a href="UndoManager.html#canUndo" class="methodName">canUndo</a></li><li data-type='method' class='private'><a href="UndoManager.html#redo" class="methodName">redo</a></li><li data-type='method' class='private'><a href="UndoManager.html#snapshot" class="methodName">snapshot</a></li><li data-type='method' class='private'><a href="UndoManager.html#undo" class="methodName">undo</a></li></ul></li></ul><h3 class="group-title">Modules</h3><ul><li class="private"><a href="module-color.html" class="className">color</a><ul class='methods private'><li data-type='method' class='private'><a href="module-color.html#.stringToColor" class="methodName">stringToColor</a></li></ul></li><li class="private"><a href="module-definitions.html" class="className">definitions</a><ul class='methods private'><li data-type='method' class='private'><a href="module-definitions.html#.defineEnvironment" class="methodName">defineEnvironment</a></li><li data-type='method' class='private'><a href="module-definitions.html#.defineFunction" class="methodName">defineFunction</a></li><li data-type='method' class='private'><a href="module-definitions.html#.defineSymbol" class="methodName">defineSymbol</a></li><li data-type='method' class='private'><a href="module-definitions.html#.defineSymbolRange" class="methodName">defineSymbolRange</a></li><li data-type='method' class='private'><a href="module-definitions.html#.defineSymbols" class="methodName">defineSymbols</a></li><li data-type='method' class='private'><a href="module-definitions.html#.frequency" class="methodName">frequency</a></li><li data-type='method' class='private'><a href="module-definitions.html#.getInfo" class="methodName">getInfo</a></li><li data-type='method' class='private'><a href="module-definitions.html#.matchCodepoint" class="methodName">matchCodepoint</a></li><li data-type='method' class='private'><a href="module-definitions.html#.matchFunction" class="methodName">matchFunction</a></li><li data-type='method' class='private'><a href="module-definitions.html#.parseParamTemplateArgument" class="methodName">parseParamTemplateArgument</a></li><li data-type='method' class='private'><a href="module-definitions.html#.suggest" class="methodName">suggest</a></li></ul></li><li class="private"><a href="module-delimiters.html" class="className">delimiters</a><ul class='methods private'><li data-type='method' class='private'><a href="module-delimiters.html#.makeCustomSizedDelim" class="methodName">makeCustomSizedDelim</a></li><li data-type='method' class='private'><a href="module-delimiters.html#.makeInner" class="methodName">makeInner</a></li><li data-type='method' class='private'><a href="module-delimiters.html#.makeLargeDelim" class="methodName">makeLargeDelim</a></li><li data-type='method' class='private'><a href="module-delimiters.html#.makeLeftRightDelim" class="methodName">makeLeftRightDelim</a></li><li data-type='method' class='private'><a href="module-delimiters.html#.makeNullFence" class="methodName">makeNullFence</a></li><li data-type='method' class='private'><a href="module-delimiters.html#.makeSizedDelim" class="methodName">makeSizedDelim</a></li><li data-type='method' class='private'><a href="module-delimiters.html#.makeSmallDelim" class="methodName">makeSmallDelim</a></li><li data-type='method' class='private'><a href="module-delimiters.html#.makeStackedDelim" class="methodName">makeStackedDelim</a></li><li data-type='method' class='private'><a href="module-delimiters.html#.traverseSequence" class="methodName">traverseSequence</a></li></ul></li><li class="private"><a href="module-editor_editableMathlist.html" class="className">editor/editableMathlist</a><ul class='methods private'><li data-type='method' class='private'><a href="module-editor_editableMathlist.html#~atomContains" class="methodName">atomContains</a></li></ul></li><li class="private"><a href="module-editor_keyboard.html" class="className">editor/keyboard</a><ul class='methods private'><li data-type='method' class='private'><a href="module-editor_keyboard.html#.delegateKeyboardEvents" class="methodName">delegateKeyboardEvents</a></li><li data-type='method' class='private'><a href="module-editor_keyboard.html#.keyboardEventToString" class="methodName">keyboardEventToString</a></li></ul></li><li class="private"><a href="module-editor_mathfield.html" class="className">editor/mathfield</a><ul class='methods private'><li data-type='method' class='private'><a href="module-editor_mathfield.html#nearestElementFromPoint" class="methodName">nearestElementFromPoint</a></li></ul></li><li class="private"><a href="module-editor_mathpath.html" class="className">editor/mathpath</a><ul class='methods private'><li data-type='method' class='private'><a href="module-editor_mathpath.html#.pathCommonAncestor" class="methodName">pathCommonAncestor</a></li><li data-type='method' class='private'><a href="module-editor_mathpath.html#.pathDistance" class="methodName">pathDistance</a></li><li data-type='method' class='private'><a href="module-editor_mathpath.html#.pathFromString" class="methodName">pathFromString</a></li><li data-type='method' class='private'><a href="module-editor_mathpath.html#.pathToString" class="methodName">pathToString</a></li></ul></li><li class="private"><a href="module-editor_shortcuts.html" class="className">editor/shortcuts</a><ul class='methods private'><li data-type='method' class='private'><a href="module-editor_shortcuts.html#.match" class="methodName">match</a></li><li data-type='method' class='private'><a href="module-editor_shortcuts.html#.matchKeystroke" class="methodName">matchKeystroke</a></li><li data-type='method' class='private'><a href="module-editor_shortcuts.html#.platform" class="methodName">platform</a></li><li data-type='method' class='private'><a href="module-editor_shortcuts.html#.stringify" class="methodName">stringify</a></li></ul></li><li class="private"><a href="module-fontMetrics.html" class="className">fontMetrics</a><ul class='methods private'><li data-type='method' class='private'><a href="module-fontMetrics.html#.getCharacterMetrics" class="methodName">getCharacterMetrics</a></li></ul></li><li class="private"><a href="module-lexer.html" class="className">lexer</a><ul class='methods private'><li data-type='method' class='private'><a href="module-lexer.html#.tokenize" class="methodName">tokenize</a></li></ul></li><li class="private"><a href="module-mathAtom.html" class="className">mathAtom</a><ul class='methods private'><li data-type='method' class='private'><a href="module-mathAtom.html#.decompose" class="methodName">decompose</a></li><li data-type='method' class='private'><a href="module-mathAtom.html#.getFontName" class="methodName">getFontName</a></li><li data-type='method' class='private'><a href="module-mathAtom.html#.makeColGap" class="methodName">makeColGap</a></li><li data-type='method' class='private'><a href="module-mathAtom.html#.makeColOfRepeatingElements" class="methodName">makeColOfRepeatingElements</a></li><li data-type='method' class='private'><a href="module-mathAtom.html#.makeStack" class="methodName">makeStack</a></li></ul></li><li><a href="module-mathlive.html" class="className">mathlive</a><ul class='methods'><li data-type='method'><a href="module-mathlive.html#latexToAST" class="methodName">latexToAST</a></li><li data-type='method'><a href="module-mathlive.html#latexToMarkup" class="methodName">latexToMarkup</a></li><li data-type='method'><a href="module-mathlive.html#latexToMathML" class="methodName">latexToMathML</a></li><li data-type='method'><a href="module-mathlive.html#latexToSpeakableText" class="methodName">latexToSpeakableText</a></li><li data-type='method'><a href="module-mathlive.html#makeMathField" class="methodName">makeMathField</a></li><li data-type='method'><a href="module-mathlive.html#pauseReadAloud" class="methodName">pauseReadAloud</a></li><li data-type='method'><a href="module-mathlive.html#playReadAloud" class="methodName">playReadAloud</a></li><li data-type='method'><a href="module-mathlive.html#readAloud" class="methodName">readAloud</a></li><li data-type='method'><a href="module-mathlive.html#readAloudStatus" class="methodName">readAloudStatus</a></li><li data-type='method'><a href="module-mathlive.html#renderMathInDocument" class="methodName">renderMathInDocument</a></li><li data-type='method'><a href="module-mathlive.html#renderMathInElement" class="methodName">renderMathInElement</a></li><li data-type='method'><a href="module-mathlive.html#resumeReadAloud" class="methodName">resumeReadAloud</a></li><li data-type='method'><a href="module-mathlive.html#revertToOriginalContent" class="methodName">revertToOriginalContent</a></li><li data-type='method'><a href="module-mathlive.html#revertToOriginalContent" class="methodName">revertToOriginalContent</a></li></ul></li><li class="private"><a href="module-mathstyle.html" class="className">mathstyle</a><ul class='methods private'><li data-type='method' class='private'><a href="module-mathstyle.html#.toMathstyle" class="methodName">toMathstyle</a></li></ul></li><li class="private"><a href="module-span.html" class="className">span</a><ul class='methods private'><li data-type='method' class='private'><a href="module-span.html#.coalesce" class="methodName">coalesce</a></li><li data-type='method' class='private'><a href="module-span.html#.makeFontSizer" class="methodName">makeFontSizer</a></li><li data-type='method' class='private'><a href="module-span.html#.makeHlist" class="methodName">makeHlist</a></li><li data-type='method' class='private'><a href="module-span.html#.makeSpan" class="methodName">makeSpan</a></li><li data-type='method' class='private'><a href="module-span.html#.makeSpanOfType" class="methodName">makeSpanOfType</a></li><li data-type='method' class='private'><a href="module-span.html#.makeSymbol" class="methodName">makeSymbol</a></li><li data-type='method' class='private'><a href="module-span.html#.makeVlist" class="methodName">makeVlist</a></li><li data-type='method' class='private'><a href="module-span.html#.toString" class="methodName">toString</a></li></ul></li></ul><label class="checkbox"><input id="toggle-private" type="checkbox" onclick="
if (!document.getElementById('toggle-private').checked) {
document.documentElement.classList.add('no-private')
writeCookie('symbol-access', 'no-private')
} else {
document.documentElement.classList.remove('no-private')
writeCookie('symbol-access', 'private')
}
">Include Private Symbols</input></label></div>
<footer role="contentInfo">
Made with <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>.
</footer>
</nav>
</section>
<main id="main">
<h1 class="page-title">addons/maston.js</h1>
<section>
<article>
<pre class="prettyprint source linenums">
<code>define([
'mathlive/core/lexer',
'mathlive/core/mathAtom',
'mathlive/core/parser',
'mathlive/core/definitions',
],
function(Lexer, MathAtom, ParserModule, Definitions) {
const CANONICAL_NAMES = {
// CONSTANTS
'\\imaginaryI': '\u2148',
'\\imaginaryJ': '\u2149',
'\\pi': 'π',
'\\exponentialE': '\u212f',
// ARITHMETIC
'﹢': '+', // SMALL PLUS SIGN
'+': '+', // FULL WIDTH PLUS SIGN
'−': '-', // MINUS SIGN
'-': '-', // HYPHEN-MINUS
'﹣': '-', // SMALL HYPHEN-MINUS
'-': '-', // FULLWIDTH HYPHEN-MINUS
'\\times': '*',
'⨉': '*', // N-ARY TIMES OPERATOR U+
'️✖': '*', // MULTIPLICATION SYMBOL
'️×': '*', // MULTIPLICATION SIGN
'.': '*',
'÷': '/', // DIVISION SIGN
// '/': '/', // SOLIDUS
'⁄': '/', // FRACTION SLASH
'/': '/', // FULLWIDTH SOLIDUS
'!': 'factorial',
'️\\pm': 'plusminus', // PLUS-MINUS SIGN
'\\mp': 'minusplus', // MINUS-PLUS SIGN
'\\land': 'and',
'\\wedge': 'and',
'\\lor': 'or',
'\\vee': 'or',
'\\oplus': 'xor',
'\\veebar': 'xor',
'\\lnot': 'not',
'\\neg': 'not',
'\\exists': 'exists',
'\\nexists': '!exists',
'\\forall': 'forAll',
'\\backepsilon': 'suchThat',
'\\therefore': 'therefore',
'\\because': 'because',
'\\nabla': 'nabla',
'\\circ': 'circle',
// '\\oplus': 'oplus',
'\\ominus': 'ominus',
'\\odot': 'odot',
'\\otimes': 'otimes',
'\\zeta': 'Zeta',
'\\Gamma': 'Gamma',
'\\min': 'min',
'\\max': 'max',
'\\mod': 'mod',
'\\lim': 'lim', // BIG OP
'\\sum': 'sum',
'\\prod': 'prod',
'\\int': 'integral',
'\\iint': 'integral2',
'\\iiint': 'integral3',
'\\Re': 'Re',
'\\gothicCapitalR': 'Re',
'\\Im': 'Im',
'\\gothicCapitalI': 'Im',
'\\binom': 'nCr',
'\\partial': 'partial',
'\\differentialD': 'differentialD',
'\\capitalDifferentialD': 'capitalDifferentialD',
'\\Finv': 'Finv',
'\\Game': 'Game',
'\\wp': 'wp',
'\\ast': 'ast',
'\\star': 'star',
'\\asymp': 'asymp',
// Function domain, limits
'\\to': 'to', // Looks like \rightarrow
'\\gets': 'gets', // Looks like \leftarrow
// Logic
'\\rightarrow': 'shortLogicalImplies',
'\\leftarrow': 'shortLogicalImpliedBy',
'\\leftrightarrow': 'shortLogicalEquivalent',
'\\longrightarrow': 'logicalImplies',
'\\longleftarrow': 'logicalImpliedBy',
'\\longleftrightarrow': 'logicalEquivalent',
// Metalogic
'\\Rightarrow': 'shortImplies',
'\\Leftarrow': 'shortImpliedBy',
'\\Leftrightarrow': 'shortEquivalent',
'\\implies': 'implies',
'\\Longrightarrow': 'implies',
'\\impliedby': 'impliedBy',
'\\Longleftarrow': 'impliedBy',
'\\iff': 'equivalent',
'\\Longleftrightarrow': 'equivalent',
}
const FUNCTION_TEMPLATE = {
// TRIGONOMETRY
'sin': '\\sin%_%^ %',
'cos': '\\cos%_%^ %',
'tan': '\\tan%_%^ %',
'cot': '\\cot%_%^ %',
'sec': '\\sec%_%^ %',
'csc': '\\csc%_%^ %',
'sinh': '\\sinh %',
'cosh': '\\cosh %',
'tanh': '\\tanh %',
'csch': '\\csch %',
'sech': '\\sech %',
'coth': '\\coth %',
'arcsin': '\\arcsin %',
'arccos': '\\arccos %',
'arctan': '\\arctan %',
'arccot': '\\arcctg %', // Check
'arcsec': '\\arcsec %',
'arccsc': '\\arccsc %',
'arsinh': '\\arsinh %',
'arcosh': '\\arcosh %',
'artanh': '\\artanh %',
'arcsch': '\\arcsch %',
'arsech': '\\arsech %',
'arcoth': '\\arcoth %',
// LOGARITHMS
'ln': '\\ln%_%^ %', // Natural logarithm
'log': '\\log%_%^ %', // General logarithm, e.g. log_10
'lg': '\\lg %', // Common, base-10, logarithm
'lb': '\\lb %', // Binary, base-2, logarithm
// Big operator
'sum': '\\sum%_%^ %',
// OTHER
'Zeta': '\\zeta%_%^ %', // Riemann Zeta function
'Gamma': '\\Gamma %', // Gamma function, such that Gamma(n) = (n - 1)!
'min': '\\min%_%^ %',
'max': '\\max%_%^ %',
'mod': '\\mod%_%^ %',
'lim': '\\lim%_%^ %', // BIG OP
'binom': '\\binom %',
'nabla': '\\nabla %',
'curl': '\\nabla\\times %',
'div': '\\nabla\\cdot %',
'floor': '\\lfloor % \\rfloor%_%^',
'ceil': '\\lceil % \\rceil%_%^',
'abs': '\\vert % \\vert%_%^',
'norm': '\\lVert % \\rVert%_%^',
'ucorner': '\\ulcorner % \\urcorner%_%^',
'lcorner': '\\llcorner % \\lrcorner%_%^',
'angle': '\\langle % \\rangle%_%^',
'group': '\\lgroup % \\rgroup%_%^',
'moustache':'\\lmoustache % \\rmoustache%_%^',
'brace': '\\lbrace % \\rbrace%_%^',
'sqrt': '\\sqrt[%^]{%}',
'lcm': '\\mathop{lcm}%',
'gcd': '\\mathop{gcd}%',
'erf': '\\mathop{erf}%',
'erfc': '\\mathop{erfc}%',
'randomReal': '\\mathop{randomReal}%',
'randomInteger': '\\mathop{randomInteger}%',
// Arithmetic operators
'*': '%0 \\times %1',
// Logic operators
'and': '%0 \\land %1',
'or': '%0 \\lor %1',
'xor': '%0 \\oplus %1',
'not': '%0 \\lnot %1',
// Other operators
'circle': '%0 \\circ %1',
'ast': '%0 \\ast %1',
'star': '%0 \\star %1',
'asymp': '%0 \\asymp %1',
'/': '\\frac{%0}{%1}',
'Re': '\\Re{%}',
'Im': '\\Im{%}',
'factorial': '%!',
'factorial2': '%!!',
}
// From www.w3.org/TR/MathML3/appendixc.html
const OP_PRECEDENCE = {
'degree': 880,
'nabla': 740,
'curl': 740, // not in MathML
'partial': 740,
'differentialD': 740, // not in MathML
'capitalDifferentialD': 740, // not in MathML
'odot': 710,
// Logical not
'not': 680,
// Division
'div': 660, // division sign
'solidus': 660,
'/': 660,
'setminus': 650, // \setminus, \smallsetminus
'%': 640,
'otimes': 410,
// Set operators
'union': 350, // \cup
'intersection': 350, // \cap
// Multiplication, division and modulo
'*': 390,
'ast': 390,
'.': 390,
'oplus': 300, // also logical XOR... @todo
'ominus': 300,
// Addition
'+': 275,
'-': 275,
'+-': 275, // \pm
'-+': 275, // \mp
// Most circled-ops are 265
'circle': 265,
'circledast': 265,
'circledcirc': 265,
'star': 265, // Different from ast
// Range
'..': 263, // Not in MathML
// Unit conversion
'to': 262, // Not in MathLM
'in': 262, // Not in MathML
// Relational
'=': 260,
'!=': 255,
'approx': 247,
'<': 245,
'>': 243,
'≥': 242,
'≤': 241,
// Set operator
'complement': 240,
'subset': 240, // \subset
'superset': 240, // \supset
// @todo and equality and neg operators
'elementof': 240, // \in
'!elementof': 240, // \notin
//
'exists': 230,
'!exists': 230,
'forall': 230,
// Logical operators
'and': 200,
'xor': 195, // MathML had 190
'or': 190,
// Note: 'not' is 680
// center, low, diag, vert ellipsis 150
// Composition/sequence
'suchThat': 110, // \backepsilon
':': 100,
// '..': 100,
// '...': 100,
// Conditional (?:)
// Assignement
':=': 80, // MathML had 260 (same with U+2254 COLON EQUALS)
'therefore': 70,
'because': 70,
// Arrows
// Note: MathML had 270 for the arrows, but this
// would not work for (a = b => b = a)
// See also https://en.wikipedia.org/wiki/Logical_connective#Order_of_precedence
// for a suggested precedence (note that in this page lower precedence
// has the opposite meaning as what we use)
'shortLogicalImplies': 52, // ->
'shortImplies': 51, // =>
'logicalImplies': 50, // -->
'implies': 49, // ==>
'shortLogicalImpliedBy': 48,// <-
'shortImpliedBy': 47, // <=
'logicalImpliedBy': 46, // <--
'impliedBy': 45, // <==
'shortLogicalEquivalent':44,// <->
'shortEquivalent': 43, // <=>
'logicalEquivalent':42, // <-->
'equivalent': 41, // <==>
',': 40,
';': 30
}
/**
* Given a canonical name, return its precedence
* @param {string} canonicalName, for example "and"
* @return {number}
*/
function getPrecedence(canonicalName) {
return canonicalName ? (OP_PRECEDENCE[canonicalName] || -1) : -1;
}
function getAssociativity(canonicalName) {
if (/=|=>/.test(canonicalName)) {
return 'right';
}
return 'left';
}
/**
*
* @param {string} name function canonical name
* @return {string}
*/
function getLatexTemplateForFunction(name) {
let result = FUNCTION_TEMPLATE[name];
if (!result) {
result = name.length > 1 ? '\\mathop{' + name + '} %' : (name + ' %');
}
return result;
}
/**
*
* @param {string} name symbol name
* @return {string}
*/
function getLatexForSymbol(name) {
let result = FUNCTION_TEMPLATE[name];
if (result) {
return result.replace('%1', '').replace('%0', '').replace('%', '');
}
const info = Definitions.getInfo('\\' + name, 'math');
if (info && info.type !== 'error' &&
(!info.fontFamily || info.fontFamily === 'main' || info.fontFamily === 'ams')) {
result = '\\' + name;
}
return result;
}
/**
*
* @param {string} name function or operator canonical name
* @return {string}
*/
function getLatexTemplateForOperator(name) {
let result = FUNCTION_TEMPLATE[name];
if (!result) {
result = '%0 \\mathbin{' + name + '} %1';
}
return result;
}
function isFunction(canonicalName) {
if (canonicalName === 'f' || canonicalName === 'g') return true;
let t = FUNCTION_TEMPLATE[canonicalName];
if (!t) return false;
// %0 and %1 are the lhs and rhs arguments. Remove those from the template
t = t.replace('%0', '').replace('%1', '');
// If we're left with a plain %, it's the argument list, and therefore
// this is a function.
if (/%/.test(t)) return true;
return false;
}
/**
*
* @param {string} latex, for example '\\times'
* @return {string} the canonical name for the input, for example '*'
*/
function getCanonicalName(latex) {
latex = (latex || '').trim();
let result = CANONICAL_NAMES[latex];
if (!result) {
if (latex.charAt(0) === '\\') {
const info = Definitions.getInfo(latex, 'math', {});
if (info && info.type !== 'error') {
result = info.value || latex.slice(1);
} else {
result = latex.slice(1);
}
} else {
result = latex;
}
}
return result;
}
/**
* Return the operator precedence of the atom
* or -1 if not an operator
* @param {*} atom
* @return {number}
*/
function opPrec(atom) {
if (!atom) return null;
const name = getCanonicalName(getString(atom));
const result = {
prec: getPrecedence(name),
assoc: getAssociativity(name)
}
if (result.prec <= 0) return null
return result;
}
function isOperator(atom) {
return opPrec(atom) !== null;
}
const DELIM_FUNCTION = {
'\\lfloor\\rfloor': 'floor',
'\\lceil\\rceil': 'ceil',
'\\vert\\vert': 'abs',
'\\lvert\\rvert': 'abs',
'||': 'abs',
'\\Vert\\Vert': 'norm',
'\\lVert\\rVert': 'norm',
'\\ulcorner\\urcorner': 'ucorner',
'\\llcorner\\lrcorner': 'lcorner',
'\\langle\\rangle': 'angle',
'\\lgroup\\rgroup': 'group',
'\\lmoustache\\rmoustache': 'moustache',
'\\lbrace\\rbrace': 'brace'
}
const POSTFIX_FUNCTION = {
'!': 'factorial',
'\\dag': 'dagger',
'\\dagger': 'dagger',
'\\ddager': 'dagger2',
'\\maltese': 'maltese',
'\\backprime': 'backprime',
'\\backdoubleprime': 'backprime2',
'\\prime': 'prime',
'\\doubleprime': 'prime2',
'\\$': '$',
'\\%': '%',
'\\_': '_',
'\\degree': 'degree'
}
const ASSOCIATIVE_FUNCTION = {
'+': '+',
'-': '+', // Substraction is add(), but it's
// handled specifically so that the
// argument is negated
'*': '*',
',': 'list',
';': 'list2',
'and': 'and',
'or': 'or',
'xor': 'xor',
'union': 'union',
// shortLogicalEquivalent and logicalEquivalent map to the same function
// they mean the same thing, but have a difference precedence.
'shortLogicalEquivalent': 'logicalEquivalent', // logical equivalent, iff, biconditional logical connective
'logicalEquivalent': 'logicalEquivalent', // same
// shortEquivalent and equivalent map to the same function
// they mean the same thing, but have a difference precedence.
'shortEquivalent': 'equivalent', // metalogic equivalent
'equivalent': 'equivalent', // same
}
const SUPER_ASSOCIATIVE_FUNCTION = {
',': 'list',
';': 'list2'
}
function getString(atom) {
if (atom.latex && atom.latex !== '\\mathop ' && atom.latex !== '\\mathbin ' &&
atom.latex !== '\\mathrel ' && atom.latex !== '\\mathopen ' &&
atom.latex !== '\\mathpunct ' && atom.latex !== '\\mathord ' &&
atom.latex !== '\\mathinner ' && atom.type !== 'font') {
return atom.latex.trim();
}
if (atom.type === 'leftright') {
return '';
}
if (typeof atom.body === 'string') {
return atom.body;
}
if (Array.isArray(atom.body)) {
let result = '';
for (const subAtom of atom.body) {
result += getString(subAtom);
}
return result;
}
return '';
}
/**
*
* @param {Object} expr -- Abstract Syntax Tree object
* @return {string} -- A string, the symbol, or undefined
*/
function asSymbol(expr) {
let result = expr;
if (typeof result !== 'string') {
result = expr !== undefined ? expr.sym : undefined;
}
if (result) {
const latex = getLatexForSymbol(result);
result = latex || result;
}
return result;
}
/**
*
* @param {Object} num -- Abstract Syntax Tree object
* @return {number} -- A Javascript number, the value of the AST or NaN
*/
function asMachineNumber(num) {
let result = undefined;
if (num !== undefined) {
if (num.num !== undefined) {
if (num.num.toString().match(/^[+-]?[0-9]*[.]?[0-9]*[eE]?[+-]?[0-9]?$/)) {
result = parseFloat(num.num);
}
} else if (typeof num === 'number') {
result = parseFloat(num);
}
}
return result;
}
function isNumber(expr) {
return typeof expr === 'number' ||
(expr !== undefined && expr.num !== undefined);
}
/**
* Return true if the current atom is of the specified type and value.
* @param {Object} expr
* @param {string} type
* @param {string} value
*/
function isAtom(expr, type, value) {
let result = false;
const atom = expr.atoms[expr.index];
if (atom && atom.type === type) {
if (value === undefined) {
result = true;
} else {
result = getString(atom) === value;
}
}
return result;
}
/**
* Return the negative of the expression. Usually {op:'-', lhs:expr}
* but for numbers, the negated number
* @param {*} expr
*/
function negate(expr) {
if (typeof expr === 'number') {
return -expr;
} else if (expr && typeof expr.num === 'number') {
expr.num = -expr.num;
return expr;
}
return {op:'-', lhs:expr};
}
/**
* Parse for a possible sup/sub at the current token location.
* Handles both sup/sub attached directly to the current atom
* as well as "empty" atoms with a sup/sub following the current
* atom.
* @param {Object} expr
*/
function parseSupsub(expr, options) {
let atom = expr.atoms[expr.index - 1];
// Is there a supsub directly on this atom?
if (!atom || !(atom.superscript || atom.subscript)) {
atom = null;
}
// Is the following atom a subsup atom?
if (!atom) {
atom = expr.atoms[expr.index];
if (isAtom(expr, 'msubsup') && (atom.superscript || atom.subscript)) {
expr.index += 1;
} else {
atom = null;
}
}
if (atom) {
if (typeof expr.ast === 'string') {