Socket
Socket
Sign inDemoInstall

mathlive

Package Overview
Dependencies
Maintainers
1
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mathlive - npm Package Compare versions

Comparing version 0.35.1 to 0.50.1

dist/commands.d.ts

290

CHANGELOG.md

@@ -0,1 +1,291 @@

## 0.50.1 (May 6, 2020)
### New Feature
- A new option, `config.error` can be used to catch errors while parsing Latex.
This is invoked both for the initial content of the mathfield, when the
content of the mathfield is changed programmatically, or when the user
paste latex content in the field.
An error code will indicate the problem encountered, but the parsing will
attempt to recover, as it has done previously.
### Bug Fixes
- Fixed an issue where the alphabetic 'sans' keys on the virtual keyboard output blackboard.
- Fixed an issue where the `\mleft.` and `\mright.` commands would not be rendered correctly (or propertly converted to MathASCII). (https://github.com/benetech/MathShare/issues/1182)
## 0.50 (May 4, 2020)
### Highlights
- **Maintenance**: Migration to TypeScript
- **Maintenance**: New math variant (bold, italic, etc...) subsytem matches LaTeX more closely
- **Maintenance**: Reduced code size
- **New feature**: Verbatim Latex
- **New feature**: `Mathfield.getConfig()`
### New Features
- **"Verbatim Latex"**: the Latex provided as input (for example with `insert()`)
is preserved as long as it's not edited. Previously, the Latex would be
normalized on input, and the output would not match character
for character, even though it produced equivalent Latex code. For example,
extra spaces could be inserted, and the order of subscript and superscript was
not preserved.
Now, the input Latex is preserved until
editing operations cause it to be modified. This also means that the arguments
of macros are never modified (since the macros are not editable) and will be
returned exactly as input (they were normalized before).
- New **`letterShapeStyle`** configuration setting to control which letters are automatically italicized, according to four popular styles:
| `letterShapeStyle` | xyz | ABC | αÎČÉŁ | ΓΔΘ |
| -----------------: | --- | --- | --- | --- |
| `iso` | it | it | it | it |
| `tex` | it | it | it | up |
| `french` | it | up | up | up |
| `upright` | up | up | up | up |
**(it)** = italic\
**(up)** = upright
The default letter shape style is `auto`: if the system locale is "french", the `french` style will be used, `tex` otherwise. The previous behavior was to always use `tex` style lettershape.
- New `Mathfield.getConfig()` method which gives access to the current configuration settings.
It can be invoked in three different ways:
- `mf.getConfig()`: return a `MathfieldConfig` object will the values for all
the configuration options filled-in.
- `mf.getConfig('letterShapeStyle')`: return the current value of the
`letterShapeStyle` option
- `mf.getConfig(['smartMode', 'smartFence'])`: return an object with the
values of the `smartMode` and `smartFence` filled in.
Note that `getConfig()` may return a different value immediately after `setConfig()`
was invoked: `getConfig()` returns a "resolved" value, so for example:
```javascript
mf.setConfig({ letterShapeStyle: 'auto' });
console.log(mf.getConfig('letterShapeStyle')); // prints 'tex'
```
* An example (`examples/test-cases`) with some test cases was added, including LaTeX output screenshots for comparison.
* Re-done the font selection sub-system. Internally, it's now cleaner and
easier to follow, and also closer to the LaTeX implementation. In particular,
in math mode, the styling directives are exclusive, except for `\mathsymbol`,
which matches the TeX behavior.
* When a character variant (for example using `\mathbb`) is not available in
the font repertoire, convert to Unicode and fallback to the system font. This
allows `\mathbb{1}` to correctly output 𝟙.
* Added support for `\ensuremath` command
* Added the `\imageof` ⊷ and `\originalof` ⊾ symbols
### Code Maintenance
#### Codebase Migrated to Typescript
This does not impact the bundled library, which is still transpiled JavaScript from the TypeScript sources and which can be used either with a JavaScript or TypeScript based project.
The migration did not result in changes to the public API which remains backward compatible with previous versions. However, new declaration files (`*.d.ts`) for TypeScript are available. They are more detailed (and accurate) than the previous ones which were generated from JSDoc comments.
The migration was done by hand for the entire code base (35 kloc). Type information was provided for all the data structures and function signatures.
While this does not affect the external users of MathLive (the API and functionality remains the same), this has resulted in several bugs being found by the compiler through static analysis. For example, the `onUndoStateWillChange()` handler was never invoked because of this statement:
```javascript
if (options && options.onUndoStateWillChange === 'function') {
options.onUndoStateWillChange();
}
```
instead of:
```javascript
if (options && typeof options.onUndoStateWillChange === 'function') {
options.onUndoStateWillChange();
}
```
The TypeScript compiler correctly flagged this error.
This migration will make the ongoing maintenance and development of the codebase much easier.
#### Codebase Refactoring
Concurrently to the migration to TypeScript, and thanks to the increased clarity and confidence brought in with static typing and code analysis tools, the code has been modularized and reorganized as follow. The codebase previously consisted of several large monolithic source files, some of which were in excess of 4,500 loc.
They have been broken up as follow:
- `core/atom.js` →
- `atom-array.ts`
- `atom-accent.ts`
- `atom-box.ts`
- `atom-enclose.ts`
- `atom-genfrac.ts`
- `atom-leftright.ts`
- `atom-line.ts`
- `atom-op.ts`
- `atom-overunder.ts`
- `atom-surd.ts`
- `atom-to-latex.ts`
- `atom-utils.ts`
- `atom.ts`
- `core/definitions.js` →
- `definitions-accents.ts`
- `definitions-enclose.ts`
- `definitions-environments.ts`
- `definitions-extensible-symbols.ts`
- `definitions-functions.ts`
- `definitinos-styling.ts`
- `definitions-symbols.ts`
- `definitions-utils.ts`
- `definitions.ts`
- `core/parser.js` →
- `parser.ts`
- `modes.ts`
- `modes-utils.ts`
- `modes-math.ts`
- `modes-text.ts`
- `modes-command.ts`
- `editor-mathlist.js` →
- `model.ts`
- `model-utils.ts`
- `model-styling.ts`
- `model-smartfence.ts`
- `model-selection.ts`
- `model-listeners.ts`
- `model-insert.ts`
- `model-delete.ts`
- `model-commands.ts`
- `model-command-mode.ts`
- `model-array.ts`
- `model-array-utils.ts`
- `editor-mathfield.js` →
- `a11y.ts`
- `autocomplete.ts`
- `commands.ts`
- `config.ts`
- `speech.ts`
- `speech-read-aloud.ts`
- `undo.ts`
- `mathfield.ts`
- `mathfield-virtual-keyboards.ts`
- `mathfield-utils.ts`
- `mathfield-styling.ts`
- `mathfield-smartmode.ts`
- `mathfield-render.ts`
- `mathfield-pointer-input.ts`
- `mathfield-keyboard-input.ts`
- `mathfield-commands.ts`
- `mathfield-clipboard.ts`
- `mathfield-buttons.ts`
Again, this is an internal change that will have no impact for external users of the MathLive library, but it will be contribute to improving the maintainability and velocity of the project.
#### Other Code Maintenance
- Updated font binaries
- Rewrote grapheme splitter in TypeScript. As a result, code size reduced by 113Kb (!).
- Switched to `jest` as a test runner.
### Bug Fixes
- **Fix #285**: The initial content of the mathfield was considered part of the
undo stack, that is, typing command+Z before making any editing operations
would make the initial content disappear.
- **Fix #236**: An initially empty field had no visible caret until it had focused,
then blurred, then focused again.
- **Fix #438**: MathLive did not behave correctly when inside a shadow DOM
- **Fix #436**: When `smartFence` was on, applying an inline shortcut before
the closing parent of a paren group that had been inserted as a pure fence
(not a `\left\right` group) the parens would get (incorrectly) promoted
to a `\left\right` group, and the shortcut would be inserted outside of the
paren.
- **Fix #435**: Virtual keyboard after a JSON-based virtual keyboard would not
display correctly.
- **Fix #417**: The "International Backslash" (labeled `><` on a german keyboard)
would incorrectly trigger the command mode.
- **Fix #416**: With `smartFence` on, braces around a fraction would disappear,
e.g. typing "(1/2" would result in "1/2"
- **Fix #415**: `toASCIIMath()` would fail when the mathfield was empty
- **Fix #393**: some characters in a `\operatorname` command, including `-` and `*`, were not displayed correctly (they should display as if in text mode, not in math mode, and the correct glyphs are different between the two modes)
- **Fix #395**: re-implemented how macros handle their arguments. They would previously
parse their argument using the current parseMode. This is incorrect. The parseMode
cannot be determined until the macro has been expanded and the arguments substituted.
The parsing of the macros arguments is now deferred until after the macro has been
expanded. Additionally, it wasn't previously possible for arguments to macros
to contain other arguments. This is now allowed.
- **Fix #395 (bis)**: Properly output Latex for macros when using 'latex' and 'latex-expanded' formats.
- Fixed numerous issues with LaTeX round-tripping. For example, `\mathfrak{C}`,
`\boldsymbol{\sin\theta}`,
- If the `\text` command included a `&`, the content following the `&` would be ignored.
- The `align*` environment was not handled correctly and displayed an extra gap between columns.
- The math styling commands did not behave properly. For example:\
\
`\mathbf{\sin \alpha} + \mathit{\cos \beta} + \mathbf{\tan x} + \boldsymbol{\sin \gamma}`
| | before | after |
| ----- | ------------ | ----------- |
| alpha | bold upright | italic |
| cos | italic | upright |
| tan | bold | roman |
| gamma | bold upright | bold italic |
- Related to the above, but worth noting separately, `\mathbf{\alpha}` should
render as normal italic: the `\mathbf` command does not apply to lowercase
greek letters. The command _does_ apply to uppercase greek letters. This is an artifact of the TeX font encoding, but the behavior is preserved for compatibility with TeX.
- The `\textcolor` command did not apply to large symbols, such as `\sum`
- Correctly output LaTeX for infix operators such as `\atopwithdelims`
- Correctly output unicode characters in the astral plane, e.g. `\unicode{"1F468}`
- Fixed an issue were consecutive calls to set the content of the mathfield could result in some spurious characters inserted at the beginning of the field.
## Breaking Change
- The signature of the `latexToMarkup()` function has changed.\
Instead of a
style and format, the second argument is an option object. The style can be
specified with a `mathstyle` property, the format with a `format` property.
A new `letterShapeStyle` property can also be specified.
- Before: `MathLive.latexToMarkup(formula, 'displaystyle')`
- After: `MathLive.latexToMarkup(formula, { mathstyle: 'displaystyle' });`
- The 'command' virtual keyboard is no longer displayed by default. The layout
for this virtual keyboard has been deprecated and will be removed in a future
version. This is a partial fullfilment of #270.
## Deprecated
- The `overrideDefaultInlineShortcuts` is deprecated (still supported in this
version, but will be removed in an upcoming one). Instead, to add to the default
shortcuts, use:
```javascript
mf.setConfig({
inlineShortcuts: {
...mf.getConfig('inlineShortcuts').inlineShortcuts,
...newShortcuts,
},
});
```
## 0.35

@@ -2,0 +292,0 @@

1296

dist/mathlive.d.ts
/**
* @typedef {function} MathFieldCallback
* @param {Mathfield} mathfield
* @return {void}
* @global
*
* Use MathLive to render and edit mathematical formulas in your browser.
*
*
* Read {@tutorial mathfield-getting-started | Getting Started} for more info.
*
* @example
* <script type="module">
* // To invoke the functions in this module, import the `Mathlive` module.
*
* import MathLive from 'https://unpkg.com/mathlive/dist/mathlive.mjs';
*
* console.log(MathLive.latexToAST('e^{i\\pi}+1=0'));
* </script>
*
* @packageDocumentation MathLive SDK Reference
*
*/
declare type MathFieldCallback = (mathfield: Mathfield) => void;
import { Mathfield } from './mathfield';
import { MathfieldConfig, TextToSpeechOptions } from './config';
import { MacroDictionary, ParserErrorCallback } from './core';
export { Mathfield };
export { MathfieldConfig };
/**
@typedef MathFieldConfig
@type {Object}
@property {string} locale?
@property {object<string, string>} strings?
@property {number} horizontalSpacingScale?
@property {string} namespace?
@property {function} substituteTextArea?
@property {"math" | "text"} defaultMode?
@property {MathFieldCallback} onFocus?
@property {MathFieldCallback} onBlur?
@property {function} onKeystroke?
@property {function} onAnnounce?
@property {boolean} overrideDefaultInlineShortcuts?
@property {object<string, string>} inlineShortcuts?
@property {number} inlineShortcutTimeout?
@property {object<string, string>} macros?
@property {boolean} smartFence?
@property {boolean} smartSuperscript?
@property {number} scriptDepth?
@property {boolean} removeExtraneousParentheses?
@property {boolean} ignoreSpacebarInMathMode?
@property {string} virtualKeyboardToggleGlyph?
@property {"manual" | "onfocus" | "off" } virtualKeyboardMode?
@property {"all" | "numeric" | "roman" | "greek" | "functions" | "command" | string} virtualKeyboards?
@property {"qwerty" | "azerty" | "qwertz" | "dvorak" | "colemak"} virtualKeyboardRomanLayout?
@property {object<string, string>} customVirtualKeyboardLayers?
@property {object<string, object>} customVirtualKeyboards?
@property {"material" | "apple" | ""} virtualKeyboardTheme?
@property {boolean} keypressVibration?
@property {string} keypressSound?
@property {string} plonkSound?
@property {boolean} readOnly?
@property {"mathlive" | "sre"} textToSpeechRules?
@property {"ssml" | "mac"} textToSpeechMarkup?
@property {object} textToSpeechRulesOptions?
@property {"local" | "amazon"} speechEngine?
@property {string} speechEngineVoice?
@property {string} speechEngineRate?
@property {function} onMoveOutOf?
@property {function} onTabOutOf?
@property {MathFieldCallback} onContentWillChange?
@property {MathFieldCallback} onContentDidChange?
@property {MathFieldCallback} onSelectionWillChange?
@property {MathFieldCallback} onSelectionDidChange?
@property {function} onUndoStateWillChange?
@property {function} onUndoStateDidChange?
@property {function} onModeChange?
@property {function} onVirtualKeyboardToggle?
@property {function} onReadAloudStatus?
@property {function} handleSpeak?
@property {function} handleReadAloud?
@global
* Converts a LaTeX string to a string of HTML markup.
*
* @param text A string of valid LaTeX. It does not have to start
* with a mode token such as `$$` or `\(`.
*
* @param options.mathstyle If `'displaystyle'` the "display" mode of TeX
* is used to typeset the formula, which is most appropriate for formulas that are
* displayed in a standalone block.
*
* If `'textstyle'` is used, the "text" mode
* of TeX is used, which is most appropriate when displaying math "inline"
* with other text (on the same line).
*
* @param options.macros A dictionary of LaTeX macros
*
* @param options.error A function invoked when a syntax error is encountered.
* An attempt to recover will be made even when an error is reported.
*
* @category Converting
* @keywords convert, latex, markup
*/
declare type MathFieldConfig = {
locale?: string;
strings?: {
[key: string]: string;
};
horizontalSpacingScale?: number;
namespace?: string;
substituteTextArea?: (...params: any[]) => any;
defaultMode?: "math" | "text";
onFocus?: MathFieldCallback;
onBlur?: MathFieldCallback;
onKeystroke?: (...params: any[]) => any;
onAnnounce?: (...params: any[]) => any;
overrideDefaultInlineShortcuts?: boolean;
inlineShortcuts?: {
[key: string]: string;
};
inlineShortcutTimeout?: number;
macros?: {
[key: string]: string;
};
smartFence?: boolean;
smartSuperscript?: boolean;
scriptDepth?: number;
removeExtraneousParentheses?: boolean;
ignoreSpacebarInMathMode?: boolean;
virtualKeyboardToggleGlyph?: string;
virtualKeyboardMode?: "manual" | "onfocus" | "off";
virtualKeyboards?: "all" | "numeric" | "roman" | "greek" | "functions" | "command" | string;
virtualKeyboardRomanLayout?: "qwerty" | "azerty" | "qwertz" | "dvorak" | "colemak";
customVirtualKeyboardLayers?: {
[key: string]: string;
};
customVirtualKeyboards?: {
[key: string]: object;
};
virtualKeyboardTheme?: "material" | "apple" | "";
keypressVibration?: boolean;
keypressSound?: string;
plonkSound?: string;
readOnly?: boolean;
textToSpeechRules?: "mathlive" | "sre";
textToSpeechMarkup?: "ssml" | "mac";
textToSpeechRulesOptions?: any;
speechEngine?: "local" | "amazon";
speechEngineVoice?: string;
speechEngineRate?: string;
onMoveOutOf?: (...params: any[]) => any;
onTabOutOf?: (...params: any[]) => any;
onContentWillChange?: MathFieldCallback;
onContentDidChange?: MathFieldCallback;
onSelectionWillChange?: MathFieldCallback;
onSelectionDidChange?: MathFieldCallback;
onUndoStateWillChange?: (...params: any[]) => any;
onUndoStateDidChange?: (...params: any[]) => any;
onModeChange?: (...params: any[]) => any;
onVirtualKeyboardToggle?: (...params: any[]) => any;
onReadAloudStatus?: (...params: any[]) => any;
handleSpeak?: (...params: any[]) => any;
handleReadAloud?: (...params: any[]) => any;
};
export declare function latexToMarkup(text: string, options: {
mathstyle?: 'displaystyle' | 'textstyle';
letterShapeStyle?: 'tex' | 'french' | 'iso' | 'upright' | 'auto';
macros?: MacroDictionary;
error?: ParserErrorCallback;
}): string;
/**
* Convert a DOM element into an editable mathfield.
*
* @property {HTMLElement} element - The DOM element this mathfield is attached to.
* @property {Object.<string, any>} config - A set of key/value pairs that can
* be used to customize the behavior of the mathfield
* @property {string} id - A unique ID identifying this mathfield
* @property {boolean} keystrokeCaptionVisible - True if the keystroke caption
* panel is visible
* @property {boolean} virtualKeyboardVisible - True if the virtual keyboard is
* visible
* @property {string} keystrokeBuffer The last few keystrokes, to look out
* for inline shortcuts
* @property {object[]} keystrokeBufferStates The saved state for each of the
* past keystrokes
* @class Mathfield
* @global
* After the DOM element has been created, the value `element.mathfield` will
* return a reference to the mathfield object. This value is also returned
* by `makeMathField`
*
* @param element A DOM element, for example as obtained
* by `document.getElementById()`, or the ID of a DOM element as a string.
*
*
* Given the HTML markup:
* ```html
* <span id='equation'>$f(x)=sin(x)$</span>
* ```
* The following code will turn the span into an editable mathfield.
* ```javascript
* import MathLive from 'https://unpkg.com/mathlive/dist/mathlive.mjs';
* MathLive.makeMathField('equation');
* ```
* @keywords create, make, mathfield
*/
declare class Mathfield {
/**
* Reverts this mathfield to its original content.
*
* After this method has been
* called, no other methods can be called on the object.
*
* To turn the
* element back into a mathfield, call `MathLive.makeMathField()` on the
* element again to get a new mathfield object.
*
* @method Mathfield#$revertToOriginalContent
*/
$revertToOriginalContent(): void;
/**
* Performs a command defined by a selector.
*
*
#### Moving the insertion point
| Name | Description |
| --------------------- | ------------------------- |
| `"moveToNextChar"` | |
| `"moveToPreviousChar"` | |
| `"moveUp"` | |
| `"moveDown"` | |
| `"moveToNextPlaceholder"` | |
| `"moveToPreviousPlaceholder"` | |
| `"moveToNextWord"` | |
| `"moveToPreviousWord"` | |
| `"moveToGroupStart"` | |
| `"moveToGroupEnd"` | |
| `"moveToMathFieldStart"` | |
| `"moveToMathFieldEnd"` | |
| `"moveToSuperscript"` | |
| `"moveToSubscript"` | |
| `"moveToOpposite"` | |
| `"moveBeforeParent"` | |
| `"moveAfterParent"` | |
#### Selection
| Name | Description |
| --------------------- | ------------------------- |
| `"selectGroup"` | Select all the atoms in the current group, that is all the siblings.<br> When the selection is in a numerator, the group is the numerator.<br>When the selection is a superscript or subscript, the group is the supsub.|
| `"selectAll"` | Select all the atoms in the mathfield|
#### Extending the selection
| Name | Description |
| --------------------- | ------------------------- |
| `"extendToNextChar"` | |
| `"extendToPreviousChar"` | |
| `"extendToNextWord"` | |
| `"extendToPreviousWord"` | |
| `"extendUp"` | |
| `"extendDown"` | |
| `"extendToNextBoundary"` | |
| `"extendToPreviousBoundary"` | |
| `"extendToGroupStart"` | |
| `"extendToGroupEnd"` | |
| `"extendToMathFieldStart"` | |
| `"extendToMathFieldEnd"` | |
#### Editing / deleting
| Name | Description |
| --------------------- | ------------------------- |
| `"deleteAll"` | Delete everything in the field |
| `"delete"` | Delete the current selection |
| `"deleteNextChar"` | |
| `"deletePreviousChar"` | |
| `"deleteNextWord"` | |
| `"deletePreviousWord"` | |
| `"deleteToGroupStart"` | |
| `"deleteToGroupEnd"` | |
| `"deleteToMathFieldEnd"` | |
| `"transpose"` | |
#### Editing a matrix
| Name | Description |
| --------------------- | ------------------------- |
| `"addRowAfter"` | |
| `"addRowBefore"` | |
| `"addColumnAfter"` | |
| `"addColumnBefore"` | |
#### Other editing commands
| Name | Description |
| --------------------- | ------------------------- |
| `"scrollIntoView"` | |
| `"scrollToStart"` | |
| `"switchMode"` | |
| `"complete"` | |
| `"nextSuggestion"` | |
| `"previousSuggestion"` | |
| `"toggleKeystrokeCaption"` | |
| `"applyStyle"` | |
#### Clipboard
| Name | Description |
| --------------------- | ------------------------- |
| `"undo"` | |
| `"redo"` | |
| `"copyToClipboard"` | |
| `"cutToClipboard"` | |
| `"pasteFromClipboard"` | |
#### Virtual Keyboard
| Name | Description |
| --------------------- | ------------------------- |
| `"toggleVirtualKeyboard"` | |
| `"showVirtualKeyboard"` | |
| `"hideVirtualKeyboard"` | |
| `"toggleVirtualKeyboardAlt"` | |
| `"toggleVirtualKeyboardShift"` | |
| `"showAlternateKeys"` | |
| `"hideAlternateKeys"` | |
| `"performAlternateKeys"` | |
| `"switchKeyboardLayer"` | |
| `"shiftKeyboardLayer"` | |
| `"unshiftKeyboardLayer"` | |
| `"insertAndUnshiftKeyboardLayer"` | |
| `"performWithFeedback"` | |
#### Speech
| Name | Description |
| --------------------- | ------------------------- |
| `"speak"` | speaks the amount specified by the first parameter. |
*
* @param {string|string[]} command - A selector, or an array whose first element
* is a selector, and whose subsequent elements are arguments to the selector.
*
* Note that selectors do not include a final "_". They can be passed either
* in camelCase or kebab-case.
*
* ```javascript
* mf.$perform('selectAll');
* mf.$perform('select-all');
* ```
* In the above example, both calls invoke the same selector.
*
*
* @method Mathfield#$perform
*/
$perform(command: string | string[]): void;
/**
* Returns a textual representation of the mathfield.
*
* @param {string} [format] - The format of the result.
*
| Format | Description |
| :------------------ | :---------------------- |
| `"latex"` |LaTeX rendering of the content, with LaTeX macros not expanded|
| `"latex-expanded"` |All macros are recursively expanded to their definition|
| `"json"` | A MathJSON abstract syntax tree, as an object literal formated as a JSON string (see {@tutorial MATHJSON})|
| `"spoken"` |Spoken text rendering, using the default format defined in config, which could be either text or SSML markup.|
| `"spoken-text"` |A plain spoken text rendering of the content.|
| `"spoken-ssml"` |A SSML (Speech Synthesis Markup Language) version of the content, which can be used with some text-to-speech engines such as AWS|
| `"spoken-ssml-withHighlighting"`|Like `"spoken-ssml"` but with additional annotations necessary for synchronized higlighting (read aloud)|
| `"mathML"` | A string of MathML markup|
*
* **Default** = `"latex"`
* @return {string}
* @category Accessing the Content
* @method Mathfield#$text
*/
$text(format?: string): string;
/**
* Returns a textual representation of the selection in the mathfield.
*
* @param {string} [format] - The format of the result.
*
| Format | Description |
| :------------------ | :---------------------- |
| `"latex"` |LaTeX rendering of the content, with LaTeX macros not expanded|
| `"latex-expanded"` |All macros are recursively expanded to their definition|
| `"json"` | A MathJSON abstract syntax tree, as an object literal formated as a JSON string (see {@tutorial MATHJSON})|
| `"spoken"` |Spoken text rendering, using the default format defined in config, which could be either text or SSML markup.|
| `"spoken-text"` |A plain spoken text rendering of the content.|
| `"spoken-ssml"` |A SSML (Speech Synthesis Markup Language) version of the content, which can be used with some text-to-speech engines such as AWS|
| `"spoken-ssml-withHighlighting"`|Like `"spoken-ssml"` but with additional annotations necessary for synchronized higlighting (read aloud)|
| `"mathML"` | A string of MathML markup|
*
* **Default** = `"latex"`
* @return {string}
* @category Accessing the Content
* @method Mathfield#$selectedText
*/
$selectedText(format?: string): string;
/**
* Checks if the selection is collapsed.
*
* @return {boolean} True if the length of the selection is 0, that is, if it is a single
* insertion point.
* @category Selection
* @method Mathfield#$selectionIsCollapsed
*/
$selectionIsCollapsed(): boolean;
/**
* Returns the depth of the selection group.
*
* If the selection is at the root level, returns 0.
*
* If the selection is a portion of the numerator of a fraction
* which is at the root level, return 1. Note that in that case, the numerator
* would be the "selection group".
*
* @return {number}
* @category Selection
* @method Mathfield#$selectionDepth
*/
$selectionDepth(): number;
/**
* Checks if the selection starts at the beginning of the selection group.
*
* @return {boolean}
* @category Selection
* @method Mathfield#$selectionAtStart
*/
$selectionAtStart(): boolean;
/**
* Checks if the selection extends to the end of the selection group.
*
* @return {boolean}
* @category Selection
* @method Mathfield#$selectionAtEnd
*/
$selectionAtEnd(): boolean;
/**
* Sets or gets the content of the mathfield.
*
* If `text` is not empty, sets the content of the mathfield to the
* text interpreted as a LaTeX expression.
*
* If `text` is empty (or omitted), return the content of the mathfield as a
* LaTeX expression.
* @param {string} [text]
*
* @param {Object.<string, any>} [options]
* @param {boolean} [options.suppressChangeNotifications] - If true, the
* handlers for the contentWillChange and contentDidChange notifications will
* not be invoked. **Default** = `false`.
*
* @return {string}
* @category Accessing the Content
* @method Mathfield#$latex
*/
$latex(text?: string, options?: {
suppressChangeNotifications?: boolean;
}): string;
/**
* Return the DOM element associated with this mathfield.
*
* Note that `this.$el().mathfield === this`
*
* @return {HTMLElement}
* @method Mathfield#$el
*/
$el(): HTMLElement;
/**
* Inserts a block of text at the current insertion point.
*
* This method can be called explicitly or invoked as a selector with {@linkcode Mathfield#$perform $perform("insert")}
* .
*
* After the insertion, the selection will be set according to the `selectionMode`.
*
* @param {string} s - The text to be inserted
*
* @param {Object.<string, any>} [options]
*
* @param {"replaceSelection"|"replaceAll"|"insertBefore"|"insertAfter"} options.insertionMode -
*
| <!-- --> | <!-- --> |
| :---------- | :---------- |
|`"replaceSelection"`| (default)|
|`"replaceAll"`| |
|`"insertBefore"`| |
|`"insertAfter"`| |
*
* @param {'placeholder' | 'after' | 'before' | 'item'} options.selectionMode - Describes where the selection
* will be after the insertion:
*
| <!-- --> | <!-- --> |
| :---------- | :---------- |
|`"placeholder"`| The selection will be the first available placeholder in the text that has been inserted (default)|
|`"after"`| The selection will be an insertion point after the inserted text|
|`"before"`| The selection will be an insertion point before the inserted text|
|`"item"`| The inserted text will be selected|
*
* @param {'auto' | 'latex'} options.format - The format of the string `s`:
*
| <!-- --> | <!-- --> |
|:------------|:------------|
|`"auto"`| The string is Latex fragment or command) (default)|
|`"latex"`| The string is a Latex fragment|
*
* @param {boolean} options.focus - If true, the mathfield will be focused after
* the insertion
*
* @param {boolean} options.feedback - If true, provide audio and haptic feedback
*
* @param {"text" | "math" | ""} options.mode - If empty, the current mode
* is used (default)
*
* @param {object} options.style
*
* @param {boolean} options.resetStyle - If true, the style after the insertion
* is the same as the style before. If false, the style after the
* insertion is the style of the last inserted atom.
*
* @param {boolean} options.smartFence - If true, promote plain fences, e.g. `(`,
* as `\left...\right` or `\mleft...\mright`
*
* @param {boolean} options.suppressChangeNotifications - If true, the
* handlers for the contentWillChange, contentDidChange, selectionWillChange and
* selectionDidChange notifications will not be invoked. Default `false`.
*
* @category Changing the Content
* @method Mathfield#$insert
*/
$insert(s: string, options?: {
insertionMode: "replaceSelection" | "replaceAll" | "insertBefore" | "insertAfter";
selectionMode: 'placeholder' | 'after' | 'before' | 'item';
format: 'auto' | 'latex';
focus: boolean;
feedback: boolean;
mode: "text" | "math" | "";
style: any;
resetStyle: boolean;
smartFence: boolean;
suppressChangeNotifications: boolean;
}): void;
/**
* Updates the style (color, bold, italic, etc...) of the selection or sets
* the style to be applied to future input.
*
* If there is a selection, the style is applied to the selection
*
* If the selection already has this style, remove it. If the selection
* has the style partially applied (i.e. only some sections), remove it from
* those sections, and apply it to the entire selection.
*
* If there is no selection, the style will apply to the next character typed.
*
* @param {object} style The style properties to be applied. All the
* properties are optional and they can be combined.
*
* @param {string} [style.mode] - Either `"math"`, `"text"` or `"command"`
*
* @param {string} [style.color] - The text/fill color, as a CSS RGB value or
* a string for some "well-known" colors, e.g. `"red"`, `"#f00"`, etc...
*
* @param {string} [style.backgroundColor] - The background color.
*
* @param {string} [style.fontFamily] - The font family used to render text.
*
* This value can the name of a locally available font, or a CSS font stack, e.g.
* `"Avenir"`, `"Georgia, serif"`, etc...
*
* This can also be one of the following TeX-specific values:
*
| <!-- --> | <!-- --> |
| :---------- | :---------- |
|`"cmr"`| Computer Modern Roman, serif|
|`"cmss"`| Computer Modern Sans-serif, latin characters only|
|`"cmtt"`| Typewriter, slab, latin characters only|
|`"cal"`| Calligraphic style, uppercase latin letters and digits only|
|`"frak"`| Fraktur, gothic, uppercase, lowercase and digits|
|`"bb"`| Blackboard bold, uppercase only|
|`"scr"`| Script style, uppercase only|
*
* @param {string} [style.series] - The font 'series', i.e. weight and
* stretch.
*
* The following values can be combined, for example: `"ebc"`: extra-bold,
* condensed. Aside from `"b"`, these attributes may not have visible effect if the
* font family does not support this attribute:
*
| <!-- --> | <!-- --> |
| :---------- | :---------- |
|`"ul"`| ultra-light weight|
|`"el"`| extra-light|
|`"l"`| light|
|`"sl"`| semi-light|
|`"m"`| medium (default)|
|`"sb"`| semi-bold|
|`"b"`| bold|
|`"eb"`| extra-bold|
|`"ub"`| ultra-bold|
|`"uc"`| ultra-condensed|
|`"ec"`| extra-condensed|
|`"c"`| condensed|
|`"sc"`| semi-condensed|
|`"n"`| normal (default)|
|`"sx"`| semi-expanded|
|`"x"`| expanded|
|`"ex"`| extra-expanded|
|`"ux"`| ultra-expanded|
*
* @param {string} [style.shape] - The font "shape", i.e. italic or upright.
*
| <!-- --> | <!-- --> |
| :---------- | :---------- |
|`"auto"`| italic or upright, depending on mode and letter (single letters are italic in math mode)|
|`"up"`| upright|
|`"it"`| italic|
|`"sl"`| slanted or oblique (often the same as italic)|
|`"sc"`| small caps|
|`"ol"`| outline|
*
* @param {string} [style.size] - The font size: `"size1"`...`"size10"`.
* '"size5"' is the default size
*
* @category Changing the Content
* @method Mathfield#$applyStyle
*
*/
$applyStyle(style: {
mode?: string;
color?: string;
backgroundColor?: string;
fontFamily?: string;
series?: string;
shape?: string;
size?: string;
}): void;
/**
* @param {string} keys - A string representation of a key combination.
*
* For example `"Alt-KeyU"`.
*
* See [W3C UIEvents](https://www.w3.org/TR/uievents/#code-virtual-keyboards)
* for more information on the format of the descriptor.
*
* @param {Event?} [evt] - An event corresponding to the keystroke. Pass this
* event if the keystroke originated from a user interaction that produced it.
* If the keystroke is synthetic (for example, triggered in response to a
* click or other event not involving a keyboard), omit it.
* @return {boolean}
* @category Changing the Content
* @method Mathfield#$keystroke
*/
$keystroke(keys: string, evt?: Event): boolean;
/**
* Simulates a user typing the keys indicated by text.
*
* @param {string} text - A sequence of one or more characters.
* @category Changing the Content
* @method Mathfield#$typedText
*/
$typedText(text: string): void;
/**
*
* Update the configuration options for this mathfield.
*
* @param {MathFieldConfig} config - See {@tutorial CONFIG Configuration Options} for details.
*
* @method Mathfield#$setConfig
*/
$setConfig(config: MathFieldConfig): void;
/**
*
* Speak some part of the expression, either with or without synchronized highlighting.
*
* @param {string} amount - `"all"`, `"selection"`, `"left"`, `"right"`, `"group"`, `"parent"`
* @param {object} speakOptions
* @param {boolean} speakOptions.withHighlighting - If true, synchronized
* highlighting of speech will happen (if possible). Default is false.
*
* @method Mathfield#speak_
*/
speak_(amount: string, speakOptions: {
withHighlighting: boolean;
}): void;
/**
* The DOM element this mathfield is attached to.
*/
element: HTMLElement;
/**
* A set of key/value pairs that can
be used to customize the behavior of the mathfield
*/
config: {
[key: string]: any;
};
/**
* A unique ID identifying this mathfield
*/
id: string;
/**
* True if the keystroke caption
panel is visible
*/
keystrokeCaptionVisible: boolean;
/**
* True if the virtual keyboard is
visible
*/
virtualKeyboardVisible: boolean;
/**
* The last few keystrokes, to look out
for inline shortcuts
*/
keystrokeBuffer: string;
/**
* The saved state for each of the
past keystrokes
*/
keystrokeBufferStates: object[];
}
export declare function makeMathField(element: HTMLElement | string, config: MathfieldConfig): Mathfield;
/**
* Converts a LaTeX string to a string of MathML markup.
*
* Use MathLive to render and edit mathematical formulas in your browser.
* @param latex A string of valid LaTeX. It does not have to start
* with a mode token such as a `$$` or `\(`.
* @param options.generateId If true, add an `"extid"` attribute
* to the MathML nodes with a value matching the `atomID`. This can be used
* to map items on the screen with their MathML representation or vice-versa.
* @param options.error Callback invoked when an error is encountered while
* parsing the input string.
*/
export declare function latexToMathML(latex: string, options: {
macros?: MacroDictionary;
generateID: boolean;
error?: ParserErrorCallback;
}): string;
/**
* Converts a LaTeX string to an {@tutorial math-json | MathJSON } Abstract Syntax Tree
*
* This module exports {@link #functions%3Amathlive some functions} and the {@link #class%3AMathField `Mathfield`} class.
* **See Also:** [[latexToAST|latexToAST()]]
*
* See {@tutorial USAGE_GUIDE the Usage Guide} for more details on how to get
* started.
* @param latex A string of valid LaTeX. It does not have to start
* with a mode token such as a `$$` or `\(`.
* @param options.macros A dictionary of LaTeX macros
* @param options.error Callback invoked when an error is encountered while
* parsing the input string.
*
* @example
* // To invoke the functions in this module, import the `mathlive` module.
* @return The Abstract Syntax Tree as an object literal using the MathJSON format.
* @category Converting
* @keywords convert, latex, mathjson, ast
*/
export declare function latexToAST(latex: string, options?: {
macros?: MacroDictionary;
error?: ParserErrorCallback;
}): any;
/**
* Converts a {@tutorial math-json | MathJSON } Abstract Syntax Tree to a LaTeX string.
*
* import mathlive from 'dist/mathlive.mjs';
* **See Also:** [[latexToAST|latexToAST()]]
*
* console.log(mathlive.latexToMarkup('e^{i\\pi}+1=0'));
* @return The LaTeX representation of the Abstract Syntax Tree, if valid.
* @category Converting
* @keywords convert, latex, mathjson, ast
*/
export declare function astToLatex(mathJson: any, options?: {
/** The number of digits used in the representation of numbers. **Default** = 14 */
precision?: number;
/** The character used as the decimal marker. **Default** = `"."`. */
decimalMarker?: string;
/** The character used to separate group of numbers, typically thousands. **Default** = `"\\, "` */
groupSeparator?: string;
/** The character used to indicate product. Other option would be `"\\times "`. **Default** = `"\\cdot "` */
product?: string;
/** The character used before an exponent indicator. **Default** = `"\\cdot "` */
exponentProduct?: string;
/** The character used to indicate an exponent. **Default** = `""` */
exponentMarker?: string;
/** The format used for numbers using the scientific notation. **Default** = `"auto"` * /
scientificNotation?: 'auto' | 'engineering' | 'on';
/** The string used at the begining of repeating digits. **Default** = `"\\overline{"` */
beginRepeatingDigits?: string;
/** The string used at the end of repeating digits. **Default** = `"}"` */
endRepeatingDigits?: string;
}): string;
/**
* Converts a LaTeX string to a textual representation ready to be spoken
*
* @module mathlive
* @packageDocumentation MathLive API Reference
* @param latex A string of valid LaTeX. It does not have to start
* with a mode token such as a `$$` or `\(`.
*
* @param options {@inheritDoc TextToSpeechOptions}
* @param options.error Callback invoked when an error is encountered while
* parsing the input string.
*
* @return The spoken representation of the input LaTeX.
* @example
* console.log(MathLive.latexToSpeakableText('\\frac{1}{2}'));
* // 'half'
* @category Converting
* @keywords convert, latex, speech, speakable, text, speakable text
*/
declare module "mathlive" {
/**
* Converts a LaTeX string to a string of HTML markup.
export declare function latexToSpeakableText(latex: string, options: TextToSpeechOptions & {
macros?: MacroDictionary;
error?: ParserErrorCallback;
}): string;
export declare type AutoRenderOptions = {
/** Namespace that is added to `data-` attributes to avoid collisions with other libraries.
*
* @param {string} text A string of valid LaTeX. It does not have to start
* with a mode token such as `$$` or `\(`.
* It is empty by default.
*
* @param {"displaystyle" | "textstyle"} mathstyle If `'displaystyle'` the "display" mode of TeX
* is used to typeset the formula, which is most appropriate for formulas that are
* displayed in a standalone block.
*
* If `'textstyle'` is used, the "text" mode
* of TeX is used, which is most appropriate when displaying math "inline"
* with other text (on the same line).
*
* @param {"mathlist" | "span" | "html"} [format='html'] For debugging purposes, this function
* can also return a text representation of internal data structures
* used to construct the markup.
*
* @param {object} [macros] A dictionary of LaTeX macros
*
* @return {string}
* @category Converting
* @function module:mathlive#latexToMarkup
* The namespace should be a string of lowercase letters.
*/
function latexToMarkup(text: string, mathstyle: "displaystyle" | "textstyle", format?: "mathlist" | "span" | "html", macros?: any): string;
/**
* Convert a DOM element into an editable mathfield.
namespace?: string;
/** Custom LaTeX macros */
macros?: MacroDictionary;
/** An array of tag names whose content will
* not be scanned for delimiters (unless their class matches the `processClass`
* pattern below.
*
* After the DOM element has been created, the value `element.mathfield` will
* return a reference to the mathfield object. This value is also returned
* by `makeMathField`
*
* @param {HTMLElement|string} element A DOM element, for example as obtained
* by `document.getElementById()`, or the ID of a DOM element as a string.
*
* @param {MathFieldConfig} [config={}] See {@tutorial CONFIG} for details.
*
*
* @return {Mathfield}
*
* Given the HTML markup:
* ```html
* <span id='equation'>$f(x)=sin(x)$</span>
* ```
* The following code will turn the span into an editable mathfield.
* ```
* import MathLive from 'dist/mathlive.mjs';
* MathLive.makeMathField('equation');
* ```
*
* @function module:mathlive#makeMathField
* **Default:** `['noscript', 'style', 'textarea', 'pre', 'code', 'annotation', 'annotation-xml']`
*/
function makeMathField(element: HTMLElement | string, config?: MathFieldConfig): Mathfield;
skipTags?: string[];
/**
* Converts a LaTeX string to a string of MathML markup.
* A string used as a regular expression of class names of elements whose content will not be
* scanned for delimiter
*
* @param {string} latex A string of valid LaTeX. It does not have to start
* with a mode token such as a `$$` or `\(`.
* @param {object} options
* @param {boolean} [options.generateID=false] - If true, add an `"extid"` attribute
* to the MathML nodes with a value matching the `atomID`. This can be used
* to map items on the screen with their MathML representation or vice-versa.
* @return {string}
* @category Converting
* @function module:mathlive#latexToMathML
* **Default**: `'tex2jax_ignore'`
*/
function latexToMathML(latex: string, options: {
generateID?: boolean;
}): string;
ignoreClass?: string;
/**
* Converts a LaTeX string to an Abstract Syntax Tree (MathJSON)
*
* **See:** {@tutorial MATHJSON}
*
* @param {string} latex A string of valid LaTeX. It does not have to start
* with a mode token such as a `$$` or `\(`.
* @param {Object.<string, any>} options
* @param {object} [options.macros] A dictionary of LaTeX macros
*
* @return {object} The Abstract Syntax Tree as an object literal using the MathJSON format.
* @category Converting
* @function module:mathlive#latexToAST
*/
function latexToAST(latex: string, options: {
macros?: any;
}): any;
/**
* Converts an Abstract Syntax Tree (MathJSON) to a LaTeX string.
*
* **See:** {@tutorial MATHJSON}
*
* @param {object} ast - The Abstract Syntax Tree as an object literal (MathJSON).
* @param {Object.<string, any>} options
* @param {number} [options.precision=14] The number of digits used in the
* representation of numbers. **Default** = 14.
* @param {string} [options.decimalMarker='.'] The character used as the decimal
* marker. **Default** = `"."`.
* @param {string} [options.groupSeparator='\\, '] The character used to separate group of numbers, typically thousands. **Default** = `"\\, "`
* @param {string} [options.product='\\cdot '] The character used to indicate product. Other option would be `"\\times "`. **Default** = `"\\cdot "`
* @param {string} [options.exponentProduct='\\cdot '] The character used before an
* exponent indicator. **Default** = `"\\cdot "`
* @param {string} [options.exponentMarker=''] The character used to indicate an
* exponent. **Default** = `""`
* @param {"auto" | "engineering" | "on"} [options.scientificNotation='auto'] The format used for numbers
* using the scientific notation. **Default** = `"auto"`
* @param {string} [options.beginRepeatingDigits='\\overline{'] The string
* used at the begining of repeating digits. **Default** = `"\\overline{"`
* @param {string} [options.endRepeatingDigits='}'] The string
* used at the end of repeating digits. **Default** = `"}"`
*
* @return {string} The LaTeX representation of the Abstract Syntax Tree, if valid.
* @category Converting
* @function module:mathlive#astToLatex
*/
function astToLatex(ast: any, options: {
precision?: number;
decimalMarker?: string;
groupSeparator?: string;
product?: string;
exponentProduct?: string;
exponentMarker?: string;
scientificNotation?: "auto" | "engineering" | "on";
beginRepeatingDigits?: string;
endRepeatingDigits?: string;
}): string;
/**
* Converts a LaTeX string to a textual representation ready to be spoken
*
* @param {string} latex A string of valid LaTeX. It does not have to start
* with a mode token such as a `$$` or `\(`.
*
* @param {Object.<string, any>} options
*
* @param {"mathlive" | "sre"} [options.textToSpeechRules='mathlive'] The set of text to
* speech rules to use.
*
* A value of `"mathlive"` (the default) indicates that
* the simple rules built into MathLive should be used.
*
* A value of `"sre"` indicates that the Speech Rule Engine from Volker Sorge
* should be used.
* Note that SRE is not included or loaded by MathLive and for this option to
* work SRE should be loaded separately.
*
* @param {string} [options.textToSpeechMarkup=''] The markup syntax to use
* for the output of conversion to spoken text.
*
* Possible values are `ssml` for
* the SSML markup or `mac` for the MacOS markup (e.g. `"[[ltr]]"`)
*
* @param {Object.<string, any>} [options.textToSpeechRulesOptions={}] A set of
* key/value pairs that can be used to configure the speech rule engine.
*
* Which options are available depends on the speech rule engine in use. There
* are no options available with MathLive's built-in engine. The options for
* the SRE engine are documented [here]{@link:https://github.com/zorkow/speech-rule-engine}
* @return {string} The spoken representation of the input LaTeX.
* @example
* console.log(MathLive.latexToSpeakableText('\\frac{1}{2}'));
* // âžĄïžŽ'half'
* @category Converting
* @function module:mathlive#latexToSpeakableText
*/
function latexToSpeakableText(latex: string, options: {
textToSpeechRules?: "mathlive" | "sre";
textToSpeechMarkup?: string;
textToSpeechRulesOptions?: {
[key: string]: any;
};
}): string;
/**
* Highlights the span corresponding to the specified atomID.
*
* This is used for text-to-speech with synchronized highlighting (read aloud)
*
* @category Read Aloud
* @param {string} atomID
*
*/
function highlightAtomID(atomID: string): void;
/**
* Returns the status of a Read Aloud operation (reading with synchronized
* highlighting).
*
* Possible values are:
* - `"ready"`
* - `"playing"`
* - `"paused"`
* - `"unavailable"`
*
* **See** {@linkcode module:editor-mathfield#speak speak}
* @category Read Aloud
* @return {"ready" | "playing" | "paused" | "unavailable"}
* @function module:mathlive#readAloudStatus
*/
function readAloudStatus(): "ready" | "playing" | "paused" | "unavailable";
/**
* Pauses a read aloud operation if one is in progress.
*
* **See** {@linkcode module:editor/mathfield#speak speak}
* @category Read Aloud
* @function module:mathlive#pauseReadAloud
*/
function pauseReadAloud(): void;
/**
* Resumes a read aloud operation if one was paused.
*
* **See** {@linkcode module:editor-mathfield#speak speak}
* @category Read Aloud
* @function module:mathlive#resumeReadAloud
*/
function resumeReadAloud(): void;
/**
* If a Read Aloud operation is in progress, read from a specified token
*
* **See** {@linkcode module:editor-mathfield#speak speak}
*
* @param {string} [token]
* @param {number} [count] The number of tokens to read.
* @category Read Aloud
* @function module:mathlive#playReadAloud
*/
function playReadAloud(token?: string, count?: number): void;
/**
* Transform all the elements in the document body that contain LaTeX code
* into typeset math.
*
* **Note:** This is a very expensive call, as it needs to parse the entire
* DOM tree to determine which elements need to be processed. In most cases
* this should only be called once per document, once the DOM has been loaded.
* To render a specific element, use {@linkcode module:mathlive#renderMathInElement renderMathInElement()}
*
* **See:** {@tutorial USAGE_GUIDE}
*
* @param {object<string, any>} [options={}] See {@linkcode module:mathlive#renderMathInElement renderMathInElement()}
* for details
* @example
* import MathLive from 'dist/mathlive.mjs';
* document.addEventListener("load", () => {
* MathLive.renderMathInDocument();
* });
*
*/
function renderMathInDocument(options?: {
[key: string]: any;
}): void;
/**
* Transform all the children of `element`, recursively, that contain LaTeX code
* into typeset math.
*
* **See:** {@tutorial USAGE_GUIDE}
*
* @param {HTMLElement|string} element An HTML DOM element, or a string containing
* the ID of an element.
* @param {object} [options={}]
*
* @param {string} [options.namespace=''] - Namespace that is added to `data-`
* attributes to avoid collisions with other libraries.
*
* It is empty by default.
*
* The namespace should be a string of lowercase letters.
*
* @param {object[]} [options.macros={}] - Custom LaTeX macros
*
* @param {string[]} [options.skipTags=['noscript', 'style', 'textarea', 'pre', 'code', 'annotation', 'annotation-xml'] ]
* an array of tag names whose content will
* not be scanned for delimiters (unless their class matches the `processClass`
* pattern below.
*
* @param {string} [options.ignoreClass='tex2jax_ignore'] a string used as a
* regular expression of class names of elements whose content will not be
* scanned for delimiters
* @param {string} [options.processClass='tex2jax_process'] a string used as a
* A string used as a
* regular expression of class names of elements whose content **will** be

@@ -968,7 +191,14 @@ * scanned for delimiters, even if their tag name or parent class name would

*
* @param {string} [options.processScriptType="math/tex"] `<script>` tags of the
* **Default**: `'tex2jax_process'`
*
* */
processClass?: string;
/**
* `<script>` tags of the
* indicated type will be processed while others will be ignored.
*
* @param {string} [options.renderAccessibleContent='mathml'] The format(s) in
* **Default**: `'math/tex'`
*/
processScriptType?: string;
/** The format(s) in
* which to render the math for screen readers:

@@ -979,6 +209,8 @@ * - `'mathml'` MathML

* You can pass an empty string to turn off the rendering of accessible content.
*
* You can pass multiple values separated by spaces, e.g `'mathml speakable-text'`
*
* @param {boolean} [options.preserveOriginalContent=true] if true, store the
* **Default**: `'mathml'`
*/
renderAccessibleContent?: string;
/** If true, store the
* original textual content of the element in a `data-original-content`

@@ -990,81 +222,119 @@ * attribute. This value can be accessed for example to restore the element to

* ```
* @param {boolean} [options.readAloud=false] if true, generate markup that can
* be read aloud later using {@linkcode module:editor-mathfield#speak speak}
*
* @param {boolean} [options.TeX.processEnvironments=true] if false, math expression
* that start with `\begin{` will not automatically be rendered.
* **Default**: `'mathml'`
*/
preserveOriginalContent?: boolean;
/**
* If true, generate markup that can
* be read aloud later using {@linkcode speak}
*
* @param {string[][]} [options.TeX.delimiters.inline=[['\\(','\\)']] ] arrays
* of delimiter pairs that will trigger a render of the content in 'textstyle'
* **Default**: `false`
*/
readAloud?: boolean;
TeX?: {
/** if false, math expression
* that start with `\begin{` will not automatically be rendered.
*/
processEnvironments?: boolean;
};
/**
* Delimiter pairs that will trigger a render of the content in
* display style or inline, respectively.
*
* @param {string[][]} [options.TeX.delimiters.display=[['$$', '$$'], ['\\[', '\\]']] ] arrays
* of delimiter pairs that will trigger a render of the content in
* 'displaystyle'.
* **Default**: `{display: [ ['$$', '$$'], ['\\[', '\\]'] ] ], inline: [ ['\\(','\\)'] ] ]}`
*
* @param {function} [renderToMarkup] a function that will convert any LaTeX found to
*/
delimiters?: {
display: string[][];
inline: string[][];
};
/** A function that will convert any LaTeX found to
* HTML markup. This is only useful to override the default MathLive renderer
*
* @param {function} [renderToMathML] a function that will convert any LaTeX found to
* MathML markup.
*
* @param {function} [renderToSpeakableText] a function that will convert any LaTeX found to
* speakable text markup.
*
* @function module:mathlive#renderMathInElement
*/
function renderMathInElement(element: HTMLElement | string, options?: {
namespace?: string;
macros?: object[];
skipTags?: string[];
ignoreClass?: string;
processClass?: string;
processScriptType?: string;
renderAccessibleContent?: string;
preserveOriginalContent?: boolean;
readAloud?: boolean;
}, renderToMarkup?: (...params: any[]) => any, renderToMathML?: (...params: any[]) => any, renderToSpeakableText?: (...params: any[]) => any): void;
renderToMarkup?: Function;
/**
*
* @param {string|HTMLElement|Mathfield} element
* @param {Object.<string, any>} [options={}]
* @param {string} options.namespace The namespace used for the `data-`
* attributes. If you used a namespace with `renderMathInElement`, you must
* use the same namespace here.
* @function module:mathlive#revertToOriginalContent
* a function that will convert any LaTeX found to
* MathML markup.
*/
function revertToOriginalContent(element: string | HTMLElement | Mathfield, options?: {
namespace: string;
}): void;
/**
* After calling {@linkcode module:mathlive#renderMathInElement renderMathInElement}
* or {@linkcode module:mathlive#makeMathField makeMathField} the original content
* can be retrieved by calling this function.
*
* Given the following markup:
* ```html
* <span id='equation'>$$f(x)=sin(x)$$</span>
* ```
* The following code:
* ```javascript
* MathLive.renderMathInElement('equation');
* console.log(MathLive.getOriginalContent('equation'));
* ```
* will output:
* ```
* $$f(x)=sin(x)$$
* ```
* @param {string | HTMLElement | Mathfield} element - A DOM element ID, a DOM
* element or a Mathfield.
* @param {object} [options={}]
* @param {string} [options.namespace=""] The namespace used for the `data-`
* attributes.
renderToMathML?: Function;
/** A function that will convert any LaTeX found to
* speakable text markup. */
renderToSpeakableText?: Function;
};
/**
* Transform all the elements in the document body that contain LaTeX code
* into typeset math.
*
* **Note:** This is a very expensive call, as it needs to parse the entire
* DOM tree to determine which elements need to be processed. In most cases
* this should only be called once per document, once the DOM has been loaded.
* To render a specific element, use {@linkcode renderMathInElement | renderMathInElement()}
*
* Read {@tutorial mathfield-getting-started | Getting Started}.
*
* @example
* import MathLive from 'https://unpkg.com/mathlive/dist/mathlive.mjs';
* document.addEventListener("load", () => {
* MathLive.renderMathInDocument();
* });
*
* @category Rendering
* @keywords render, document
*/
export declare function renderMathInDocument(options?: AutoRenderOptions): void;
/**
* Transform all the children of `element`, recursively, that contain LaTeX code
* into typeset math.
*
* Read {@tutorial mathfield-getting-started | Getting Started}.
*
* @param {HTMLElement|string} element An HTML DOM element, or a string containing
* the ID of an element.
*
* @category Rendering
* @keywords render, element, htmlelement
*/
export declare function renderMathInElement(element: HTMLElement, options?: AutoRenderOptions): void;
/**
*
* @category Rendering
* @keywords revert, original, content
*/
export declare function revertToOriginalContent(element: HTMLElement,
/** The namespace used for the `data-`
* attributes. If you used a namespace with `renderMathInElement`, you must
* use the same namespace here.
*/
options?: {
namespace?: string;
}): void;
/**
* After calling {@linkcode renderMathInElement}
* or {@linkcode makeMathField} the original content
* can be retrieved by calling this function.
*
* Given the following markup:
* ```html
* <span id='equation'>$$f(x)=sin(x)$$</span>
* ```
* The following code:
* ```javascript
* MathLive.renderMathInElement('equation');
* console.log(MathLive.getOriginalContent('equation'));
* ```
* will output:
* ```
* $$f(x)=sin(x)$$
* ```
* @param {string | HTMLElement | Mathfield} element - A DOM element ID, a DOM
* element or a Mathfield.
*
* @category Rendering
* @keywords original, content
*/
export declare function getOriginalContent(element: string | HTMLElement, options?: {
/** The namespace used for the `data-` attributes.
* If you used a namespace with `renderMathInElement()`, you must
* use the same namespace here.
* @return {string} the original content of the element.
* @function module:mathlive#getOriginalContent
*/
function getOriginalContent(element: string | HTMLElement | Mathfield, options?: {
namespace?: string;
}): string;
}
* use the same namespace here. */
namespace?: string;
}): string;
{
"name": "mathlive",
"version": "0.35.1",
"version": "0.50.1",
"description": "Render and edit beautifully typeset math",

@@ -14,48 +14,30 @@ "license": "MIT",

},
"keywords": [
"math",
"editor",
"javascript",
"math-editing",
"latex",
"tex",
"mathjax",
"katex",
"mathquill"
],
"bugs": "https://github.com/arnog/mathlive/issues/",
"scripts": {
"build": "bash ./scripts/build.sh",
"clean": "rimraf build dist coverage",
"deploy": "bash ./scripts/deploy",
"deploy-ci": "bash ./scripts/deploy-ci",
"dist": "bash ./scripts/build.sh production",
"lint": "eslint --fix src/",
"start": "bash ./scripts/build.sh watch",
"test": "bash ./scripts/test.sh"
},
"main": "./dist/mathlive.js",
"module": "./dist/mathlive.mjs",
"types": "./dist/mathlive.d.ts",
"files": [
"/dist"
],
"main": "./dist/mathlive.js",
"types": "./dist/mathlive.d.ts",
"scripts": {
"clean": "rimraf build dist docs",
"build-js": "rollup --config",
"watch-js": "rollup --config --watch",
"build-corecss": "lessc css/mathlive.core.less dist/mathlive.core.css",
"build-othercss": "lessc css/mathlive.less dist/mathlive.css",
"build-postcss": "postcss dist/*.css -d dist",
"build-css": "npm-run-all -s build-corecss build-othercss build-postcss",
"watch-css": "chokidar \"css/*.less\" --initial -c \"npm run build-css -s\"",
"build-ts-types": "jsdoc -t node_modules/tsd-jsdoc/dist -d ./build -a public -r ./src/",
"build": "npm-run-all build-css build-ts-types build-js",
"watch": "npm-run-all -p watch-*",
"http-server": "http-server . -c-1 --cors='*' -o examples/index.html",
"start": "npm-run-all -p watch-js watch-css http-server",
"lint": "prettier --ignore-path ./.prettierignore --write \"**/*.{ts,js,css,md,yml,json}\" \"!dist/**\" \"!docs/**\" \"!examples/**\"",
"test": "tape -r @babel/register test/* | tap-spec",
"watch-test": "chokidar \"src/*.js\" -c \"npm run test -s\" ",
"coverage": "nyc npm run babel-node ./test/test.js && nyc report",
"coverage:report": "nyc report",
"prepare": "",
"docs": "jsdoc -c ./jsdoc.conf.json && printf \"docs.mathlive.io\" > docs/CNAME",
"watch-docs": "chokidar \"src/*.js\" \"tutorials/*.md\" \"examples/*.md\" -c \"npm run docs -s\"",
"dist": "npm-run-all -s clean build docs",
"deploy": "bash ./scripts/deploy",
"deploy-ci": "bash ./scripts/deploy-ci"
"prettier": {
"singleQuote": true,
"trailingComma": "es5",
"endOfLine": "lf",
"tabWidth": 4,
"jsxSingleQuote": true
},
"prettier": "@cortex-js/prettier-config",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
"pre-commit": "lint-staged",
"pre-push": "npm run dist"
}

