grok
, the API documentation tool that turns a TypeScript file into HTML (https://github.com/ui-js/grok)
0.70.0
uses the Compute Engine to parse LaTeX and to serialize MathJSON
math-json
as a format option to setValue
, i.e. .setValue(["Add", 2, "x"], {format: "math-json"})
Thank you @arnog. That was really quick. I can now .setValue
to ["Add", 2, "x"]
and .getValue('math-json'))
returns exactly what was set i.e. ["Add", 2, "x"]
.
When I set value to ["Divide", "weight", ["Square", "height"]]
(it's Body Mass Index formula), the rendering in browser works as expected, however, the getValue('math-json')
returns something that is very far from what was set: ["Divide",["Error","Missing","'unknown-command'",["LatexForm","'\\mathrm{weight}'"]],["Power",["Delimiter",["Error","Missing","'unknown-command'",["LatexForm","'\\mathrm{height}'"]]],2]]
.
The backstory is I have built a python API that solves MathJSON expressions. In my example the weight
and height
are obviously outside of the supported MathJSON vocabulary, so my python API recognizes that and looks for actual weight
and height
values elsewhere to plug them in the expression to solve. I'd be willing to change my API to make it more compatible with math-field
generated MathJSON as it would be much less work than to create another equation builder.
The question is - how to use variables that are longer than a single character?
head
, or wait until I push a tag to npm. If you are using a CDN, I need to make a build and push an update, then you can update to this version.
Hello. Can anyone help/tell me - is it possible to do this with mathlive?
I have a set of variables L1, L2, L3, ... LN. Each of these variables has a set of properties, one of which is a visual representation such as "A" , "B" , "C" , etc. Representations for variables can be the same.
There is a formula "L1 + L2 + L3". I need to be able to edit it using mathlive. But using visual representation
For example, there are variables
L1 = {view: V, id: 1, name: Variable1 }
L2 = {view: S, id: 2, name: Variable2 }
L3 = {view: V, id: 3, name: Variable3 }
There is a formula L1 + L2 + L3
It is necessary to represent via mathlive as
V + S + V
Is it possible when entering a variable, for example, through a macro, so that its meta description is still preserved, and in the future it would be possible to convert back to L1 + L2 + L3
Also, is it possible to display a hint when hovering over a variable in a matnlive?
@KondakovArtem yes, you could do something like that by defining a macro. The arguments to the macro would include both the name of the variable and its visual representation, but would only display its visual representation.
You could do this using:
mf.setOptions( { macros: { var: "#2" } })
Then using this in LaTeX: \var{Variable1}{V}
, and it would display V
. However, you would get back the LaTeX as \var{Variable1}{V}
which would allow you to associated it back to L1 (or you could use L1
directly instead of Variable1
).
There is currently no support do display a hint/tooltip, but if someone wants to contribute support for it (there is a semi-standard \tooltip
LaTeX command), I'd be happy to merge it.