Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mathlive

Package Overview
Dependencies
Maintainers
1
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mathlive - npm Package Versions

1
18

0.69.1

Diff

Changelog

Source

0.69.1 2021-06-09

Improvements

  • Attempt to fix installation of the npm package on some Windows configurations
arnog
published 0.69.0 •

Changelog

Source

0.69.0 2021-06-09

Breaking Changes

  • This release requires TypeScript 4.3 or later (the API uses asymmetric getters/setters). If you are using VSCode, you may need to change the version of TypeScript used by the editor for language services (syntax checking). To do so, with a TypeScript file open, click the Typescript version in the bottom bar, then choose "Select TypeScript Version", then "Use Workspace Version" (see https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-newer-typescript-versions)

  • All the default imports have been removed. Instead of

import MathLive from 'mathlive';
MathLive.renderMathInDocument();

use:

import { renderMathInDocument } from 'mathlive';
renderMathInDocument();

If you are not calling a specific MathLive function and just need to use the <math-field> tag, use:

import from 'mathlive';
  • The following deprecated functions have been removed: latexToMathML()convertLatexToMathMl(), latexToSpeakableTextconvertLatexToSpeakableText, latexToMarkup()convertLatexToMarkup(),
  • The deprecated revertToOriginalContent functionality has been removed.
  • The deprecated overrideDefaultInlineShortcuts property has been removed. Instead, use:
mf.setConfig('inlineShortcuts', {
  ...mf.getConfig('inlineShortcuts'),
  ...newShortcuts,
});
  • The following MathField functions have been removed: $setConfig()setOptions(), getConfig()getOptions(), $perform()executeCommand(), $text()getValue(), $selectedText()getValue(), $selectionIsCollapsed(), $selectionDepth(), $selectionAtStart(), $selectionAtEnd(), $latex()getValue()andsetValue(), $el, $insert()insert(), $hasFocus()hasFocus(), $focus()focus(), $blur()blur(), $select()select(), $clearSelection()executeCommand('delete-backward'), $applyStyle()applyStyle(), $keystroke(), $typedText()

  • The makeMathField() function has been removed. Use new MathfieldElement() or the <math-field> tag instead:

// Before
let mf = MathLive.makeMathField(document.createElement('div'), {
  virtualKeyboardMode: 'manual',
});
mf.$latex('f(x) = \\sin x');
document.body.appendChild(mf.$el());

// After
let mfe = new MathfieldElement({
  virtualKeyboardMode: 'manual',
});
mfe.value = 'f(x) = \\sin x';
document.body.appendChild(mfe);

or:

<math-field virtual-keyboard-mode="manual">f(x) = \sin x</math-field>

Improvements

  • Added localization for Dutch (contributed by @harrisnl), Bosnian, Croatian, Czeck, Danish, Estonian, Finnish, Icelandic, Norwegian, Portuguese, Serbian, Slovak, Slovenian, Swedish, Turkish (contributed by @physedo).
  • The selection can now be set using an offset, i.e. mf.selection = 0 instead of mf.selection = { ranges:[[0, 0]] }.
  • Map \cdot to "times" in spoken-text format.
  • #994 When using virtualKeyboardContainer, the virtual keyboard is now displayed inside the container. The container should have a position of relative.
  • When replacing a placeholder with a LaTeX command in LaTeX mode (by pressing the \ key), remove the \placeholder{} command.
  • In spoken text, correctly handle \mathop and \operatorname.

New Features

  • The getOffsetDepth() method can be used to query the depth of a specific offset. Use mf.getOffsetDepth(mf.position) for the depth of the current position.
  • the onExport() hook provides an opportunity to customize the format exported to the Clipboard.

Issues Resolved

  • Actually change the keyboard toggle glyph when changed with setOptions
  • Reparse the formula when the macros dictionary is updated
  • #971 In some browsers, when mathfield elements are contained in a container with overflow: scroll, the dimensions of the viewport would be incorrectly affected.
  • #974 With non-US keyboard layout, always map the "/" key to a fraction.