@@ -77,14 +59,4 @@ },

},
"nyc": {
"exclude": [
"test",
"**/debug.js",
"dist",
"build"
],
"report-dir": "./build/coverage",
"reporter": "html"
},
"engines": {
"npm": ">=6.13",
"npm": ">=6.14",
"node": ">=10.0"

@@ -106,35 +78,42 @@ },

],
"bugs": "https://github.com/arnog/mathlive/issues/",
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@babel/register": "^7.9.0",
"@cortex-js/prettier-config": "^1.0.0",
"autoprefixer": "^9.7.5",
"chokidar-cli": "^2.1.0",
"@types/jest": "^25.2.1",
"@types/node": "^13.13.5",
"@typescript-eslint/eslint-plugin": "^2.31.0",
"@typescript-eslint/parser": "^2.31.0",
"autoprefixer": "^9.7.6",
"cssnano": "^4.1.10",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-prettier": "^3.1.2",
"eslint-watch": "^6.0.1",
"http-server": "^0.12.1",
"husky": "^4.2.3",
"jsdoc": "^3.6.3",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"http-server": "^0.12.3",
"husky": "^4.2.5",
"jest": "^26.0.1",
"less": "^3.11.1",
"lint-staged": "^10.0.9",
"npm-run-all": "^4.1.5",
"nyc": "^15.0.0",
"postcss-cli": "^7.1.0",
"prettier": "^2.0.2",
"lint-staged": "^10.2.2",
"postcss-cli": "^7.1.1",
"prettier": "^2.0.5",
"rimraf": "^3.0.2",
"rollup": "^2.2.0",
"rollup": "^2.8.1",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-eslint": "^7.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^5.3.0",
"sutro-jsdoc-theme": "^1.0",
"tap-spec": "^5.0.0",
"tape": "^4.13.2",
"tsd-jsdoc": "^2.4.0"
"rollup-plugin-typescript2": "^0.27.0",
"ts-jest": "^25.5.0",
"typescript": "^3.8.3"
},
"dependencies": {}
"dependencies": {},
"keywords": [
"math",
"editor",
"javascript",
"math-editing",
"latex",
"tex",
"mathjax",
"katex",
"mathquill"
]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with âšĄïž by Socket Inc