kqmath / tex2max Goto Github PK
View Code? Open in Web Editor NEW:books: JavaScript library for converting LaTeX math into Maxima code
Home Page: https://www.npmjs.com/package/tex2max
License: GNU General Public License v3.0
:books: JavaScript library for converting LaTeX math into Maxima code
Home Page: https://www.npmjs.com/package/tex2max
License: GNU General Public License v3.0
There is an unresolved merge conflict in the post-parser.js
file.
Lines 176 to 192 in fb50ee0
Only the matrix
matrix environment works, even though other types such as pmatrix
is susposed to be supported.
This fails:
\begin{pmatrix}
1 & 2\\
3 & 4
\end{pmatrix}
while this works as expected:
\begin{matrix}
1 & 2\\
3 & 4
\end{matrix}
Would be really nice if tex2max supported parsing strings like ln|x| and transpiled them to ln(abs(x)). Seems doable, and I don't mind taking this on as I need it as soon as possible but if I could get some advice on where/how to start that'd be awesome. Thanks!
Functions with special notation in it’s arguments, only reads the first value after the special notation.
E.g. \lim_{x\to1+2}x results in limit((x),x,(1)), rather than limit((x),x,(3)).
Note: it works if the values are wrapped in parenthesis (aka. a group).
Decimal numbers are currently supported. However, only support for decimal points .
are implemented while decimal commas ,
aren't.
It should be possible to implement decimal commas. However, there are some caveats that needs to be resolved first. See issue #44. This is also related to issue #47 and #48.
When the issues above are resolved, it should be made optional whether to allow only decimal points or decimal commas as input (in floating numbers). As default it should be possible to use both types as input.
Since Maxima only allows decimal points in floating numbers, all transpiled floating numbers should only contain decimal points.
E.g. \lim_{x\to\infty}x doesn't convert to limit(x,x,inf), but to limit(x,x,infty).
Applies (for now) to onlyGreekName and onlyGreekSymbol.
E.g. expression sin xy should yield sin (xy), not sin (x)*y.
When i use LaTeX expressions like '\\sin(x)+\\cos(x)'
, the produced output is 'sin(x)cos(x)'
, but the output should be 'sin(x)+cos(x)'
; the same happends with operators like +,-,*,/
and expressions like \\sin(x)+\\cos(x)+...+\\tan(x)
or \\sin(x)+\\frac{3x}{2}
. It seems that only happens when the LaTeX expression have a trigonometric function and later an operator.
Accepted inputs should be on the form sin^(-1) x and arcsin x. These should be transpiled to the form asin x.
Describe the bug
When I try to import tex2max
using declare var tex2max: any;
I get a ReferenceError: tex2max is not defined
. But this doesn't occur with other packages. I have tried binding the scripts by installing the npm package and through the script tag in index.html
To Reproduce
Steps to reproduce the behavior:
npm install tex2max --save-dev
Expected behavior
tex2max object should be created, I need the toMaxima() method specifically
Desktop (please complete the following information):
Feel free to close or delete this issue, but I just wanted to say thank you for this library! Just saved me many hours of doing this myself. Let me know if there's anything I can do to help with the project.
Unit tests should be added to maintain code health, ensure code coverage, and detect errors and faults.
AVA should be used as testing framework.
Lists aren't currently supported.
In Maxima, to construct a list, one should write [...]
.
For example, [a, b, c]
.
See the Maxima manual - Lists.
Is it possible to add support for logarithms with different bases by formula log_a(b) = log(b)/log(a)
?
\log _2(10)
=> (log(10)/log(2))
\log _{2-x}\(\frac{5+2}{x^2})
=> (log(\frac{5+2}{x^2})/log(2-x))
P.S. Thanks a lot for the great library!
The LaTeX expression \frac{1}{2}^2
produces (1)/(2)^2
.
Fractions should be wrapped in another set of brackets, like this: ((1)/(2))^2
.
The tex2max.js
file is currently not working. This is most likely a breaking change in the Webpack version.
When trying to run the file in the browser, it complains about SyntaxError: Invalid regular expression: range out of order in character class
.
When LaTeX expression contains mathematical constants "e" and "pi", it's impossible to run in Maxima: for example \lim_{x\to\pi}(e^x)
converts to limit(((e^x)),x,(pi))
Perhaps it should be converted to limit(((%e^x)),x,(%pi))
(with %) or is this how it should be?
When onlySingleVariables is true and addTimesSign option is false, writing a variable name longer than one character should result in an exception being thrown.
For maxima to calculate with symbolic constants, they need to be prepended with a % sign.
See the Maxima documentation on Functions and Variables for Constants.
The symbolic constants should be handled as macros. See the macros.js file, and the doToken() function.
Input | Output | |
---|---|---|
onlyGreekName | onlyGreekSymbol | |
e | %e | |
i | %i | |
\gamma | %gamma | γ |
\phi | %phi | ϕ |
\pi | %pi | π |
Decimals aren't supported.
Both decimal point .
and comma ,
should be supported.
This means that they needs to be defined as accepted tokens, see tokens.js. Further, they need to be parsed as being a part of a number. This should most likely be implemented in the parseNumber
function in the parser.js file.
Sets aren't currently supported.
In Maxima, to construct a set, one should write set(...)
or {...}
.
For example, set(a, b, a)
or {a, b}
.
To construct the empty set, write set()
or {}
.
See the Maxima manual - Sets.
Some LaTeX functions are defied within the macro operatorname. MathQuill does this with e.g. the function "arccsc": \operatorname{arccsc x}.
Dear developer, thanks a lot for the great project!
I am completely a newbie in programming. I would like to have an html input output interface that I can use instantly. I tried to learn a little html and javascript and have written a stupid html with the following code, which does not work at all. Could you please help make it work? Or even better, you can provide a better version? Thanks a lot anyway!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tex2max</title>
<script src="C:/Users/dell/node_modules/tex2max/lib/tex2max.js">
const tex2max = require('tex2max');
const converter = new tex2max();
</script>
</head>
<body>
<form oninput="y.value=converter.toMaxima(z.value)">
LaTeX: <input type="text" id="z" value=" "><br>
Maxima: <output name="y" for="z"></output>
<br>
converter.toMaxima("z.value")
z.value
</body>
</html>
hgThe following was received back in February. Has it been reviwed? If it has already been addressed, the issue can be closed.
:-- hg
We found a potential security vulnerability in a repository for which you have been granted security alert access.
KQMATH/tex2max
https://github.com/KQMATH/tex2max
Known low severity security vulnerability in lodash v< 4.17.11, defined in https://github.com/KQMATH/tex2max/blob/develop/package-lock.json
https://github.com/KQMATH/tex2max/blob/develop/package-lock.json update suggested: lodash v4.17.11
Always verify the validity and compatibility of suggestions with your codebase.
Review the vulnerable dependency:
https://github.com/KQMATH/tex2max/network/alert/package-lock.json/lodash/open
Only users who have been assigned access to security alerts will receive these notifications.
here is the tex2max instance from the console:
TeX2Max {options: {…}, lastInput: "", lastResult: ""}
options:
----------------
onlySingleVariables: false
handleEquation: false
addTimesSign: true
onlyGreekName: false
onlyGreekSymbol: false
debugging: false
disallowllowDecimalCommas: false
lastInput: "\sin(x+t)\cdot x"
lastResult: "sin(x+t)x"
structure: (4) [{…}, {…}, {…}, {…}]
----------------
lastResult: "sin(x+t)x",
The last result is: sin(x+t)x
.
I expected to see: sin(x+t)*x
.
The LaTeX expression \sin x\cos y
produces sin(x*cos(y))
.
Trigonometric functions should only include the subsequent expressions that isn't +
, -
, +-
or any type of function
as their argument.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.