UNPKG

itutor-mathlive

Version:

Beautifully typeset math made easy

659 lines (555 loc) 144 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"><title>core/definitions.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">core/definitions.js</h1> <section> <article> <pre class="prettyprint source linenums"> <code>/*global require:false*/ /*global define:false*/ /* eslint max-len: 0 */ // TODO // Some missing greek letters, but see https://reference.wolfram.com/language/tutorial/LettersAndLetterLikeForms.html // koppa, stigma, Sampi // See https://tex.stackexchange.com/questions/231878/accessing-archaic-greek-koppa-in-the-birkmult-document-class // Capital Alpha, etc... // Colon (ratio) (2236) // Function names can have '*' in them // Review: // https://en.wikipedia.org/wiki/Help:Displaying_a_formula // https://reference.wolfram.com/language/tutorial/LettersAndLetterLikeForms.html // ftp://ftp.dante.de/tex-archive/info/symbols/comprehensive/symbols-a4.pdf // Media Wiki Reference // https://en.wikipedia.org/wiki/Help:Displaying_a_formula // MathJax Reference // http://docs.mathjax.org/en/latest/tex.html#supported-latex-commands // http://www.onemathematicalcat.org/MathJaxDocumentation/TeXSyntax.htm // LaTeX Reference // http://ctan.sharelatex.com/tex-archive/info/latex2e-help-texinfo/latex2e.html // iBooks Author/Pages // https://support.apple.com/en-au/HT202501 // Mathematica Reference // https://reference.wolfram.com/language/tutorial/NamesOfSymbolsAndMathematicalObjects.html // https://reference.wolfram.com/language/guide/MathematicalTypesetting.html /* * @todo \sb (equivalent to _) $\mathfrak{sl}\sb 2$ frequency 184 * @todo \sp (equivalent to ^) $\mathfrak{sl}\sp 2$ frequency 274 * \intertext frequency 0 See http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/mathtools/mathtools.pdf */ /** * This module contains the definitions of all the symbols and commands, for * example `\alpha`, `\sin`, `\mathrm`. * There are a few exceptions with some "built-in" commands that require * special parsing such as `\char`. * @module definitions * @private */ define(['mathlive/core/fontMetrics'], function(FontMetrics) { /** * To organize the symbols when generating the documentation, we * keep track of a category that gets assigned to each symbol. * @private */ let category = ''; // itutor modification let VARIABLE_GETTER = undefined; let EXPRESSION_GETTER = undefined; const TEXT_SYMBOLS = {}; const MATH_SYMBOLS = {}; const COMMAND_SYMBOLS = {}; const FUNCTIONS = {}; const ENVIRONMENTS = {}; const MACROS = { 'iff': '\\;\u27fa\\;', //>2,000 Note: additional spaces around the arrows 'nicefrac': '^{#1}\\!\\!/\\!_{#2}', // From bracket.sty, Diract notation 'bra': '\\mathinner{\\langle{#1}|}', 'ket': '\\mathinner{|{#1}\\rangle}', 'braket': '\\mathinner{\\langle{#1}\\rangle}', 'set': '\\mathinner{\\lbrace #1 \\rbrace}', 'Bra': '\\left\\langle #1\\right|', 'Ket': '\\left|#1\\right\\rangle', 'Braket': '\\left\\langle{#1}\\right\\rangle', 'Set': '\\left\\lbrace #1 \\right\\rbrace', }; const RIGHT_DELIM = { '(': ')', '{': '}', '[': ']', '|': '|', '\\lbrace': '\\rbrace', '\\{': '\\}', '\\langle': '\\rangle', '\\lfloor': '\\rfloor', '\\lceil': '\\rceil', '\\vert': '\\vert', '\\lvert': '\\rvert', '\\Vert': '\\Vert', '\\lVert': '\\rVert', '\\lbrack': '\\rbrack', '\\ulcorner': '\\urcorner', '\\llcorner': '\\lrcorner', '\\lgroup': '\\rgroup', '\\lmoustache': '\\rmoustache' } // Frequency of a symbol. // String constants corresponding to frequency values, // which are the number of results returned by latexsearch.com // When the precise number is known, it is provided. Otherwise, // the following constants are used to denote an estimate. const CRYPTIC = 'CRYPTIC'; const ARCANE = 'ARCANE'; // const VERY_RARE = 'VERY_RARE'; const RARE = 'RARE'; const UNCOMMON = 'UNCOMMON'; const COMMON = 'COMMON'; const SUPERCOMMON = 'SUPERCOMMON'; /** * @type {object.&lt;string, number>} * @private */ const FREQUENCY_VALUE = { 'CRYPTIC': 0, 'ARCANE': 200, 'VERY_RARE': 600, 'RARE': 1200, 'UNCOMMON': 2000, 'COMMON': 3000, 'SUPERCOMMON': 4000 } /** * Set the frequency of the specified symbol. * Default frequency is UNCOMMON * The argument list is a frequency value, followed by one or more symbol strings * For example: * frequency(COMMON , '\\sin', '\\cos') * @param {string|number} value The frequency as a string constant, * or a numeric value [0...2000] * @param {?} * @memberof module:definitions * @private */ function frequency(value, ...symbols) { const v = typeof value === 'string' ? FREQUENCY_VALUE[value] : value; for (const symbol of symbols) { if (TEXT_SYMBOLS[symbol]) { TEXT_SYMBOLS[symbol].frequency = v; } if (MATH_SYMBOLS[symbol]) { MATH_SYMBOLS[symbol].frequency = v; } if (FUNCTIONS[symbol]) { // Make a copy of the entry, since it could be shared by multiple // symbols FUNCTIONS[symbol] = Object.assign({}, FUNCTIONS[symbol]); FUNCTIONS[symbol].frequency = v; } } } /** * * @param {string} latexName The common LaTeX command for this symbol * @param {(string|string[])} mode * @param {string} fontFamily * @param {string} type * @param {string} value * @param {(number|string)} [frequency] * @memberof module:definitions * @private */ function defineSymbol(latexName, mode, fontFamily, type, value, frequency) { console.assert(fontFamily === 'main' || fontFamily === 'ams' || fontFamily === 'mathrm' || fontFamily === 'mathbb' || fontFamily === 'mathfrak' || fontFamily === 'mathcal' || fontFamily === 'mathscr' || Array.isArray(fontFamily), "Unknown font family " + fontFamily + " for " + latexName); // Convert a frequency constant to a numerical value if (typeof frequency === 'string') frequency = FREQUENCY_VALUE[frequency]; if (mode.includes(TEXT)) { TEXT_SYMBOLS[latexName] = { symbol: true, category: category, // To group items when generating the documentation fontFamily: fontFamily, type: type === ORD ? TEXTORD : type, skipBoundary: true, body: value, frequency: frequency }; } if (mode.includes(MATH)) { MATH_SYMBOLS[latexName] = { symbol: true, category: category, // To group items when generating the documentation fontFamily: fontFamily, type: type === ORD ? MATHORD : type, skipBoundary: true, value: value, frequency: frequency }; } if (mode.includes(COMMAND)) { COMMAND_SYMBOLS[latexName] = { fontFamily: fontFamily, type: type, value: value}; } } /** * Define a set of single-character symbols and all their attributes. * The value associated with the symbol is the symbol itself. * @param {string} string a string of single character symbols * @param {string} mode * @param {string} fontFamily * @param {string} type * @param {(string|number)} [frequency] * @memberof module:definitions * @private */ function defineSymbols(string, mode, fontFamily, type, frequency) { for(let i = 0; i &lt; string.length; i++) { const ch = string.charAt(i); defineSymbol(ch, mode, fontFamily, type, ch, frequency); } } /** * Define a set of single-character symbols as a range of Unicode codepoints * @param {number} from First Unicode codepoint * @param {number} to Last Unicode codepoint * @param {string} mode * @param {string} fontFamily * @param {string} type * @param {(string|number)} [frequency] * @memberof module:definitions * @private */ function defineSymbolRange(from, to, mode, fontFamily, type, frequency) { for(let i = from; i &lt;= to; i++) { const ch = String.fromCodePoint(i); defineSymbol(ch, mode, fontFamily, type, ch, frequency); } } const CODEPOINT_SHORTCUTS = { 0x00b7: '\\cdot', 0x00bc: '\\frac{1}{4}', 0x00bd: '\\frac{1}{2}', 0x00be: '\\frac{3}{4}', 0x2070: '^{0}', 0x2071: '^{i}', 0x00b9: '^{1}', 0x00b2: '^{2}', 0x00b3: '^{3}', 0x2074: '^{4}', 0x2075: '^{5}', 0x2076: '^{6}', 0x2077: '^{7}', 0x2078: '^{8}', 0x2079: '^{9}', 0x207a: '^{+}', 0x207b: '^{-}', 0x207c: '^{=}', 0x207f: '^{n}', 0x2080: '_{0}', 0x2081: '_{1}', 0x2082: '_{2}', 0x2083: '_{3}', 0x2084: '_{4}', 0x2085: '_{5}', 0x2086: '_{6}', 0x2087: '_{7}', 0x2088: '_{8}', 0x2089: '_{9}', 0x208A: '_{+}', 0x208B: '_{-}', 0x208C: '_{=}', 0x2090: '_{a}', 0x2091: '_{e}', 0x2092: '_{o}', 0x2093: '_{x}', 0x2102: '\\C', 0x2115: '\\N', 0x2119: '\\P', 0x211A: '\\Q', 0x211D: '\\R', 0x2124: '\\Z', }; /** * Given a character, return a LaTeX expression matching its Unicode codepoint. * The return string is in the ASCII range. * If there is a matching symbol (e.g. \alpha) it is returned. * If there is no matching symbol and it is outside the ASCII range, an * expression with \char is returned. * @param {string} s * @return {string} * @memberof module:definitions * @private */ function matchCodepoint(s) { const codepoint = s.codePointAt(0); // Some symbols map to multiple codepoints. // Some symbols are 'pseudosuperscript'. Convert them to a super(or sub)script. // Map their alternative codepoints here. let result = CODEPOINT_SHORTCUTS[s]; if (result) return result; if (codepoint > 32 &amp;&amp; codepoint &lt; 127) return s; for (const p in MATH_SYMBOLS) { if (MATH_SYMBOLS.hasOwnProperty(p)) { if (MATH_SYMBOLS[p].value === s || MATH_SYMBOLS[p].body === s) { result = p; if (p[0] === '\\') result += ' '; } } } // No symbol was found, return a \char command if (!result) { if (codepoint &lt; 32 || codepoint >= 127) { result = '\\char"' + ('000000' + codepoint.toString(16)).toUpperCase().substr(-6) } else { result = s; } } return result; } /** * Given a Unicode character returns {char:, variant:, style} corresponding * to this codepoint. `variant` is optional and is one of 'mathbb', * 'mathfrak', 'mathcal', 'mathscr', 'mathsf' and 'mathtt' * This maps characters such as "blackboard uppercase C" to * {char: 'C', variant: 'mathbb', style:} * @param {string} char */ /* Some symbols in the MATHEMATICAL ALPHANUMERICAL SYMBOLS blocked had been previously defined in other blocks. Remap them */ const MATH_LETTER_EXCEPTIONS = { 0x1d455: 0x0210e, 0x1D49D: 0x0212C, 0x1D4A0: 0x02130, 0x1D4A1: 0x02131, 0x1D4A3: 0x0210B, 0x1D4A4: 0x02110, 0x1D4A7: 0x02112, 0x1D4A8: 0x02133, 0x1D4AD: 0x0211B, 0x1D4BA: 0x0212F, 0x1D4BC: 0x0210A, 0x1D4C4: 0x02134, 0x1D506: 0x0212D, 0x1D50B: 0x0210C, 0x1D50C: 0x02111, 0x1D515: 0x0211C, 0x1D51D: 0x02128, 0x1D53A: 0x02102, 0x1D53F: 0x0210D, 0x1D545: 0x02115, 0x1D547: 0x02119, 0x1D548: 0x0211A, 0x1D549: 0x0211D, 0x1D551: 0x02124, } const MATH_UNICODE_BLOCKS = [ { start: 0x1D400, len: 26, offset: 65, style: 'bold' }, { start: 0x1D41A, len: 26, offset: 97, style: 'bold' }, { start: 0x1D434, len: 26, offset: 65, style: 'italic' }, { start: 0x1D44E, len: 26, offset: 97, style: 'italic' }, { start: 0x1D468, len: 26, offset: 65, style: 'bolditalic'}, { start: 0x1D482, len: 26, offset: 97, style: 'bolditalic'}, { start: 0x1D49c, len: 26, offset: 65, variant: 'mathcal'}, { start: 0x1D4b6, len: 26, offset: 97, variant: 'mathcal'}, { start: 0x1D4d0, len: 26, offset: 65, variant: 'mathcal', style: 'bold'}, { start: 0x1D4ea, len: 26, offset: 97, variant: 'mathcal', style: 'bold'}, { start: 0x1D504, len: 26, offset: 65, variant: 'mathfrak'}, { start: 0x1D51e, len: 26, offset: 97, variant: 'mathfrak'}, { start: 0x1D56c, len: 26, offset: 65, variant: 'mathfrak', style: 'bold'}, { start: 0x1D586, len: 26, offset: 97, variant: 'mathfrak', style: 'bold'}, { start: 0x1D538, len: 26, offset: 65, variant: 'mathbb'}, { start: 0x1D552, len: 26, offset: 97, variant: 'mathbb'}, { start: 0x1D5A0, len: 26, offset: 65, variant: 'mathsf'}, { start: 0x1D5BA, len: 26, offset: 97, variant: 'mathsf'}, { start: 0x1D5D4, len: 26, offset: 65, variant: 'mathsf', style: 'bold'}, { start: 0x1D5EE, len: 26, offset: 97, variant: 'mathsf', style: 'bold'}, { start: 0x1D608, len: 26, offset: 65, variant: 'mathsf', style: 'italic'}, { start: 0x1D622, len: 26, offset: 97, variant: 'mathsf', style: 'italic'}, { start: 0x1D63c, len: 26, offset: 65, variant: 'mathsf', style: 'bolditalic'}, { start: 0x1D656, len: 26, offset: 97, variant: 'mathsf', style: 'bolditalic'}, { start: 0x1D670, len: 26, offset: 65, variant: 'mathtt'}, { start: 0x1D68A, len: 26, offset: 97, variant: 'mathtt'}, { start: 0x1D6A8, len: 25, offset: 0x391, style: 'bold'}, { start: 0x1D6C2, len: 25, offset: 0x3B1, style: 'bold'}, { start: 0x1D6E2, len: 25, offset: 0x391, style: 'italic'}, { start: 0x1D6FC, len: 25, offset: 0x3B1, style: 'italic'}, { start: 0x1D71C, len: 25, offset: 0x391, style: 'bolditalic'}, { start: 0x1D736, len: 25, offset: 0x3B1, style: 'bolditalic'}, { start: 0x1D756, len: 25, offset: 0x391, variant: 'mathsf', style: 'bold'}, { start: 0x1D770, len: 25, offset: 0x3B1, variant: 'mathsf', style: 'bold'}, { start: 0x1D790, len: 25, offset: 0x391, variant: 'mathsf', style: 'bolditalic'}, { start: 0x1D7AA, len: 25, offset: 0x3B1, variant: 'mathsf', style: 'bolditalic'}, { start: 0x1D7CE, len: 10, offset: 48, variant: '', style: 'bold' }, { start: 0x1D7D8, len: 10, offset: 48, variant: 'mathbb' }, { start: 0x1D7E3, len: 10, offset: 48, variant: 'mathsf' }, { start: 0x1D7Ec, len: 10, offset: 48, variant: 'mathsf', style: 'bold' }, { start: 0x1D7F6, len: 10, offset: 48, variant: 'mathtt'}, ] function unicodeToMathVariant(char) { let codepoint = char; if (typeof char === 'string') codepoint = char.codePointAt(0); if ((codepoint &lt; 0x1d400 || codepoint > 0x1d7ff) &amp;&amp; (codepoint &lt; 0x2100 || codepoint > 0x214f)) { return {char:char}; } // Handle the 'gap' letters by converting them back into their logical range for (const c in MATH_LETTER_EXCEPTIONS) { if (MATH_LETTER_EXCEPTIONS.hasOwnProperty(c)) { if (MATH_LETTER_EXCEPTIONS[c] === codepoint) { codepoint = c; break; } } } for (let i = 0; i &lt; MATH_UNICODE_BLOCKS.length; i++) { if (codepoint >= MATH_UNICODE_BLOCKS[i].start &amp;&amp; codepoint &lt; MATH_UNICODE_BLOCKS[i].start + MATH_UNICODE_BLOCKS[i].len) { return { char: String.fromCodePoint(codepoint - MATH_UNICODE_BLOCKS[i].start + MATH_UNICODE_BLOCKS[i].offset), variant: MATH_UNICODE_BLOCKS[i].variant, style: MATH_UNICODE_BLOCKS[i].style, } } } return {char:char}; } /** * Given a character and variant ('mathbb', 'mathcal', etc...) * return the corresponding unicode character (a string) * @param {string} char * @param {string} variant */ function mathVariantToUnicode(char, variant, style) { if (!/[A-Za-z0-9]/.test(char)) return char; const codepoint = char.codePointAt(0); for (let i = 0; i &lt; MATH_UNICODE_BLOCKS.length; i++) { if (!variant || MATH_UNICODE_BLOCKS[i].variant === variant) { if (!style || MATH_UNICODE_BLOCKS[i].style === style) { if (codepoint >= MATH_UNICODE_BLOCKS[i].offset &amp;&amp; codepoint &lt; MATH_UNICODE_BLOCKS[i].offset + MATH_UNICODE_BLOCKS[i].len) { return String.fromCodePoint( MATH_UNICODE_BLOCKS[i].start + codepoint - MATH_UNICODE_BLOCKS[i].offset); } } } } return char; } function codepointToLatex(cp) { if (CODEPOINT_SHORTCUTS[cp]) return CODEPOINT_SHORTCUTS[cp]; let result; // const s = String.fromCodePoint(cp); // for (const p in MATH_SYMBOLS) { // if (MATH_SYMBOLS.hasOwnProperty(p)) { // if (MATH_SYMBOLS[p].value === s || MATH_SYMBOLS[p].body === s) { // result = p; // if (p[0] === '\\') result += ' '; // return result; // } // } // } const v = unicodeToMathVariant(cp); if (!v.style &amp;&amp; !v.variant) return String.fromCodePoint(cp); result = v.char; if (v.variant) { result = '\\' + v.variant + '{' + result + '}'; } if (v.style === 'bold') { result = '\\mathbf{' + result + '}'; } else if (v.style === 'italic') { result = '\\mathit{' + result + '}'; } else if (v.style === 'bolditalic') { result = '\\mathbf{\\mathit{' + result + '}}'; } return '\\mathord{' + result + '}'; } function unicodeStringToLatex(s) { let result = ''; for (const cp of s) { result += codepointToLatex(cp.codePointAt(0)); } return result; } /** * * @param {string} mode * @param {string} s * @return {Object} * @memberof module:definitions * @private */ function matchFunction(mode, s) { let result = null; for (const p in FUNCTIONS) { if (FUNCTIONS.hasOwnProperty(p)) { if (s === p &amp;&amp; (mode !== 'text' || FUNCTIONS[p].allowedInText)) { if (!result || result.value.length &lt; p.length) { result = { latexName: p, value: p.slice(1) }; } } } } return result; } function matchSymbol(mode, s) { const a = mode === 'text' ? TEXT_SYMBOLS : (mode === 'command' ? COMMAND_SYMBOLS : MATH_SYMBOLS); let result = null; for (const p in a) { if (a.hasOwnProperty(p)) { const candidate = p; if (s === candidate) { if (!result || result.match.length &lt; candidate.length) { result = { latexName: p, fontFamily: a[p].fontFamily, value: a[p].value, type: a[p].type, match: candidate }