-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7af8d1
commit 9b04430
Showing
5 changed files
with
154 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
|
||
## [Unreleased] | ||
|
||
|
||
## [1.1.0] - 2020-3-9 | ||
### Added | ||
- Tests for the basic arithmetics and autoMult option | ||
- Tests for options.functions | ||
- Preparing input before parsing, enabling parsing when the passed expression has some unimportant groups such as `as{da } ^{13}{/6}` -> `as da ^{13} /6 ` | ||
- Types "prod", "sqrt" to Node types. | ||
|
||
|
||
### Changed | ||
- the error message when parsing `\dfhgw`, which is not defined, the parser throw "undefined control sequence dfhgw"; | ||
- Sqrt now is parsed with type = "sqrt" not "function" as before. | ||
|
||
### Fix | ||
|
||
- `\lef( [expression] \right)`: an error was thrown when we try to parse such an epxression, it considered right as control sequance name | ||
- Make the argument for BlockParentheses instance of Array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,125 @@ | ||
# math-latex-parser | ||
A mathematical parser for latex in math mode. We mean by mathematical that, arithmetic operations is considered for example if you pass "1+2", the result would by a (add node "+") with two children nodes of type number. | ||
A mathematical parser for latex in math mode. We mean by mathematical that, arithmetic operations are considered. For example, if you pass "1+2", the result would by a (add node "+") with two children nodes of type number. | ||
|
||
# Install | ||
|
||
``` | ||
npm i @scicave/math-latex-parser | ||
``` | ||
|
||
# Usage | ||
|
||
```js | ||
const {parse} = require('@scicave/math-latex-parser'); | ||
|
||
console.log(parse('12+3^6x \\frac 1 {5+3}')); | ||
/* | ||
You ge some thing like this | ||
Notice: this is just a prototype, the result is more verbose. | ||
{ | ||
"name": "+", | ||
"type": "operator", | ||
"args": [ | ||
12, | ||
{ | ||
"type": "automult", | ||
"args": [ | ||
{ | ||
"type": "automult", | ||
"args": [ | ||
{ | ||
"name": "^", | ||
"type": "operator", | ||
"args": [ | ||
3, | ||
6 | ||
] | ||
}, | ||
"x" | ||
] | ||
}, | ||
{ | ||
"type": "frac", | ||
"args": [ | ||
1, | ||
{ | ||
"name": "+", | ||
"type": "operator", | ||
"args": [ | ||
5, | ||
3 | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
*/ | ||
``` | ||
|
||
You can also pass options to the parse function: | ||
|
||
```js | ||
console.log(parse(tex, options)); | ||
``` | ||
|
||
# Options | ||
|
||
## autoMult: boolean | ||
> Default: `true` | ||
You can parse some thing like this `3^6cd\\sqrt af`, if false, the previous latex expression will throw an error while being parsed. | ||
|
||
## singleCharName: boolean | ||
> Default: `true` | ||
if you want to use `asdas{d } _ {asdasd123}` as id for variable of function (see options.functions here below), you have to set options.singleCharName to false. | ||
|
||
## functions: string [] | ||
> Default: [] | ||
Acceptable values: Array of checkers, which are functions or regex or another checker[]. | ||
|
||
this is useful in some cases like, `f(x)`, or `f\left(x\right)`, the function id here is `f`, you can use `blablabla` when singleCharName is `false`. | ||
|
||
## operatorNames: checker[] | ||
> Default: [ | ||
"floor", "ceil", "round", "random", "factorial", | ||
"sech", "csch", "coth", "abs", "arsinh", "arcosh", | ||
"artanh", "arasinh", "aracosh", "aratanh", | ||
] | ||
|
||
Acceptable values: Array of checkers, which are functions or regex or another checker[] | ||
|
||
Some expressions such as `\operatorname{floor}` are valid, when one of the checkers processes `floor` and return `true`. | ||
|
||
## builtInControlSeq: checker[] | ||
> Default: [ | ||
"alpha", "Alpha", "beta", "Beta", "gamma", "Gamma", "pi", "Pi", "varpi", "phi", "Phi", | ||
"varphi", "mu", "theta", "vartheta", "epsilon", "varepsilon", "upsilon", "Upsilon", | ||
"zeta", "eta", "Lambda", "lambda", "kappa", "omega", "Omega", "psi", "Psi", | ||
"chi", "tau", "sigma", "Sigma", "varsigma", "rho", "varrho", "Xi", "xi", "nu", | ||
"imath", "jmath", "ell", "Re", "Im", "wp", "Nabla", "infty", "aleph", "beth", | ||
"gimel", "comicron", "iota", "delta", "thetasym", "omicron", "Delta", "Epsilon", | ||
"Zeta", "Eta", "Theta", "Iota", "Kappa", "Mu", "Nu", "Omicron", "Rho", "Tau", "Chi" | ||
] | ||
|
||
Acceptable values: Array of checkers, which are functions or regex or another checker[] | ||
|
||
## builtInFunctions: checker[] | ||
> Default: [ | ||
"sinh", "cosh", "tanh", | ||
"sin", "cos", "tan", "sec", "csc", "cot", | ||
"arcsin", "arccos", "arctan", "arcsec", "arccsc", "arccot", | ||
"ln" | ||
] | ||
|
||
Acceptable values: Array of checkers, which are functions or regex or another checker[] | ||
|
||
|
||
# License | ||
|
||
MIT |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters