Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 10:04
    faxinwang opened #1015
  • 09:36
    physedo opened #1014
  • Jun 15 19:27
    stefnotch opened #1013
  • Jun 15 11:40
    physedo opened #1012
  • Jun 12 19:41
    physedo opened #1011
  • Jun 12 14:01
    dependabot[bot] labeled #1010
  • Jun 12 14:01
    dependabot[bot] opened #1010
  • Jun 12 14:01
    dependabot[bot] labeled #1009
  • Jun 12 14:01
    dependabot[bot] opened #1009
  • Jun 12 11:34
    physedo opened #1008
  • Jun 11 12:04
    arnog closed #780
  • Jun 11 12:04
    arnog commented #780
  • Jun 11 12:01
    arnog closed #938
  • Jun 11 12:01
    arnog commented #938
  • Jun 11 12:01
    arnog closed #954
  • Jun 11 12:01
    arnog commented #954
  • Jun 11 12:00
    arnog unpinned #500
  • Jun 11 12:00
    arnog commented #500
  • Jun 11 09:48
    arnog closed #7
  • Jun 11 09:48
    arnog opened #7
Arno Gourdol
@arnog
@kubaPod If you modify the Vue wrapper (just copy it and make your own version, it's just a few lines of boilerplate code), you can make the changes I suggest above so that the model (value) will use the MathML format. That seems like the simplest way to achieve what you are looking for.
Kuba Podkalicki
@kubaPod
@arnog I will give it a try, thanks!
Arno Gourdol
@arnog
@kubaPod 👍let me know how it goes. Good luck!
Arno Gourdol
@arnog
I have pushed mathlive@0.69.0 to npm.
As promised, this is the release that drops a number of deprecated functions. The Changelog includes information about how to upgrade the deprecated calls, if you haven't already (most have been deprecated for over a year).
Of note as well, if you use TypeScript, this release require TypeScript 4.3 (one of the accessor as an assymetric getter/setter, which is now supported in this version of TypeScript).

0.69.0 (2021-06-09)

Breaking Changes

  • This release requires TypeScript 4.3 or later (the API uses assymetric
    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(), latexToSpeakableText
    convertLatexToSpeakableText, 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.

Bug Fixes

  • 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.
Arno Gourdol
@arnog
For the next couple of weeks at least I am going to focus on making improvements to MathJSON, and more specifically the Compute Engine. I am working on implementing ComputeEngine.evaluate() which will evaluate symbolically an expression so that ComputeEngine.evaluate(["Add", "x", "x", "3", "2"]) will return ["Add", ["Multiply", 2, "x"], 5] for example...
As a result, expect fewer changes in the MathLive editor, except for bug fixes.
stefnotch
@stefnotch
Stefnotch@STEFNOTCH-PC MINGW64 ~/Documents/GitHub/Tools/starboard-mathlive (main)
$ npm i
npm ERR! code 127
npm ERR! path C:\Users\Stefnotch\Documents\GitHub\Tools\starboard-mathlive\node_modules\mathlive
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c bash ./scripts/postinstall.sh
npm ERR! bash: ./scripts/postinstall.sh: No such file or directory

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Stefnotch\AppData\Local\npm-cache\_logs\2021-06-09T12_41_33_990Z-debug.log
Well, it's apparently still impossible to install mathlive on Windows. :/
I'm not entirely sure if the postinstall hook is indeed the correct hook to use arnog/mathlive@e03dc62
It seems like the hook should only get invoked for people developing mathlive and not for end users trying to install mathlive into their project?
Kuba Podkalicki
@kubaPod
@stefnotch I failed too, even with git bash as suggested somewhere. So I ended up working with 0.68.0 which installs fine.
stefnotch
@stefnotch
Would using the prepare hook instead fix this? As in, something like "prepare": "bash ./scripts/postinstall.sh && bash ./scripts/build.sh production",
Arno Gourdol
@arnog
@stefnotch oh... I see, yeah it fails because the scripts directory is not in the npm archive. You're right that this hook is only needed for people developing mathlive: it's used to make sure the code gets linted/tested before being pushed to the repo.
Arno Gourdol
@arnog
ok, I've published mathlive@0.69.1 that attempts to address this issue. Let me know if that resolves it.
stefnotch
@stefnotch
@arnog Have you published it to npm or just GitHub? Because I can't find it on npm
Arno Gourdol
@arnog
I've tried to publish it to npm, and I didn't get an error message... Maybe there's some backup in the npm processing queue?
Arno Gourdol
@arnog
I got the confirmation emails from npm. I've published another version just in case, but it looks like the npm website is not updating.
zoranpopovic
@zoranpopovic
latest version builds on windows
zoranpopovic
@zoranpopovic
@arnog, here's a quick video of our Algebra diasgnostics tool now fully running on Mathlive. Note multi-selection, equation transformations animated, dynamic input box, add-to-both-sides etc (some of which needed some pretty complex manipulatoin of the mathlive dom fragments.
https://youtu.be/cM0SAX-7cYg
nikoschen
@nikoschen
image.png
nikoschen
@nikoschen
image.png
Arno Gourdol
@arnog
@zoranpopovic this is really impressive! I didn't know you could do that with MathLive! 😀Thanks for sharing.

@nikoschen In mathematical notation, abc is interpreted as a \times b \times c. If you have some multi-letter variables in your formula, you can declare them using a custom Latex dictionary:

const latexSyntax = new LatexSyntax(
  {
    promoteUnknownSymbols: /^[a-z]+/,
    dictionary:
      [
        ...LatexSyntax.getDictionary(),
        {
          name: 'Speed',
          trigger: { symbol: ['s', 'p', 'e', 'e', 'd'] }
        }
      ]
  });
latexSyntax.parse('3speed'))
// -> ["Multiply", 3, "Speed"]

Note that you can also indicate which variables should be automatically promoted to symbols using the promoteUnknownSymbols regex pattern.

And the lcm function is currently not in the default dictionary, but I will add it shortly.
Kuba Podkalicki
@kubaPod
@arnog fyi, MathJSON seems to be isomorphic to ExpressionJSON in Wolfram Language/Mathematica (https://reference.wolfram.com/language/ref/format/ExpressionJSON.html) which makes me, as WL user, even more excited about your project.
stefnotch
@stefnotch
@arnog Thank you! I can also confirm that the latest version (0.69.2) works perfectly on Windows
Arno Gourdol
@arnog
@kubaPod uh! I did not know about ExpressionJSON. That's... fascinating. I guess I could have saved some time if I had known about it earlier, but then again, it's kinda a validation that I am on the right track I suppose...
It's amazing they even have the same way to represent strings (as "'string'")...
Kuba Podkalicki
@kubaPod
@arnog These days you can create a demo account for the web interface for WL aka Wolfram Cloud, https://www.wolframcloud.com/ so you can do your own tests. But if you need any feedback just let me know.
Arno Gourdol
@arnog
@kubaPod oh yeah, I have an account, I just never ran into ExpressionJSON... There's just so much in Mathematica these days...
zoranpopovic
@zoranpopovic
right now x \cdot a is spoken as 'X' times a, which produces a short a sound. is there a way for all variables to be quoted during speech conversion?
Arno Gourdol
@arnog
That's odd. It should be 'X' times 'A'. What are you speech configurations?
stefnotch
@stefnotch
I just discovered something random and odd:
Type \ to enter command mode. Then hit the right arrow key and notice how the cursor seems to jump a bit further. Then, type some characters like abc and hit Enter
image.png
And then, repeatedly hold the right arrow key and then the left arrow key to move the caret over the characters.
image.png
\begin{equation*} \a\\\\b\\ \end{equation*}
zoranpopovic
@zoranpopovic
@arnog all settings are default.
Edin
@physedo
Error: node_modules/mathlive/dist/public/mathfield-element.d.ts:759:9 - error TS2380: 'get' and 'set' accessor must have the same type. [ng] 759 get selection(): Selection; [ng] ~~~~~~~~~ [ng] Error: node_modules/mathlive/dist/public/mathfield-element.d.ts:764:9 - error TS2380: 'get' and 'set' accessor must have the same type. [ng] 764 set selection(value: Selection | Offset); [ng] ~~~~~~~~~
I get this error in latest version Version
0.69.3
stefnotch
@stefnotch
@physedo That's related to the Typescript version. Only the latest version of Typescript supports getters and setters with different (compatible) types.
I found another little thing, I'm not sure if this is a bug. Typing \int followed by Enter and then typing 3 results in perfectly fine looking mathematics. However, copying and pasting it does not
image.png
\begin{equation*} \int3 \end{equation*} (issue won't reproduce if you copy-paste this, you actually have to type the characters)
stefnotch
@stefnotch
^ This seems to be because it doesn't get serialized as correct mathjson. (["Integral","","Nothing","Nothing"]{"num":"3"} is the MathJson result)
Edin
@physedo
@stefnotch thanks I forgot to update