arnog
published 0.68.1 •

Changelog

Source

0.68.1 2021-06-02

Improvements

  • Keybindings: keybindings can now be associated with specific keyboard layouts. By default, the keybindings that are specific to the US keyboard layout are no longer applied with other keyboard layouts. This makes it easier to use punctuation with some keyboard layouts and prevent some error messages from being thrown (addresses #962).

  • MathML: improved MathML output, especially for formulas with unbalanced delimiters

Issues Resolved

  • #969 and #967 Changed the way the build is done so that MathLive does not use MathJSON as a submodule but as a regular npm dependency, and builds correctly even in non-git environments.
  • #968 navigating with arrow keys cannot navigate past a macro
arnog
published 0.68.0 •

Changelog

Source

0.68.0 2021-05-31

Breaking Changes

#500 MathJSON support. The legacy MASTON/JSON format has been removed.
The MathJSON format is now integrated into MathLive 🚀 🎆 🥳

To get the MathJSON representation of a formula, use mf.getValue('math-json').

The latexToAST() and astToLatex() functions have been replaced by parseMathJson() and serializeMathJson().

import { parseMathJson, serializeMathJson } from 'mathlive';

MathJSON has an extensive API that supports parsing and serializing of custom LaTeX expressions. You can use it to define your own LaTeX "vocabulary" and "grammar" and transform it into MathJSON.

You can also convert MathJSON expressions into several canonical forms, do symbolic computation with MathJSON expressions, for example to compare them, and more.

Learn more at cortexjs.io/math-json/.

New Features

  • #952 It is now possible to define variants with keycaps in a custom keyboard. These variants are displayed with a long press on the keycap.
  • #955 When navigating with the arrow keys but there is nowhere to go, a move-out event is dispatched (or the lower-level onMoveOutOf hook is invoked, but using the event is recommended). This is an opportunity to handle this situation, for example by changing the focus to another element. To get the default behavior, which is to play a "plonk" sound, do not cancel the event. To prevent the "plonk" sound from playing, use evt.preventDefault(). Note tha previously a focus-out event was dispatched in this case, but since the focus is actually not changed by default, this was incorrect.

Improvements

  • The SpeechScope argument of the speak command is now optional.
  • Display the keys in the keystroke caption panel (alt/option+shift+K) in chronological order from left to right.
  • Do not inject stylesheets or placeholder elements for the popover panel, keystroke caption panel or virtual keyboard until actually needed, which may be never and thus result in a smaller DOM.

Architecture

  • The library is now null-safe, i.e. it compiles with the Typescript flag strictNullChecks. This will ensure that the public Typescript declaration file also compile with strictNullChecks if you make use of it in your own project.

Issues Resolved

  • #948 The Typescript declaration of set plonkSound() failed when compiled with strictNullChecks.
  • When using a mathfield as a web component, the speak command would be inoperative.
  • In Chrome/Blink, when a mathfield was in a contentEditable block, inserting a line before the component would make the component crash. Now the component is correctly disconnected, then reconnected and preserves its state across the disconnection.
  • #960 Typing "e^pi" would result in e\pi instead of e^\pi. Also, serializing some partial formulas, such as "e^" would result in incorrect LaTeX (e.g. "e").
  • In MathML serialization, 2^3 was not serializing the superscript (#951 ) and subscripts were not serialized for various constructs( #534).
arnog
published 0.67.0 •

Changelog

Source

0.67.0 2021-05-21

New Features

  • Added \overarc, \underarc, \overparen and \underparen commands.

Improvements

  • When replacing a selected range, snapshot in the undo state the collapsed selection before inserting the replacement.

Issues Resolved

  • Correctly calculate the padding for enclose atoms (broken in 0.66)
  • Setting the keypressSound to null would not turn off the sounds. Setting it to the string "null" did, though.
  • An input event would incorrectly bubble out of the mathfield, even in read-only mode.
  • When calling getOption(), or when examining a property on MathfieldElement, return the actual value, rather than an object literal that contains the value.
  • If the mathlive module was loaded before the <math-field> element was parsed in the document, the attributes of the mathfield would be ignored.
arnog
published 0.66.1 •

Changelog

Source

0.66.1 2021-05-21

Issues Resolved

  • Revert improvements where the display property of the mathfield would change depending on the default-mode property. This had unintended consequences in some cases. To control the layout of the mathfield, use style="display:inline-block;" instead.
  • When using applyStyle(), if a non-RGB color (e.g. "yellow") was used, it would not be applied to the selection.
  • When using applyStyle() if the font size was changed, it was always set to font size 1 (tiny).
  • Macro packages were incorrectly parsed
arnog
published 0.66.0 •

Changelog

Source

0.66.0 2021-05-20

Breaking Changes

  • The horizontalSpacingScale option is deprecated. It will be removed in an upcoming version and replaced by the standard TeX registers \thinmuskip, \medmuskip and \thickmuskip.

Improvements

  • When the default-mode attribute (or the defaultMode property) of a <math-field> element is set to "inline-math", the element will be displayed as an inline element. Previously, the defaultMode affected the layout of the math content, but the element still behaved as a block.
  • renderMathInDocument() now creates a <div> when using Display Style, and a <span> when using Text Style (inline math).

New Features

  • #946 Support addding a custom stylesheet to a <math-field> when using the \class command.
  • The mathfield options which are reflected as attributes (e.g. virtual-keyboard-mode) are now reflected as a property on the element mf.virtualKeyboardMode as a shortcut to mf.setOptions({virtualKeyboardMode:...}. This also allows to set these properties before the component is connected to the document.
  • Added the following attributes to <math-field>: plonk-sound, keypress-sound. Setting them to 'none' turn off these sounds.
  • Added support for definition of macro packages (see MacroPackageDefinition)
  • Added support to selectively expand macro definitions. This avoid expanding common macro definitions (for example from amsmath.sty) when copying/pasting, while still expanding custom macros for improved compatibility.
  • Added support for MediaWiki commands:
  • \darr
  • \dArr
  • \Darr
  • \lang
  • \rang
  • \uarr
  • \uArr
  • \Uarr
  • \N
  • \R
  • \Z
  • \alef
  • \alefsym
  • \Alpha
  • \Beta
  • \bull
  • \Chi
  • \clubs
  • \cnums
  • \Complex
  • \Dagger
  • \diamonds
  • \empty
  • \Epsilon
  • \Eta
  • \exist
  • \harr
  • \hArr
  • \Harr
  • \hearts
  • \image
  • \infin
  • \Iota
  • \isin
  • \Kappa
  • \larr
  • \lArr
  • \Larr
  • \lrarr
  • \lrArr
  • \Lrarr
  • \Mu
  • \natnums
  • \Nu
  • \Omicron
  • \plusmn
  • \rarr
  • \rArr
  • \Rarr
  • \real
  • \reals
  • \Reals
  • \Rho
  • \sdot
  • \sect
  • \spades
  • \sub
  • \sube
  • \supe
  • \Tau
  • \thetasym
  • \weierp
  • \Zeta
  • Added support for some additional amsmath commands:
  • \varGamma
  • \varDelta
  • \varTheta
  • \varLambda
  • \varXi
  • \varPi
  • \varSigma
  • \varUpsilon
  • \varPhi
  • \varPsi
  • \varOmega
  • Added support for the \displaylimits command

See Supported TeX/LaTeX Commands for more details.

Issues Resolved

  • When a mathfield is created, then immediately removed from the document, do not crash. The creation of the mathfield triggered an asynchronous rendering and by the time the rendering was executed the mathfield was no longer valid. This situattion happened when using "tippyjs" and possibly other libraries.
  • When a mathfield is read-only, do not display the focus outline.
  • #943 When a tooltip for a custom virtual keyboard was provided, the label was set to "undefined".
  • The DVIPS colors were case sensitive, they should be case sensitive. (i.e. LimeGreen is a valid color, Limegreen is not)
  • #945 Preserve more aggressively verbatim LaTeX. Also, avoid serializing superfluous spaces in Spacing atoms.
  • #770 Correctly handle attaching limits to \int command using the keyboard.
  • Return the correct value for the mathfield element when it is not attached yet, even if the output format is not specified.
  • Color specified with the rgb() function would not render correctly if the arguments contained some spaces, e.g.rgb ( 255 , 255 , 255 ).
arnog
published 0.65.0 •

Changelog

Source

0.65.0 2021-05-14

Breaking Changes

  • The substituteTextArea option has been removed. This option was in fact not working so removing it will presumably have no impact.

New Features

  • #939 Added access to \underline, \underbrace, \xleftarrow, etc... to the virtual keyboard.

Improvements

  • On iPad OS and relevant Windows devices, support the detachable keyboard.
  • In LaTeX mode, don't consider \\ (double-dash, i.e. end of line in tabular mode) as a valid command prefix.
  • In LaTeX mode, don't recommend \{ as a command by default.
  • Added \bigstar symbol
  • Improved performance of renderMathInDocument() when there are many formulas on the page.

Architecture

  • Renamed Span to Box.

Issues Resolved

  • When using Firefox on Windows, the layout of the formula could shift by a fraction of a pixel when moving the caret.
  • In LaTeX mode with nested expressions, the edited LaTeX was incorrect.
arnog
published 0.64.0 •

Changelog

Source

0.64.0 2021-05-09

Breaking Changes

  • The FontSize type is now an integer between 1 and 10. It previously was size1, size2, etc... The default font size is 5, the smallest is 1. However, when using applyStyle(), the size can still be specified with size1, etc... The following size values can also be used: tiny, scriptsize, footnotesize, small, normal or normalSize, large, Large, LARGE, huge, Huge.

  • Previously, named colors (yellow, red...) mapped to the dvips color set. They can now map to different values to improve their legibility. To ensure that a particular color is used, specify the colors as a hex triplet (#dd2233). See also the colorMap option.

    The following color names are recommended: they will map to values that have been optimized for legibility as a foreground or background color, they cover all the hues of the color circle and have been adjusted to provide similar apparent brightness and intensity:

    • colors: orange, yellow, lime, green, teal, blue, indigo, purple, magenta
    • shades of grey: black, dark-grey, grey, light-grey, white

New Features

  • The background of fractions, radicals and parentheses group (\left/\right commands) is now highlighted when they contain the caret. This makes it easier to distinguish some cases when the cursor is at the edge of the element and could be either inside or outside. The appearance of the highliting can be controlled with the <del>--contains-highlight</del> --contains-highlight-background-color CSS variable. Set it to transparent to restore the previous behavior.

  • colorMap option. To map a color name such as "yellow" to a custom RGB color, set the colorMap or backgroundColorMap option to a function that takes the color name as an argument and return a matching CSS RGB string. Return undefined to proceed with the default mapping.

  • In macro dictionary, added option to expand or not the macro when using the latex-expanded output format (when copying to the clipboard, for example).

  • Added the \overunderset{}{}{} command.

  • Added the \lparen and \rparen delimiters.

  • Added the \mod, \pmod and \bmod commands, defined as macros.

  • Added support for dashed column separators in matrix, using ":" in the matrix preamble. See the arydshln package.

  • Added support for optional below argument to \stackrel and \stackbin as per the stackrel package

  • When using renderMathInDocument() or renderMathInElement(), ASCII Math format can be used. The default delimiters for ASCII Math are "" (backtick) and can be changed with the asciiMath.delimitersoption. To turn off this conversion and revert to the previous behavior, call renderMathInDocument({ asciiMath: null })`

Layout Improvements

  • Substantial rewrite of the stacked layout algorithm (fractions, superscripts, etc...). The previous algorithm did not work correctly when mixing absolute sizing commands (\Huge) and relative ones (\scriptstyle) and had various issues and inconsistencies with what TeX produced. The result is now close to TeX.

  • Display the placeholder symbol using the caret color.

  • Added the --smart-fence-opacity and --smart-fence-color CSS variables.

  • In the layout of superscript/subscript and accents, use the correct font metrics for spacing and layout (previously, the font metric for the base size was always used). This may result in very slightly different placement of superscripts, subscripts and limits (but closer to TeX).

  • Fixed cases where the inter-atom spacing was incorrect (when spacing atoms or super/subscripts were used with a binary atom, or when some other atom types were used, such as BoxAtom and more).

Clipboard Improvements

  • When pasting from the clipboard, recognize text bracketed with \begin{math}...\end{math} or \begin{displaymath}...\end{displaymath} as LaTeX (in addition to $, $$, \[...\] and \(...\) which were recognized before). Also, recognize text that may contain a LaTeX expression surrounded by regular text (i.e. "if $x > 0$").

  • When pasting ASCIIMath, recognize more expression using standard functions such as the trig functions.

  • Recognize text content surrounded with "`" (backtick) delimiters as ASCII Math.

  • When copying to the clipboard, roundtrip verbatim latex when available, i.e. the content of the clipboard will be exactly what has been pasted in if the formula has not been edited.

Other Improvements

  • The default color mapping function now returns different values when used as a line color or as a background color. This improves the legibility of colors. See MathLive Guide: Customizing.

  • Paste operations are now undoable.

Architecture

  • Avoid generating unnecessary empty span for limits and other constructs.

  • Avoid repeating color attributes on child elements by lifting them to an appropriate parent. As a consequence, when a background color is applied it is displayed more uniformly than previously.

  • Reduced the size of the font-metrics table.

  • Increased the number of automated and static tests.

Issues Resolved

  • The size and spacing of fractions in superscript did not match the TeX layout.
  • Correctly apply TeX inter-atom spacing rules as per TeXBook p. 270. The spacing of two consecutive binary atoms (e.g. +-) was incorrect, as well as some other combinations.
  • Correctly render \sqrt, \placeholder and many other atoms when a mathstyle is applied with commands such as \textstyle, \scriptstyle, etc...
  • Correctly render selection rectangle of accent commands (\widehat).
  • If a document called renderMathInDocument() and the document contained a mathfield with a value that contained exclusively an environment, the mathfield would not render (the \begin{} would be incorrectly rendered by renderMathInDocument()).
  • When using renderMathInElement() or renderMathInDocument() use the same default letterShapeStyle as when using a mathfield, that is, french if the locale is French, tex otherwise.
  • Fixed verbatim latex: when the value of the mathfield is set, if it is not modified, getValue('latex') will return exactly what was input.
  • Fixed latex output of \exponentialE: when a superscript/subscript was applied to a macro, the latex output would become blank.
  • Math characters with a bold italic style were displayed in regular italic.
  • An input consisting of only \scriptstyle would crash.
  • Allow navigation inside an empty skipBoundary atom.
  • After a copy (command/control+C) command, the content of clipboard was incorrect if the end of the selection included some content in text mode.
  • When rendering a placeholder in static mode, use a non-breaking space instead of nothing, which helps preserve a more accurate layout in some cases (for example in \sqrt[\placeholder{}}{x}
  • Rules (e.g. from \rule{}{}) were not clickable and did not appear selected.
  • Correctly roundtrip \char command when using latex-expanded format.
arnog
published 0.63.0 •

Changelog

Source

0.63.0 2021-04-24

New Features

  • #788 Added virtualKeyboardState property to indicate if the virtual keyboard is currently visible or hidden. The property can also be modified to show or hide the virtual keyboard.
  • In read-only mode, do not attempt to load the sounds and do not allow the virtual keyboard to be shown.
  • Export version (previously available as MathLive.version).
  • #199 Added infty and int inline shortcuts.

Issues Resolved

  • #708 Pressing on the bottom part of the virtual keyboard keycap did not trigger the key action.
  • The asset directory (fonts/sounds) was not properly located in some browsers when using a CDN to load MathLive.
  • Correctly focus the mathfield when the virtual keyboard is invoked.
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