nerdamer 1.1.13 → 2.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BREAKING_CHANGES.md +244 -5
- package/LICENSE.md +184 -0
- package/README.md +232 -318
- package/dist/bundle.js +2 -0
- package/dist/bundle.js.LICENSE.txt +7 -0
- package/dist/parser.js +2 -0
- package/dist/parser.js.LICENSE.txt +7 -0
- package/docs-data/parser-functions.json +2248 -0
- package/index.d.ts +10 -426
- package/output/algebra/adapters.d.ts +3 -0
- package/output/algebra/adapters.js +11 -0
- package/output/algebra/algorithms/arith.d.ts +84 -0
- package/output/algebra/algorithms/arith.js +324 -0
- package/output/algebra/algorithms/groebnerBase.d.ts +161 -0
- package/output/algebra/algorithms/groebnerBase.js +929 -0
- package/output/algebra/dispatch.d.ts +1 -0
- package/output/algebra/dispatch.js +25 -0
- package/output/algebra/factor/factor.d.ts +77 -0
- package/output/algebra/factor/factor.js +245 -0
- package/output/algebra/gcd/gcd.d.ts +30 -0
- package/output/algebra/gcd/gcd.js +95 -0
- package/output/algebra/groebner.d.ts +21 -0
- package/output/algebra/groebner.js +36 -0
- package/output/algebra/partfrac.d.ts +19 -0
- package/output/algebra/partfrac.js +365 -0
- package/output/algebra/polynomial/ModularSparsePolynomial.d.ts +131 -0
- package/output/algebra/polynomial/ModularSparsePolynomial.js +378 -0
- package/output/algebra/polynomial/ModularSparsePolynomialFactor.d.ts +40 -0
- package/output/algebra/polynomial/ModularSparsePolynomialFactor.js +661 -0
- package/output/algebra/polynomial/SparsePolynomialFactor.d.ts +64 -0
- package/output/algebra/polynomial/SparsePolynomialFactor.js +492 -0
- package/output/algebra/polynomial/SparsePolynomialGcd.d.ts +29 -0
- package/output/algebra/polynomial/SparsePolynomialGcd.js +259 -0
- package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.d.ts +82 -0
- package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.js +604 -0
- package/output/algebra/polynomial/modularGcd.d.ts +40 -0
- package/output/algebra/polynomial/modularGcd.js +365 -0
- package/output/algebra/polynomialize.d.ts +20 -0
- package/output/algebra/polynomialize.js +26 -0
- package/output/algebra/simplify/complexsimp.d.ts +7 -0
- package/output/algebra/simplify/complexsimp.js +24 -0
- package/output/algebra/simplify/factorCommon.d.ts +13 -0
- package/output/algebra/simplify/factorCommon.js +136 -0
- package/output/algebra/simplify/funcsimp.d.ts +26 -0
- package/output/algebra/simplify/funcsimp.js +633 -0
- package/output/algebra/simplify/invtrigrewrite.d.ts +10 -0
- package/output/algebra/simplify/invtrigrewrite.js +96 -0
- package/output/algebra/simplify/ratsimp.d.ts +21 -0
- package/output/algebra/simplify/ratsimp.js +140 -0
- package/output/algebra/simplify/simplify.d.ts +25 -0
- package/output/algebra/simplify/simplify.js +237 -0
- package/output/algebra/simplify/trigreduce.d.ts +38 -0
- package/output/algebra/simplify/trigreduce.js +424 -0
- package/output/algebra/simplify/trigrewrite.d.ts +17 -0
- package/output/algebra/simplify/trigrewrite.js +156 -0
- package/output/algebra/simplify/trigsimp.d.ts +11 -0
- package/output/algebra/simplify/trigsimp.js +369 -0
- package/output/algebra/simplify/utils.d.ts +32 -0
- package/output/algebra/simplify/utils.js +56 -0
- package/output/algebra/utils.d.ts +32 -0
- package/output/algebra/utils.js +48 -0
- package/output/api/advanced.d.ts +8 -0
- package/output/api/advanced.js +18 -0
- package/output/api/algebra.d.ts +17 -0
- package/output/api/algebra.js +35 -0
- package/output/api/assumptions.d.ts +4 -0
- package/output/api/assumptions.js +11 -0
- package/output/api/calculus.d.ts +10 -0
- package/output/api/calculus.js +22 -0
- package/output/api/core.d.ts +17 -0
- package/output/api/core.js +41 -0
- package/output/api/debug.d.ts +16 -0
- package/output/api/debug.js +23 -0
- package/output/api/languages/deu.d.ts +3 -0
- package/output/api/languages/deu.js +266 -0
- package/output/api/languages/fra.d.ts +3 -0
- package/output/api/languages/fra.js +266 -0
- package/output/api/languages/ita.d.ts +3 -0
- package/output/api/languages/ita.js +266 -0
- package/output/api/languages/nld.d.ts +3 -0
- package/output/api/languages/nld.js +266 -0
- package/output/api/languages/por.d.ts +3 -0
- package/output/api/languages/por.js +266 -0
- package/output/api/languages/spa.d.ts +3 -0
- package/output/api/languages/spa.js +266 -0
- package/output/api/parser.d.ts +93 -0
- package/output/api/parser.js +18 -0
- package/output/api/solve.d.ts +10 -0
- package/output/api/solve.js +17 -0
- package/output/api/structures.d.ts +10 -0
- package/output/api/structures.js +23 -0
- package/output/calculus/adapters.d.ts +8 -0
- package/output/calculus/adapters.js +41 -0
- package/output/calculus/derivative/diff.d.ts +30 -0
- package/output/calculus/derivative/diff.js +241 -0
- package/output/calculus/dispatch.d.ts +1 -0
- package/output/calculus/dispatch.js +25 -0
- package/output/calculus/fresnel.d.ts +16 -0
- package/output/calculus/fresnel.js +39 -0
- package/output/calculus/integrate/byParts.d.ts +18 -0
- package/output/calculus/integrate/byParts.js +339 -0
- package/output/calculus/integrate/bySubstitution.d.ts +135 -0
- package/output/calculus/integrate/bySubstitution.js +411 -0
- package/output/calculus/integrate/integrate.d.ts +38 -0
- package/output/calculus/integrate/integrate.js +652 -0
- package/output/calculus/integrate/integrationTable.d.ts +2 -0
- package/output/calculus/integrate/integrationTable.js +914 -0
- package/output/calculus/integrate/utils.d.ts +28 -0
- package/output/calculus/integrate/utils.js +96 -0
- package/output/calculus/laplace/ilaplace.d.ts +31 -0
- package/output/calculus/laplace/ilaplace.js +192 -0
- package/output/calculus/laplace/ilaplaceTable.d.ts +2 -0
- package/output/calculus/laplace/ilaplaceTable.js +200 -0
- package/output/calculus/laplace/laplace.d.ts +22 -0
- package/output/calculus/laplace/laplace.js +109 -0
- package/output/calculus/laplace/laplaceTable.d.ts +2 -0
- package/output/calculus/laplace/laplaceTable.js +187 -0
- package/output/calculus/limit/limit.d.ts +35 -0
- package/output/calculus/limit/limit.js +1183 -0
- package/output/calculus/limit/limitsTable.d.ts +2 -0
- package/output/calculus/limit/limitsTable.js +7 -0
- package/output/core/Settings.d.ts +32 -0
- package/output/core/Settings.js +68 -0
- package/output/core/classes/assumption/Assumption.d.ts +218 -0
- package/output/core/classes/assumption/Assumption.js +609 -0
- package/output/core/classes/assumption/assertiveFunctions.d.ts +6 -0
- package/output/core/classes/assumption/assertiveFunctions.js +64 -0
- package/output/core/classes/assumption/assume.d.ts +90 -0
- package/output/core/classes/assumption/assume.js +145 -0
- package/output/core/classes/assumption/dispatch.d.ts +1 -0
- package/output/core/classes/assumption/dispatch.js +11 -0
- package/output/core/classes/collection/Collection.d.ts +107 -0
- package/output/core/classes/collection/Collection.js +240 -0
- package/output/core/classes/complex/Complex.d.ts +109 -0
- package/output/core/classes/complex/Complex.js +153 -0
- package/output/core/classes/decimalSet/DecimalSet.d.ts +226 -0
- package/output/core/classes/decimalSet/DecimalSet.js +454 -0
- package/output/core/classes/dictionary/Dictionary.d.ts +102 -0
- package/output/core/classes/dictionary/Dictionary.js +216 -0
- package/output/core/classes/equation/Equation.d.ts +256 -0
- package/output/core/classes/equation/Equation.js +350 -0
- package/output/core/classes/expression/CoeffObject.d.ts +100 -0
- package/output/core/classes/expression/CoeffObject.js +197 -0
- package/output/core/classes/expression/Expression.d.ts +1691 -0
- package/output/core/classes/expression/Expression.js +2381 -0
- package/output/core/classes/expression/analysis.d.ts +25 -0
- package/output/core/classes/expression/analysis.js +218 -0
- package/output/core/classes/expression/collect.d.ts +9 -0
- package/output/core/classes/expression/collect.js +49 -0
- package/output/core/classes/expression/format.d.ts +54 -0
- package/output/core/classes/expression/format.js +340 -0
- package/output/core/classes/expression/products.d.ts +23 -0
- package/output/core/classes/expression/products.js +115 -0
- package/output/core/classes/expression/shortcuts.d.ts +35 -0
- package/output/core/classes/expression/shortcuts.js +129 -0
- package/output/core/classes/expression/traversal.d.ts +31 -0
- package/output/core/classes/expression/traversal.js +216 -0
- package/output/core/classes/expression/trig.d.ts +25 -0
- package/output/core/classes/expression/trig.js +40 -0
- package/output/core/classes/expression/utils.d.ts +61 -0
- package/output/core/classes/expression/utils.js +235 -0
- package/output/core/classes/lookupTable/LookupTable.d.ts +12 -0
- package/output/core/classes/lookupTable/LookupTable.js +55 -0
- package/output/core/classes/matrix/Matrix.d.ts +227 -0
- package/output/core/classes/matrix/Matrix.js +901 -0
- package/output/core/classes/matrix/Sylvester.d.ts +11 -0
- package/output/core/classes/matrix/Sylvester.js +54 -0
- package/output/core/classes/matrix/dispatch.d.ts +1 -0
- package/output/core/classes/matrix/dispatch.js +19 -0
- package/output/core/classes/matrix/functions.d.ts +28 -0
- package/output/core/classes/matrix/functions.js +57 -0
- package/output/core/classes/matrix/utils.d.ts +9 -0
- package/output/core/classes/matrix/utils.js +22 -0
- package/output/core/classes/parser/Parser.d.ts +493 -0
- package/output/core/classes/parser/Parser.js +1863 -0
- package/output/core/classes/parser/Token.d.ts +58 -0
- package/output/core/classes/parser/Token.js +137 -0
- package/output/core/classes/parser/constants.d.ts +162 -0
- package/output/core/classes/parser/constants.js +229 -0
- package/output/core/classes/parser/controlFlowSignals.d.ts +38 -0
- package/output/core/classes/parser/controlFlowSignals.js +60 -0
- package/output/core/classes/parser/helpers.d.ts +21 -0
- package/output/core/classes/parser/helpers.js +42 -0
- package/output/core/classes/parser/operations/add.d.ts +15 -0
- package/output/core/classes/parser/operations/add.js +236 -0
- package/output/core/classes/parser/operations/comma.d.ts +7 -0
- package/output/core/classes/parser/operations/comma.js +11 -0
- package/output/core/classes/parser/operations/compare.d.ts +21 -0
- package/output/core/classes/parser/operations/compare.js +474 -0
- package/output/core/classes/parser/operations/divide.d.ts +2 -0
- package/output/core/classes/parser/operations/divide.js +72 -0
- package/output/core/classes/parser/operations/functions.d.ts +46 -0
- package/output/core/classes/parser/operations/functions.js +438 -0
- package/output/core/classes/parser/operations/multiply.d.ts +11 -0
- package/output/core/classes/parser/operations/multiply.js +328 -0
- package/output/core/classes/parser/operations/power.d.ts +48 -0
- package/output/core/classes/parser/operations/power.js +673 -0
- package/output/core/classes/parser/operations/subtract.d.ts +3 -0
- package/output/core/classes/parser/operations/subtract.js +36 -0
- package/output/core/classes/parser/preprocess.d.ts +7 -0
- package/output/core/classes/parser/preprocess.js +246 -0
- package/output/core/classes/parser/scripting/controlFlow.d.ts +23 -0
- package/output/core/classes/parser/scripting/controlFlow.js +279 -0
- package/output/core/classes/parser/scripting/deferred.d.ts +4 -0
- package/output/core/classes/parser/scripting/deferred.js +65 -0
- package/output/core/classes/parser/scripting/dispatch.d.ts +1 -0
- package/output/core/classes/parser/scripting/dispatch.js +62 -0
- package/output/core/classes/parser/scripting/evaluate.d.ts +23 -0
- package/output/core/classes/parser/scripting/evaluate.js +128 -0
- package/output/core/classes/parser/scripting/functions.d.ts +14 -0
- package/output/core/classes/parser/scripting/functions.js +59 -0
- package/output/core/classes/parser/scripting/scope.d.ts +8 -0
- package/output/core/classes/parser/scripting/scope.js +132 -0
- package/output/core/classes/parser/types.d.ts +130 -0
- package/output/core/classes/parser/types.js +2 -0
- package/output/core/classes/parser/wrappers/IndexedReference.d.ts +31 -0
- package/output/core/classes/parser/wrappers/IndexedReference.js +68 -0
- package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +24 -0
- package/output/core/classes/parser/wrappers/KeyValuePair.js +51 -0
- package/output/core/classes/polynomial/Polynomial.d.ts +504 -0
- package/output/core/classes/polynomial/Polynomial.js +1195 -0
- package/output/core/classes/polynomial/SparsePolynomial.d.ts +221 -0
- package/output/core/classes/polynomial/SparsePolynomial.js +824 -0
- package/output/core/classes/polynomial/SparsePolynomialAdapter.d.ts +56 -0
- package/output/core/classes/polynomial/SparsePolynomialAdapter.js +241 -0
- package/output/core/classes/polynomial/Term.d.ts +222 -0
- package/output/core/classes/polynomial/Term.js +430 -0
- package/output/core/classes/polynomial/adapters.d.ts +18 -0
- package/output/core/classes/polynomial/adapters.js +33 -0
- package/output/core/classes/polynomial/dispatch.d.ts +1 -0
- package/output/core/classes/polynomial/dispatch.js +14 -0
- package/output/core/classes/polynomial/functions.d.ts +77 -0
- package/output/core/classes/polynomial/functions.js +189 -0
- package/output/core/classes/polynomial/utils.d.ts +62 -0
- package/output/core/classes/polynomial/utils.js +207 -0
- package/output/core/classes/rational/Rational.d.ts +501 -0
- package/output/core/classes/rational/Rational.js +829 -0
- package/output/core/classes/seq/SEQ.d.ts +13 -0
- package/output/core/classes/seq/SEQ.js +137 -0
- package/output/core/classes/valuesSet/ValuesSet.d.ts +187 -0
- package/output/core/classes/valuesSet/ValuesSet.js +399 -0
- package/output/core/classes/vector/Vector.d.ts +222 -0
- package/output/core/classes/vector/Vector.js +501 -0
- package/output/core/classes/vector/dispatch.d.ts +1 -0
- package/output/core/classes/vector/dispatch.js +11 -0
- package/output/core/classes/vector/functions.d.ts +28 -0
- package/output/core/classes/vector/functions.js +47 -0
- package/output/core/common/classes/MathematicalAggregate.d.ts +53 -0
- package/output/core/common/classes/MathematicalAggregate.js +149 -0
- package/output/core/common/classes/Scope.d.ts +62 -0
- package/output/core/common/classes/Scope.js +122 -0
- package/output/core/common/classes/StructuredEntity.d.ts +55 -0
- package/output/core/common/classes/StructuredEntity.js +151 -0
- package/output/core/common/common.d.ts +62 -0
- package/output/core/common/common.js +74 -0
- package/output/core/common/functions/functions.d.ts +14 -0
- package/output/core/common/functions/functions.js +33 -0
- package/output/core/common/functions/structuredEntityUtils.d.ts +27 -0
- package/output/core/common/functions/structuredEntityUtils.js +40 -0
- package/output/core/converters/BaseConverter.d.ts +97 -0
- package/output/core/converters/BaseConverter.js +405 -0
- package/output/core/converters/Converter.d.ts +111 -0
- package/output/core/converters/Converter.js +806 -0
- package/output/core/converters/Pattern.d.ts +71 -0
- package/output/core/converters/Pattern.js +302 -0
- package/output/core/dispatch.d.ts +52 -0
- package/output/core/dispatch.js +26 -0
- package/output/core/errors.d.ts +316 -0
- package/output/core/errors.js +349 -0
- package/output/core/fullFunctions.d.ts +7 -0
- package/output/core/fullFunctions.js +31 -0
- package/output/core/functions/bigint/bigint.d.ts +133 -0
- package/output/core/functions/bigint/bigint.js +444 -0
- package/output/core/functions/bigint/primeFactor.d.ts +51 -0
- package/output/core/functions/bigint/primeFactor.js +267 -0
- package/output/core/functions/bigint/primes.d.ts +1 -0
- package/output/core/functions/bigint/primes.js +11 -0
- package/output/core/functions/build/definitions.d.ts +12 -0
- package/output/core/functions/build/definitions.js +139 -0
- package/output/core/functions/build/index.d.ts +32 -0
- package/output/core/functions/build/index.js +136 -0
- package/output/core/functions/complex.d.ts +90 -0
- package/output/core/functions/complex.dispatch.d.ts +1 -0
- package/output/core/functions/complex.dispatch.js +16 -0
- package/output/core/functions/complex.js +482 -0
- package/output/core/functions/decimal.d.ts +24 -0
- package/output/core/functions/decimal.js +665 -0
- package/output/core/functions/expand/expand.d.ts +42 -0
- package/output/core/functions/expand/expand.js +376 -0
- package/output/core/functions/fresnelNumeric.d.ts +12 -0
- package/output/core/functions/fresnelNumeric.js +123 -0
- package/output/core/functions/numeric.d.ts +140 -0
- package/output/core/functions/numeric.js +790 -0
- package/output/core/functions/rationalNormalization.d.ts +11 -0
- package/output/core/functions/rationalNormalization.js +117 -0
- package/output/core/functions/setFunction.d.ts +19 -0
- package/output/core/functions/setFunction.js +75 -0
- package/output/core/functions/string.d.ts +26 -0
- package/output/core/functions/string.js +102 -0
- package/output/core/functions/subst.d.ts +90 -0
- package/output/core/functions/subst.js +506 -0
- package/output/core/functions/utils.d.ts +24 -0
- package/output/core/functions/utils.js +51 -0
- package/output/core/parserFunctions.d.ts +7 -0
- package/output/core/parserFunctions.js +25 -0
- package/output/core/types.d.ts +48 -0
- package/output/core/types.js +2 -0
- package/output/index.d.ts +359 -0
- package/output/index.js +739 -0
- package/output/math/defint/defint.d.ts +18 -0
- package/output/math/defint/defint.js +60 -0
- package/output/math/defint/defintDecimal.d.ts +37 -0
- package/output/math/defint/defintDecimal.js +321 -0
- package/output/math/defint/defintNative.d.ts +57 -0
- package/output/math/defint/defintNative.js +281 -0
- package/output/math/dispatch.d.ts +1 -0
- package/output/math/dispatch.js +101 -0
- package/output/math/geometry.d.ts +12 -0
- package/output/math/geometry.js +55 -0
- package/output/math/math.d.ts +695 -0
- package/output/math/math.js +1955 -0
- package/output/math/trig.d.ts +518 -0
- package/output/math/trig.js +1444 -0
- package/output/math/trunc.d.ts +19 -0
- package/output/math/trunc.js +36 -0
- package/output/math/utils.d.ts +66 -0
- package/output/math/utils.js +219 -0
- package/output/solve/classes/DecimalMatrix.d.ts +17 -0
- package/output/solve/classes/DecimalMatrix.js +86 -0
- package/output/solve/classes/FunctionSolver.d.ts +135 -0
- package/output/solve/classes/FunctionSolver.js +433 -0
- package/output/solve/classes/MultivariateSolver.d.ts +84 -0
- package/output/solve/classes/MultivariateSolver.js +240 -0
- package/output/solve/classes/PolynomialSolver.d.ts +104 -0
- package/output/solve/classes/PolynomialSolver.js +492 -0
- package/output/solve/classes/SolutionSet.d.ts +172 -0
- package/output/solve/classes/SolutionSet.js +434 -0
- package/output/solve/classes/Solver.d.ts +17 -0
- package/output/solve/classes/Solver.js +132 -0
- package/output/solve/classes/SymbolicSolver.d.ts +74 -0
- package/output/solve/classes/SymbolicSolver.js +601 -0
- package/output/solve/dispatch.d.ts +1 -0
- package/output/solve/dispatch.js +13 -0
- package/output/solve/linsolve.d.ts +53 -0
- package/output/solve/linsolve.js +233 -0
- package/output/solve/solve.d.ts +44 -0
- package/output/solve/solve.js +368 -0
- package/output/solve/solveSystem.d.ts +31 -0
- package/output/solve/solveSystem.js +266 -0
- package/output/solve/utils.d.ts +10 -0
- package/output/solve/utils.js +58 -0
- package/output/utils/array.d.ts +42 -0
- package/output/utils/array.js +98 -0
- package/output/utils/debug.d.ts +131 -0
- package/output/utils/debug.js +296 -0
- package/output/utils/decimal.d.ts +3 -0
- package/output/utils/decimal.js +16 -0
- package/output/utils/numeric.d.ts +14 -0
- package/output/utils/numeric.js +51 -0
- package/output/utils/object.d.ts +26 -0
- package/output/utils/object.js +56 -0
- package/package.json +178 -57
- package/.travis.yml +0 -3
- package/Algebra.js +0 -4568
- package/CODE_OF_CONDUCT.md +0 -46
- package/CONTRIBUTING.md +0 -14
- package/Calculus.js +0 -2675
- package/Extra.js +0 -622
- package/Solve.js +0 -1783
- package/all.js +0 -16
- package/all.min.js +0 -1
- package/gulpfile.js +0 -16
- package/index.html +0 -158
- package/license.txt +0 -19
- package/nerdamer.core.js +0 -12510
- package/spec/LaTeX.spec.js +0 -302
- package/spec/TeXConvert.spec.js +0 -8
- package/spec/algebra.spec.js +0 -287
- package/spec/basic_parser.spec.js +0 -134
- package/spec/build.spec.js +0 -131
- package/spec/calculus.spec.js +0 -183
- package/spec/core.spec.js +0 -2970
- package/spec/extra.spec.js +0 -54
- package/spec/solve.spec.js +0 -126
- package/spec/support/jasmine.json +0 -11
- package/spec/support/utils.js +0 -42
- package/spec/text.spec.js +0 -132
|
@@ -0,0 +1,806 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Converter = void 0;
|
|
4
|
+
const Dictionary_1 = require("../classes/dictionary/Dictionary");
|
|
5
|
+
const Expression_1 = require("../classes/expression/Expression");
|
|
6
|
+
const shortcuts_1 = require("../classes/expression/shortcuts");
|
|
7
|
+
const Matrix_1 = require("../classes/matrix/Matrix");
|
|
8
|
+
const constants_1 = require("../classes/parser/constants");
|
|
9
|
+
const Parser_1 = require("../classes/parser/Parser");
|
|
10
|
+
const Token_1 = require("../classes/parser/Token");
|
|
11
|
+
const ValuesSet_1 = require("../classes/valuesSet/ValuesSet");
|
|
12
|
+
const Vector_1 = require("../classes/vector/Vector");
|
|
13
|
+
const Scope_1 = require("../common/classes/Scope");
|
|
14
|
+
const dispatch_1 = require("../dispatch");
|
|
15
|
+
const errors_1 = require("../errors");
|
|
16
|
+
const BaseConverter_1 = require("./BaseConverter");
|
|
17
|
+
const { TeX, TEXT } = BaseConverter_1.BaseConverter.modes;
|
|
18
|
+
/**
|
|
19
|
+
* Formats Nerdamer values as TeX or normalized text and imports supported TeX input.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* A converter retains its output mode between calls. The default mode is `"TeX"`;
|
|
23
|
+
* construct a separate `"text"` converter when both representations are needed.
|
|
24
|
+
* Formatting a string parses it with the process-wide parser, so registered functions,
|
|
25
|
+
* constants, settings, and known values can affect the result.
|
|
26
|
+
*
|
|
27
|
+
* {@link Converter.fromTeX} recognizes the TeX forms emitted by this converter and a
|
|
28
|
+
* practical subset of common mathematical notation. It is not a general TeX parser:
|
|
29
|
+
* unsupported macros, ambiguous implicit notation, or nesting outside the recognized
|
|
30
|
+
* forms can produce parser errors or a different symbolic interpretation.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import nerdamer from 'nerdamer';
|
|
35
|
+
*
|
|
36
|
+
* const text = new nerdamer.classes.Converter('text');
|
|
37
|
+
* const tex = new nerdamer.classes.Converter();
|
|
38
|
+
*
|
|
39
|
+
* text.convert('x^2 + 2*x + 1'); // "1+2*x+x^2"
|
|
40
|
+
* tex.convert('sqrt(x)'); // "\\sqrt{x}"
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
class Converter extends BaseConverter_1.BaseConverter {
|
|
44
|
+
static TEX_FUNCTION_MAP = {
|
|
45
|
+
// Inverse trig
|
|
46
|
+
acos: 'arccos',
|
|
47
|
+
asin: 'arcsin',
|
|
48
|
+
atan: 'arctan',
|
|
49
|
+
asec: 'operatorname{arcsec}',
|
|
50
|
+
acsc: 'operatorname{arccsc}',
|
|
51
|
+
acot: 'operatorname{arccot}',
|
|
52
|
+
// Inverse hyperbolic
|
|
53
|
+
acosh: 'operatorname{arcosh}',
|
|
54
|
+
asinh: 'operatorname{arsinh}',
|
|
55
|
+
atanh: 'operatorname{artanh}',
|
|
56
|
+
asech: 'operatorname{arsech}',
|
|
57
|
+
acsch: 'operatorname{arcsch}',
|
|
58
|
+
acoth: 'operatorname{arcoth}',
|
|
59
|
+
// Hyperbolic (not built-in in LaTeX)
|
|
60
|
+
sech: 'operatorname{sech}',
|
|
61
|
+
csch: 'operatorname{csch}',
|
|
62
|
+
coth: 'operatorname{coth}',
|
|
63
|
+
// Special
|
|
64
|
+
realpart: 'Re',
|
|
65
|
+
imagpart: 'Im',
|
|
66
|
+
sign: 'operatorname{sgn}',
|
|
67
|
+
sinc: 'operatorname{sinc}',
|
|
68
|
+
erf: 'operatorname{erf}',
|
|
69
|
+
erfc: 'operatorname{erfc}',
|
|
70
|
+
determinant: 'det',
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Reverse map for fromTeX: maps TeX command names back to internal function names.
|
|
74
|
+
*/
|
|
75
|
+
static TEX_REVERSE_MAP = {
|
|
76
|
+
arccos: 'acos',
|
|
77
|
+
arcsin: 'asin',
|
|
78
|
+
arctan: 'atan',
|
|
79
|
+
arcsec: 'asec',
|
|
80
|
+
arccsc: 'acsc',
|
|
81
|
+
arccot: 'acot',
|
|
82
|
+
arcosh: 'acosh',
|
|
83
|
+
arsinh: 'asinh',
|
|
84
|
+
artanh: 'atanh',
|
|
85
|
+
arsech: 'asech',
|
|
86
|
+
arcsch: 'acsch',
|
|
87
|
+
arcoth: 'acoth',
|
|
88
|
+
det: 'determinant',
|
|
89
|
+
deg: constants_1.DEG,
|
|
90
|
+
sgn: 'sign',
|
|
91
|
+
operatorname: '',
|
|
92
|
+
Gamma: 'gamma',
|
|
93
|
+
delta: constants_1.DIRAC,
|
|
94
|
+
Re: 'realpart',
|
|
95
|
+
Im: 'imagpart',
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Creates a converter with persistent output mode.
|
|
99
|
+
*
|
|
100
|
+
* @param mode - `"TeX"` (the default) or `"text"`.
|
|
101
|
+
*/
|
|
102
|
+
constructor(mode) {
|
|
103
|
+
super();
|
|
104
|
+
if (mode) {
|
|
105
|
+
this.setMode(mode);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
static clearOnes(m, v) {
|
|
109
|
+
for (let i = 0; i < 2; i++) {
|
|
110
|
+
if (v[i] && Number(m[i]) === 1) {
|
|
111
|
+
m[i] = '';
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return [m, v];
|
|
115
|
+
}
|
|
116
|
+
static wrapRoot(value, root) {
|
|
117
|
+
return root === '2' ? `\\sqrt{${value}}` : `\\sqrt[${root}]{${value}}`;
|
|
118
|
+
}
|
|
119
|
+
finalizePowerAndInput(power, input, options) {
|
|
120
|
+
if (!options?.convertRoots) {
|
|
121
|
+
return [power, input];
|
|
122
|
+
}
|
|
123
|
+
const num = power.getNumerator();
|
|
124
|
+
const den = power.getDenominator();
|
|
125
|
+
if (num.isOne() && !power.isOne()) {
|
|
126
|
+
if (this.mode === BaseConverter_1.BaseConverter.modes.TEXT && den.eq((0, shortcuts_1.two)())) {
|
|
127
|
+
return [(0, shortcuts_1.one)(), BaseConverter_1.BaseConverter.convertSQRT(input)];
|
|
128
|
+
}
|
|
129
|
+
if (this.mode === BaseConverter_1.BaseConverter.modes.TeX) {
|
|
130
|
+
return [(0, shortcuts_1.one)(), BaseConverter_1.BaseConverter.convertNtRoot(input, den)];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return [power, input];
|
|
134
|
+
}
|
|
135
|
+
functionString(input, options) {
|
|
136
|
+
const name = this.getFunctionName(input.name || '');
|
|
137
|
+
const args = input.getArguments();
|
|
138
|
+
const output = args.map(arg => this.convert(arg, options));
|
|
139
|
+
if (this.mode === TEXT) {
|
|
140
|
+
return `${name}(${output.join(',')})`;
|
|
141
|
+
}
|
|
142
|
+
return this.formatTeXFunction(input.name || '', name, output, args);
|
|
143
|
+
}
|
|
144
|
+
value(input, isInverted, isNegative, options) {
|
|
145
|
+
const v = ['', ''];
|
|
146
|
+
const index = isInverted ? 1 : 0;
|
|
147
|
+
if (input.isNUM()) {
|
|
148
|
+
return v;
|
|
149
|
+
}
|
|
150
|
+
if (input.isEXP()) {
|
|
151
|
+
v[index] = this.handleExp(input, options);
|
|
152
|
+
}
|
|
153
|
+
else if (input.isInf()) {
|
|
154
|
+
v[index] = this.mode === 'text' ? constants_1.INFINITY[0] : '\\infty';
|
|
155
|
+
}
|
|
156
|
+
else if (!(input.elements || input.args)) {
|
|
157
|
+
v[index] = this.formatVariable(input.value);
|
|
158
|
+
}
|
|
159
|
+
else if (input.isFunction()) {
|
|
160
|
+
v[index] = this.functionString(input, options);
|
|
161
|
+
}
|
|
162
|
+
else if (input.isSum()) {
|
|
163
|
+
v[index] = this.handleSum(input, isNegative, options);
|
|
164
|
+
}
|
|
165
|
+
else if (input.isProduct()) {
|
|
166
|
+
return this.handleProduct(input, isInverted, options);
|
|
167
|
+
}
|
|
168
|
+
return v;
|
|
169
|
+
}
|
|
170
|
+
convertSourceRPN(rpn, options) {
|
|
171
|
+
const stack = [];
|
|
172
|
+
for (let i = 0; i < rpn.length; i++) {
|
|
173
|
+
const item = rpn[i];
|
|
174
|
+
if (Scope_1.Scope.isScope(item)) {
|
|
175
|
+
const converted = this.convertSourceRPN(item, options);
|
|
176
|
+
const innerText = converted.args
|
|
177
|
+
? converted.args.map(arg => arg.text).join(',')
|
|
178
|
+
: converted.text;
|
|
179
|
+
const innerSource = converted.args
|
|
180
|
+
? converted.args.map(arg => arg.source).join(',')
|
|
181
|
+
: converted.source;
|
|
182
|
+
let text = innerText;
|
|
183
|
+
let source = innerSource;
|
|
184
|
+
switch (item.type) {
|
|
185
|
+
case 'parenthesis':
|
|
186
|
+
text = this.inBrackets(innerText);
|
|
187
|
+
source = `(${innerSource})`;
|
|
188
|
+
break;
|
|
189
|
+
case 'square':
|
|
190
|
+
text = this.inBrackets(innerText, 'square');
|
|
191
|
+
source = `[${innerSource}]`;
|
|
192
|
+
break;
|
|
193
|
+
case 'curly':
|
|
194
|
+
text = this.inBrackets(innerText, 'brace');
|
|
195
|
+
source = `{${innerSource}}`;
|
|
196
|
+
break;
|
|
197
|
+
case 'pipe':
|
|
198
|
+
text = this.inBrackets(innerText, 'abs');
|
|
199
|
+
source = `|${innerSource}|`;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
stack.push({ text, source });
|
|
203
|
+
}
|
|
204
|
+
else if (item.type === Token_1.Token.FUNCTION) {
|
|
205
|
+
const argsScope = rpn[++i];
|
|
206
|
+
if (!Scope_1.Scope.isScope(argsScope)) {
|
|
207
|
+
throw new Error((0, errors_1.message)('converterMissingArgumentScope', { function: item.value }));
|
|
208
|
+
}
|
|
209
|
+
let args = [];
|
|
210
|
+
if (argsScope.length > 0) {
|
|
211
|
+
const argumentRPN = dispatch_1.mathFunctionRegistry[item.value]?.deferArguments
|
|
212
|
+
? Parser_1.Parser.toRPN(argsScope)
|
|
213
|
+
: argsScope;
|
|
214
|
+
const converted = this.convertSourceRPN(argumentRPN, options);
|
|
215
|
+
args = converted.args ?? [converted];
|
|
216
|
+
}
|
|
217
|
+
const output = args.map(arg => arg.text);
|
|
218
|
+
const placeholders = args.map((_, index) => Expression_1.Expression.create(`zzsourcearg${index}`));
|
|
219
|
+
const name = this.getFunctionName(item.value);
|
|
220
|
+
let text;
|
|
221
|
+
if (item.value === Expression_1.Expression.LOG && args.length === 2) {
|
|
222
|
+
const numerator = this.formatTeXFunction(Expression_1.Expression.LOG, name, [output[0]], [placeholders[0]]);
|
|
223
|
+
const denominator = this.formatTeXFunction(Expression_1.Expression.LOG, name, [output[1]], [placeholders[1]]);
|
|
224
|
+
text = this.toFraction(numerator, denominator);
|
|
225
|
+
}
|
|
226
|
+
else if (item.value === 'sqrt' && args.length === 1) {
|
|
227
|
+
text = Converter.wrapRoot(output[0], '2');
|
|
228
|
+
}
|
|
229
|
+
else if (args.length === 1 &&
|
|
230
|
+
(item.value === constants_1.FACTORIAL ||
|
|
231
|
+
item.value === 'factorial' ||
|
|
232
|
+
item.value === constants_1.DOUBLE_FACTORIAL)) {
|
|
233
|
+
text = this.formatTeXFunction(item.value, name, output, [
|
|
234
|
+
Expression_1.Expression.create(args[0].source),
|
|
235
|
+
]);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
text = this.formatTeXFunction(item.value, name, output, placeholders);
|
|
239
|
+
}
|
|
240
|
+
stack.push({
|
|
241
|
+
text,
|
|
242
|
+
source: `${item.value}(${args.map(arg => arg.source).join(',')})`,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
else if (item.type === Token_1.Token.PREFIX) {
|
|
246
|
+
const operand = stack.pop();
|
|
247
|
+
if (!operand) {
|
|
248
|
+
throw new Error((0, errors_1.message)('converterMissingPrefixOperand', { operator: item.value }));
|
|
249
|
+
}
|
|
250
|
+
stack.push({
|
|
251
|
+
text: item.value + operand.text,
|
|
252
|
+
source: item.value + operand.source,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
else if (item.type === Token_1.Token.OPERATOR) {
|
|
256
|
+
const operator = item.resolvedOperator ?? Parser_1.Parser.getOperator(item.value);
|
|
257
|
+
const right = stack.pop();
|
|
258
|
+
if (!operator || !right) {
|
|
259
|
+
throw new Error((0, errors_1.message)('converterMissingOperandMetadata', { operator: item.value }));
|
|
260
|
+
}
|
|
261
|
+
if (operator.isPostfix) {
|
|
262
|
+
const symbol = item.value === '%' ? '\\%' : item.value;
|
|
263
|
+
stack.push({
|
|
264
|
+
text: right.text + symbol,
|
|
265
|
+
source: right.source + item.value,
|
|
266
|
+
});
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const left = stack.pop();
|
|
270
|
+
if (!left) {
|
|
271
|
+
throw new Error((0, errors_1.message)('converterMissingLeftOperand', { operator: item.value }));
|
|
272
|
+
}
|
|
273
|
+
if (operator.action === 'comma') {
|
|
274
|
+
const args = [...(left.args ?? [left]), ...(right.args ?? [right])];
|
|
275
|
+
stack.push({
|
|
276
|
+
text: args.map(arg => arg.text).join(','),
|
|
277
|
+
source: args.map(arg => arg.source).join(','),
|
|
278
|
+
args,
|
|
279
|
+
});
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
let text;
|
|
283
|
+
if (operator.action === 'times') {
|
|
284
|
+
text =
|
|
285
|
+
left.text +
|
|
286
|
+
(item.position === -1 ? '' : this.getMultiplicationSymbol()) +
|
|
287
|
+
right.text;
|
|
288
|
+
}
|
|
289
|
+
else if (operator.action === 'div') {
|
|
290
|
+
text = this.toFraction(left.text, right.text);
|
|
291
|
+
}
|
|
292
|
+
else if (operator.action === 'pow') {
|
|
293
|
+
const power = Expression_1.Expression.create(right.source);
|
|
294
|
+
if (power.sign() === -1) {
|
|
295
|
+
const positivePower = power.signFree();
|
|
296
|
+
const denominator = positivePower.isOne()
|
|
297
|
+
? left.text
|
|
298
|
+
: left.text + '^' + this.inBraces(super.convert(positivePower, options));
|
|
299
|
+
text = this.toFraction('1', denominator);
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
text = left.text + '^' + this.inBraces(right.text);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
else if (operator.action === 'mod') {
|
|
306
|
+
text = this.formatTeXFunction('mod', this.getFunctionName('mod'), [left.text, right.text], [Expression_1.Expression.create('zzsourcearg0'), Expression_1.Expression.create('zzsourcearg1')]);
|
|
307
|
+
}
|
|
308
|
+
else if (operator.action === 'mapTo') {
|
|
309
|
+
text = `${left.text} \\mapsto ${right.text}`;
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
text = left.text + item.value + right.text;
|
|
313
|
+
}
|
|
314
|
+
stack.push({
|
|
315
|
+
text,
|
|
316
|
+
source: `(${left.source})${item.value}(${right.source})`,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
let text = item.value;
|
|
321
|
+
if (item.type === Token_1.Token.VARIABLE) {
|
|
322
|
+
text = constants_1.INFINITY.includes(item.value) ? '\\infty' : this.formatVariable(item.value);
|
|
323
|
+
}
|
|
324
|
+
stack.push({ text, source: item.value });
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (stack.length !== 1) {
|
|
328
|
+
throw new Error((0, errors_1.message)('converterTexConversionFailed'));
|
|
329
|
+
}
|
|
330
|
+
const retval = stack[0];
|
|
331
|
+
return retval;
|
|
332
|
+
}
|
|
333
|
+
formatFactorial(arg, output, symbol) {
|
|
334
|
+
if (arg.isLinear() && (arg.isSum() || arg.isProduct())) {
|
|
335
|
+
output = this.inBrackets(output);
|
|
336
|
+
}
|
|
337
|
+
return output + symbol;
|
|
338
|
+
}
|
|
339
|
+
formatSumOrProduct(symbol, output) {
|
|
340
|
+
const [a, b, c, d] = output;
|
|
341
|
+
return `${symbol}_{${this.inBraces(b)}=${this.inBraces(c)}}^${this.inBraces(d)} ${this.inBraces(a)}`;
|
|
342
|
+
}
|
|
343
|
+
formatTeXFunction(originalName, name, output, args) {
|
|
344
|
+
// Standard function: \name\left(arg\right)
|
|
345
|
+
const std = () => name + this.inBrackets(output[0]);
|
|
346
|
+
const generic = () => {
|
|
347
|
+
const formattedName = '\\operatorname' + this.inBraces(originalName.replace(/_/g, '\\_'));
|
|
348
|
+
return formattedName + this.inBrackets(output.join(','), 'parens');
|
|
349
|
+
};
|
|
350
|
+
const handlers = {
|
|
351
|
+
// Basic math
|
|
352
|
+
sqrt: std,
|
|
353
|
+
abs: () => this.inBrackets(output[0], 'abs'),
|
|
354
|
+
cbrt: () => `\\sqrt[3]${this.inBraces(output[0])}`,
|
|
355
|
+
max: () => `\\max${this.inBrackets(output.join(','), 'parens')}`,
|
|
356
|
+
min: () => `\\min${this.inBrackets(output.join(','), 'parens')}`,
|
|
357
|
+
round: () => output.length === 1
|
|
358
|
+
? `\\left\\lfloor ${output[0]} \\right\\rceil`
|
|
359
|
+
: generic(),
|
|
360
|
+
mod: () => `${output[0]} \\bmod ${output[1]}`,
|
|
361
|
+
[constants_1.FACTORIAL]: () => this.formatFactorial(args[0], output[0], '!'),
|
|
362
|
+
factorial: () => this.formatFactorial(args[0], output[0], '!'),
|
|
363
|
+
[constants_1.DOUBLE_FACTORIAL]: () => this.formatFactorial(args[0], output[0], '!!'),
|
|
364
|
+
parens: () => this.inBrackets(output[0], 'parens'),
|
|
365
|
+
// Trig
|
|
366
|
+
cos: std,
|
|
367
|
+
sin: std,
|
|
368
|
+
tan: std,
|
|
369
|
+
sec: std,
|
|
370
|
+
csc: std,
|
|
371
|
+
cot: std,
|
|
372
|
+
// Inverse trig
|
|
373
|
+
acos: std,
|
|
374
|
+
asin: std,
|
|
375
|
+
atan: std,
|
|
376
|
+
asec: std,
|
|
377
|
+
acsc: std,
|
|
378
|
+
acot: std,
|
|
379
|
+
atan2: () => name + this.inBrackets(output.join(','), 'parens'),
|
|
380
|
+
// Hyperbolic
|
|
381
|
+
sinh: std,
|
|
382
|
+
cosh: std,
|
|
383
|
+
tanh: std,
|
|
384
|
+
sech: std,
|
|
385
|
+
csch: std,
|
|
386
|
+
coth: std,
|
|
387
|
+
// Inverse hyperbolic
|
|
388
|
+
acosh: std,
|
|
389
|
+
asinh: std,
|
|
390
|
+
atanh: std,
|
|
391
|
+
asech: std,
|
|
392
|
+
acsch: std,
|
|
393
|
+
acoth: std,
|
|
394
|
+
// Floor / ceiling
|
|
395
|
+
floor: () => `\\left\\lfloor ${output[0]} \\right\\rfloor`,
|
|
396
|
+
ceil: () => `\\left\\lceil ${output[0]} \\right\\rceil`,
|
|
397
|
+
ceiling: () => `\\left\\lceil ${output[0]} \\right\\rceil`,
|
|
398
|
+
// Logarithms
|
|
399
|
+
[Expression_1.Expression.LOG]: () => {
|
|
400
|
+
const base = output[1];
|
|
401
|
+
const subscript = base === undefined ? '' : `_${this.inBraces(base)}`;
|
|
402
|
+
return `\\mathrm${this.inBraces(Expression_1.Expression.LOG)}${subscript}${this.inBrackets(output[0])}`;
|
|
403
|
+
},
|
|
404
|
+
[Expression_1.Expression.LOG10]: () => `\\mathrm${this.inBraces(Expression_1.Expression.LOG)}_${this.inBraces('10')}${this.inBrackets(output[0])}`,
|
|
405
|
+
log10: () => `\\mathrm${this.inBraces(Expression_1.Expression.LOG)}_${this.inBraces('10')}${this.inBrackets(output[0])}`,
|
|
406
|
+
// Special functions
|
|
407
|
+
exp: std,
|
|
408
|
+
gamma: () => `\\Gamma${this.inBrackets(output[0])}`,
|
|
409
|
+
gamma_incomplete: () => `\\Gamma${this.inBrackets(output.join(','), 'parens')}`,
|
|
410
|
+
gamma_incomplete_lower: () => `\\gamma${this.inBrackets(output.join(','), 'parens')}`,
|
|
411
|
+
erf: std,
|
|
412
|
+
erfc: std,
|
|
413
|
+
sinc: std,
|
|
414
|
+
Si: () => `\\operatorname{Si}${this.inBrackets(output[0])}`,
|
|
415
|
+
Shi: () => `\\operatorname{Shi}${this.inBrackets(output[0])}`,
|
|
416
|
+
Ci: () => `\\operatorname{Ci}${this.inBrackets(output[0])}`,
|
|
417
|
+
Chi: () => `\\operatorname{Chi}${this.inBrackets(output[0])}`,
|
|
418
|
+
Ei: () => `\\operatorname{Ei}${this.inBrackets(output[0])}`,
|
|
419
|
+
[constants_1.LI]: () => `\\operatorname{Li}${this.inBrackets(output[0])}`,
|
|
420
|
+
// Step / impulse
|
|
421
|
+
[constants_1.HEAVISIDE]: () => `H${this.inBrackets(output[0])}`,
|
|
422
|
+
[constants_1.DIRAC]: () => `\\delta${this.inBrackets(output[0])}`,
|
|
423
|
+
dirac: () => `\\delta${this.inBrackets(output[0])}`,
|
|
424
|
+
sign: std,
|
|
425
|
+
// Complex
|
|
426
|
+
realpart: () => `\\Re${this.inBrackets(output[0])}`,
|
|
427
|
+
imagpart: () => `\\Im${this.inBrackets(output[0])}`,
|
|
428
|
+
arg: std,
|
|
429
|
+
[constants_1.CONJUGATE]: () => `\\overline${this.inBraces(output[0])}`,
|
|
430
|
+
// Linear algebra
|
|
431
|
+
determinant: std,
|
|
432
|
+
// Polynomials
|
|
433
|
+
[constants_1.DEG]: std,
|
|
434
|
+
// Calculus
|
|
435
|
+
limit: () => `\\lim_${this.inBraces(output[1] + ' \\to ' + output[2])} ${output[0]}`,
|
|
436
|
+
integrate: () => output.length === 2 ? `\\int ${output[0]}\\, d${output[1]}` : generic(),
|
|
437
|
+
defint: () => `\\int_${this.inBraces(output[1])}^${this.inBraces(output[2])} ${output[0]}\\, d${output[3]}`,
|
|
438
|
+
diff: () => {
|
|
439
|
+
let retval;
|
|
440
|
+
if (output.length === 1) {
|
|
441
|
+
retval = generic();
|
|
442
|
+
}
|
|
443
|
+
else if (output.length === 3) {
|
|
444
|
+
retval = `\\frac${this.inBraces('d^' + output[2])}${this.inBraces('d' + output[1] + '^' + output[2])} ${output[0]}`;
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
retval = `\\frac${this.inBraces('d')}${this.inBraces('d' + output[1])} ${output[0]}`;
|
|
448
|
+
}
|
|
449
|
+
return retval;
|
|
450
|
+
},
|
|
451
|
+
laplace: () => `\\mathcal{L}_${this.inBraces(output[1] + ' \\to ' + output[2])}\\left\\{${output[0]}\\right\\}`,
|
|
452
|
+
ilaplace: () => `\\mathcal{L}^{-1}_${this.inBraces(output[1] + ' \\to ' + output[2])}\\left\\{${output[0]}\\right\\}`,
|
|
453
|
+
partfrac: () => `\\operatorname{partfrac}${this.inBrackets(output.join(','), 'parens')}`,
|
|
454
|
+
// Summation / product
|
|
455
|
+
sum: () => this.formatSumOrProduct('\\sum', output),
|
|
456
|
+
product: () => this.formatSumOrProduct('\\prod', output),
|
|
457
|
+
// Roots
|
|
458
|
+
nthroot: () => output[1] === '2'
|
|
459
|
+
? `\\sqrt${this.inBraces(output[0])}`
|
|
460
|
+
: `\\sqrt[${output[1]}]${this.inBraces(output[0])}`,
|
|
461
|
+
// Number theory
|
|
462
|
+
gcd: () => name + this.inBrackets(output.join(','), 'parens'),
|
|
463
|
+
lcm: () => `\\operatorname{lcm}${this.inBrackets(output.join(','), 'parens')}`,
|
|
464
|
+
// Wrapper
|
|
465
|
+
[constants_1.WRAP]: () => output[0],
|
|
466
|
+
};
|
|
467
|
+
const handler = handlers[originalName];
|
|
468
|
+
if (handler) {
|
|
469
|
+
return handler();
|
|
470
|
+
}
|
|
471
|
+
return generic();
|
|
472
|
+
}
|
|
473
|
+
formatVariable(value) {
|
|
474
|
+
return this.formatSubscripts(value)
|
|
475
|
+
.split('_')
|
|
476
|
+
.map((v, i) => {
|
|
477
|
+
if (this.mode === BaseConverter_1.BaseConverter.modes.TeX && this.greek.includes(v)) {
|
|
478
|
+
v = `\\${v}`;
|
|
479
|
+
}
|
|
480
|
+
return i > 0 ? this.inBraces(v) : v;
|
|
481
|
+
})
|
|
482
|
+
.join('_');
|
|
483
|
+
}
|
|
484
|
+
getFunctionName(name) {
|
|
485
|
+
if (this.mode !== TeX) {
|
|
486
|
+
return name;
|
|
487
|
+
}
|
|
488
|
+
const mappedName = Converter.TEX_FUNCTION_MAP[name] || name;
|
|
489
|
+
return `\\${mappedName}`;
|
|
490
|
+
}
|
|
491
|
+
handleExp(input, options) {
|
|
492
|
+
const arg = input.getBase();
|
|
493
|
+
let value = this.convert(arg, options);
|
|
494
|
+
if (!(arg.isInteger() || arg.isVAR())) {
|
|
495
|
+
value = this.inBrackets(value);
|
|
496
|
+
}
|
|
497
|
+
return value;
|
|
498
|
+
}
|
|
499
|
+
handleProduct(input, isInverted, options) {
|
|
500
|
+
const mul = this.getMultiplicationSymbol();
|
|
501
|
+
const numOutput = [];
|
|
502
|
+
const denOutput = [];
|
|
503
|
+
for (let element of input.elementsArray()) {
|
|
504
|
+
if (element.isFunction(constants_1.WRAP)) {
|
|
505
|
+
element = element.getArguments()[0];
|
|
506
|
+
}
|
|
507
|
+
const elementIsInverted = element.getPower().sign() === -1;
|
|
508
|
+
const isInDenominator = isInverted ? !elementIsInverted : elementIsInverted;
|
|
509
|
+
const target = isInDenominator ? denOutput : numOutput;
|
|
510
|
+
if (elementIsInverted) {
|
|
511
|
+
element = element.invert();
|
|
512
|
+
}
|
|
513
|
+
let output = this.convert(element, options);
|
|
514
|
+
if (element.isSum() && element.isLinear()) {
|
|
515
|
+
output = this.inBrackets(output);
|
|
516
|
+
}
|
|
517
|
+
target.push(output);
|
|
518
|
+
}
|
|
519
|
+
return [numOutput.join(mul), denOutput.join(mul)];
|
|
520
|
+
}
|
|
521
|
+
handleSum(input, isNegative, options) {
|
|
522
|
+
const elements = input.elementsArray().map(e => this.convert(e, options));
|
|
523
|
+
const value = elements.join('+');
|
|
524
|
+
const needsBrackets = !(input.isLinear() && input.getMultiplier().isOne()) || isNegative;
|
|
525
|
+
return needsBrackets ? this.inBrackets(value, 'parens') : value;
|
|
526
|
+
}
|
|
527
|
+
/** Parses a top-level TeX matrix environment into a scalar-valued Matrix. */
|
|
528
|
+
parseTeXMatrix(input) {
|
|
529
|
+
const match = input.match(/^\\begin\{([pbBvV]?matrix)\}\s*([\s\S]*?)\s*\\end\{\1\}$/);
|
|
530
|
+
let retval;
|
|
531
|
+
if (match) {
|
|
532
|
+
const rows = match[2]
|
|
533
|
+
.split(/\\\\/)
|
|
534
|
+
.map(row => row.trim())
|
|
535
|
+
.filter(row => row.length > 0)
|
|
536
|
+
.map(row => row.split('&').map(cell => Expression_1.Expression.create(this.fromTeX(cell.trim()))));
|
|
537
|
+
retval = new Matrix_1.Matrix(...rows);
|
|
538
|
+
}
|
|
539
|
+
return retval;
|
|
540
|
+
}
|
|
541
|
+
parseTeXSetOrDictionary(inner) {
|
|
542
|
+
const items = this.splitTeXTopLevel(inner, ',');
|
|
543
|
+
const entries = items.map(item => this.splitTeXTopLevel(item, '\\mapsto'));
|
|
544
|
+
const isDictionary = entries.some(parts => parts.length === 2);
|
|
545
|
+
if (isDictionary) {
|
|
546
|
+
const dictionaryEntries = new Map();
|
|
547
|
+
for (const parts of entries) {
|
|
548
|
+
if (parts.length === 2) {
|
|
549
|
+
const key = parts[0].trim();
|
|
550
|
+
const value = this.fromTeX(parts[1].trim());
|
|
551
|
+
dictionaryEntries.set(key, value);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return new Dictionary_1.Dictionary(dictionaryEntries);
|
|
555
|
+
}
|
|
556
|
+
const set = new ValuesSet_1.ValuesSet();
|
|
557
|
+
for (const item of items) {
|
|
558
|
+
if (item.trim()) {
|
|
559
|
+
set.add(this.fromTeX(item.trim()));
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return set;
|
|
563
|
+
}
|
|
564
|
+
parseTeXVector(input) {
|
|
565
|
+
const match = input.match(/^\\left\s*\[([\s\S]*)\\right\s*\]$/) || input.match(/^\[([\s\S]*)\]$/);
|
|
566
|
+
let retval;
|
|
567
|
+
if (match) {
|
|
568
|
+
const elements = this.splitTeXTopLevel(match[1], ',')
|
|
569
|
+
.map(item => item.trim())
|
|
570
|
+
.filter(item => item.length > 0)
|
|
571
|
+
.map(item => this.fromTeX(item));
|
|
572
|
+
retval = new Vector_1.Vector(elements);
|
|
573
|
+
}
|
|
574
|
+
return retval;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Rewrites the supported TeX subset into parser syntax in an ordered pass.
|
|
578
|
+
*
|
|
579
|
+
* Structure-dependent forms such as transforms, derivatives, integrals, limits, and
|
|
580
|
+
* indexed sums must be recognized before generic braces and commands are removed.
|
|
581
|
+
* This is a compatibility preprocessor rather than a TeX grammar, so each rewrite is
|
|
582
|
+
* limited to the forms that can be mapped unambiguously to parser calls.
|
|
583
|
+
*/
|
|
584
|
+
preprocessTeXClean(input) {
|
|
585
|
+
let s = input;
|
|
586
|
+
// Normalize valid short-form fractions before the existing brace-based TeX path runs.
|
|
587
|
+
s = s.replace(/\\frac\s*\{([^{}]+)\}\s*([a-zA-Z0-9.])/g, '\\frac{$1}{$2}');
|
|
588
|
+
s = s.replace(/\\frac\s*([a-zA-Z0-9.])\s*\{([^{}]+)\}/g, '\\frac{$1}{$2}');
|
|
589
|
+
s = s.replace(/\\frac\s*([a-zA-Z0-9.])\s*([a-zA-Z0-9.])/g, '\\frac{$1}{$2}');
|
|
590
|
+
// A whole number immediately followed by a numeric fraction is conventional mixed-number notation.
|
|
591
|
+
s = s.replace(/(\d+)\s*\\frac\s*\{(\d+)\}\s*\{(\d+)\}/g, '($1+\\frac{$2}{$3})');
|
|
592
|
+
// --- Laplace transforms (before brace stripping) ---
|
|
593
|
+
s = s.replace(/\\mathcal\s*\{L\}\s*\^\s*\{-1\}\s*_\s*\{([^{}]+?)\s*\\to\s*([^{}]+?)\}\s*(?:\\left\s*)?\\{(.+?)\\}\s*(?:\\right\s*)?/g, (_m, source, target, expr) => `ilaplace(${expr},${String(source).trim()},${String(target).trim()})`);
|
|
594
|
+
s = s.replace(/\\mathcal\s*\{L\}\s*_\s*\{([^{}]+?)\s*\\to\s*([^{}]+?)\}\s*(?:\\left\s*)?\\{(.+?)\\}\s*(?:\\right\s*)?/g, (_m, source, target, expr) => `laplace(${expr},${String(source).trim()},${String(target).trim()})`);
|
|
595
|
+
s = s.replace(/\\mathcal\s*\{L\}\s*\^\s*\{-1\}\s*(?:\\left\s*)?\\{(.+?)\\}\s*(?:\\right\s*)?/g, 'ilaplace($1)');
|
|
596
|
+
s = s.replace(/\\mathcal\s*\{L\}\s*(?:\\left\s*)?\\{(.+?)\\}\s*(?:\\right\s*)?/g, 'laplace($1)');
|
|
597
|
+
// --- Derivatives: \frac{d^n}{dx^n} f → diff(f, x, n) ---
|
|
598
|
+
// Higher order
|
|
599
|
+
s = s.replace(/\\frac\s*\{d\^(\w+)\}\s*\{d(\w+)\^\1\}\s*(.+)/g, (_m, n, v, f) => `diff(${f},${v},${n})`);
|
|
600
|
+
// First order
|
|
601
|
+
s = s.replace(/\\frac\s*\{d\}\s*\{d(\w+)\}\s*(.+)/g, (_m, v, f) => `diff(${f},${v})`);
|
|
602
|
+
// --- Definite integrals ---
|
|
603
|
+
s = s.replace(/\\int\s*_\s*\{([^}]+)\}\s*\^\s*\{([^}]+)\}\s*(.+?)\\?,?\s*d(\w+)/g, (_m, a, b, f, v) => `defint(${f},${a},${b},${v})`);
|
|
604
|
+
// --- Indefinite integrals ---
|
|
605
|
+
s = s.replace(/\\int\s+(.+?)\\?,?\s*d(\w+)/g, (_m, f, v) => `integrate(${f},${v})`);
|
|
606
|
+
// --- Limits: \lim_{x \to a} f → limit(f, x, a) ---
|
|
607
|
+
s = s.replace(/\\lim\s*_\s*\{(\w+)\s*\\to\s*([^}]+)\}\s*(.+)/g, (_m, v, a, f) => `limit(${f},${v},${a})`);
|
|
608
|
+
// --- Sum / Product: \sum_{i=a}^{b} f → sum(f, i, a, b) ---
|
|
609
|
+
s = s.replace(/\\sum\s*_\s*\{(\w+)=([^}]+)\}\s*\^\s*\{([^}]+)\}\s*(.+)/g, (_m, i, a, b, f) => `sum(${f},${i},${a},${b})`);
|
|
610
|
+
s = s.replace(/\\prod\s*_\s*\{(\w+)=([^}]+)\}\s*\^\s*\{([^}]+)\}\s*(.+)/g, (_m, i, a, b, f) => `product(${f},${i},${a},${b})`);
|
|
611
|
+
// --- Floor / Ceiling ---
|
|
612
|
+
s = s.replace(/(?:\\left\s*)?\\lfloor\s*(.+?)\s*(?:\\right\s*)?\\rceil/g, 'round($1)');
|
|
613
|
+
s = s.replace(/(?:\\left\s*)?\\lfloor\s*/g, 'floor(');
|
|
614
|
+
s = s.replace(/\\rfloor\s*(?:\\right\s*)?/g, ')');
|
|
615
|
+
s = s.replace(/(?:\\left\s*)?\\lceil\s*/g, 'ceil(');
|
|
616
|
+
s = s.replace(/\\rceil\s*(?:\\right\s*)?/g, ')');
|
|
617
|
+
// --- Arbitrary-base logarithms ---
|
|
618
|
+
s = s.replace(/\\log\s*_\s*\{([^}]+)\}\s*\{([^}]+)\}/g, 'log($2,$1)');
|
|
619
|
+
s = s.replace(/\\log\s*_\s*\{([^}]+)\}\s*([a-zA-Z0-9_.]+)/g, 'log($2,$1)');
|
|
620
|
+
// --- Special functions ---
|
|
621
|
+
s = this.replaceBracedTeXCommand(s, 'overline', constants_1.CONJUGATE);
|
|
622
|
+
s = s.replace(/\\Gamma\s*/g, 'gamma');
|
|
623
|
+
s = s.replace(/\\delta\s*/g, constants_1.DIRAC);
|
|
624
|
+
s = s.replace(/(?<![a-zA-Z])H\s*(?=(?:\\left\s*)?\()/g, constants_1.HEAVISIDE);
|
|
625
|
+
s = s.replace(/\\Re\s*/g, 'realpart');
|
|
626
|
+
s = s.replace(/\\Im\s*/g, 'imagpart');
|
|
627
|
+
// --- \operatorname{name} → name ---
|
|
628
|
+
s = s.replace(/\\operatorname\s*\{([^}]+)\}/g, '$1');
|
|
629
|
+
// --- Inverse trig/hyperbolic TeX names → internal names ---
|
|
630
|
+
for (const [texName, internalName] of Object.entries(Converter.TEX_REVERSE_MAP)) {
|
|
631
|
+
if (texName === 'operatorname' ||
|
|
632
|
+
texName === 'Gamma' ||
|
|
633
|
+
texName === 'delta' ||
|
|
634
|
+
texName === 'Re' ||
|
|
635
|
+
texName === 'Im') {
|
|
636
|
+
continue; // already handled above
|
|
637
|
+
}
|
|
638
|
+
s = s.replace(new RegExp(`\\\\${texName}\\b`, 'g'), internalName);
|
|
639
|
+
}
|
|
640
|
+
// --- \bmod ---
|
|
641
|
+
s = s.replace(/(.+?)\s*\\bmod\s*(.+)/g, 'mod($1,$2)');
|
|
642
|
+
// --- nth root: \sqrt[n]{x} → nthroot(x,n), \sqrt{x} → sqrt(x) ---
|
|
643
|
+
s = s.replace(/\\sqrt\s*\[([^\]]+)\]\s*\{([^}]+)\}/g, 'nthroot($2,$1)');
|
|
644
|
+
s = s.replace(/\\sqrt\s*\{([^}]+)\}/g, 'sqrt($1)');
|
|
645
|
+
// --- Standard cleanup (same as original fromTeX) ---
|
|
646
|
+
s = s.replace(/\\,/g, '');
|
|
647
|
+
s = s.replace(/\s*\\cdot\s*/g, '*');
|
|
648
|
+
s = s.replace(/\s*(?:\\left|\\right)\s*/g, '');
|
|
649
|
+
s = s.replace(/\\infty/g, 'Infinity');
|
|
650
|
+
s = s.replace(/\s*[{(]/g, '(');
|
|
651
|
+
s = s.replace(/}/g, ')');
|
|
652
|
+
s = s.replace(/\s+|\\/g, ' ');
|
|
653
|
+
return s;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Rewrites one TeX command whose argument is carried in balanced braces.
|
|
657
|
+
*
|
|
658
|
+
* The converter emits some commands around expressions that can themselves contain
|
|
659
|
+
* nested TeX groups. A flat regular expression cannot safely recover those arguments,
|
|
660
|
+
* so this keeps the brace matching local to the TeX conversion pipeline.
|
|
661
|
+
*/
|
|
662
|
+
replaceBracedTeXCommand(input, command, functionName) {
|
|
663
|
+
const marker = `\\${command}`;
|
|
664
|
+
let retval = '';
|
|
665
|
+
let cursor = 0;
|
|
666
|
+
while (cursor < input.length) {
|
|
667
|
+
const commandIndex = input.indexOf(marker, cursor);
|
|
668
|
+
if (commandIndex === -1) {
|
|
669
|
+
retval += input.slice(cursor);
|
|
670
|
+
cursor = input.length;
|
|
671
|
+
}
|
|
672
|
+
else {
|
|
673
|
+
retval += input.slice(cursor, commandIndex);
|
|
674
|
+
let openIndex = commandIndex + marker.length;
|
|
675
|
+
while (openIndex < input.length && /\s/.test(input[openIndex])) {
|
|
676
|
+
openIndex++;
|
|
677
|
+
}
|
|
678
|
+
if (input[openIndex] !== '{') {
|
|
679
|
+
retval += marker;
|
|
680
|
+
cursor = commandIndex + marker.length;
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
let depth = 1;
|
|
684
|
+
let closeIndex = openIndex + 1;
|
|
685
|
+
while (closeIndex < input.length && depth > 0) {
|
|
686
|
+
if (input[closeIndex] === '{') {
|
|
687
|
+
depth++;
|
|
688
|
+
}
|
|
689
|
+
else if (input[closeIndex] === '}') {
|
|
690
|
+
depth--;
|
|
691
|
+
}
|
|
692
|
+
closeIndex++;
|
|
693
|
+
}
|
|
694
|
+
if (depth !== 0) {
|
|
695
|
+
retval += input.slice(commandIndex);
|
|
696
|
+
cursor = input.length;
|
|
697
|
+
}
|
|
698
|
+
else {
|
|
699
|
+
const inner = input.slice(openIndex + 1, closeIndex - 1);
|
|
700
|
+
const convertedInner = this.replaceBracedTeXCommand(inner, command, functionName);
|
|
701
|
+
retval += `${functionName}(${convertedInner})`;
|
|
702
|
+
cursor = closeIndex;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return retval;
|
|
708
|
+
}
|
|
709
|
+
splitTeXTopLevel(input, delimiter) {
|
|
710
|
+
const items = [];
|
|
711
|
+
let depth = 0;
|
|
712
|
+
let current = '';
|
|
713
|
+
for (let i = 0; i < input.length; i++) {
|
|
714
|
+
const ch = input[i];
|
|
715
|
+
if (delimiter === ',' && ch === '\\' && input[i + 1] === ',') {
|
|
716
|
+
i++;
|
|
717
|
+
continue;
|
|
718
|
+
}
|
|
719
|
+
if (ch === '{' || ch === '[' || ch === '(') {
|
|
720
|
+
depth++;
|
|
721
|
+
}
|
|
722
|
+
else if (ch === '}' || ch === ']' || ch === ')') {
|
|
723
|
+
depth--;
|
|
724
|
+
}
|
|
725
|
+
if (depth === 0 && input.startsWith(delimiter, i)) {
|
|
726
|
+
items.push(current);
|
|
727
|
+
current = '';
|
|
728
|
+
i += delimiter.length - 1;
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
current += ch;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
if (current.trim()) {
|
|
735
|
+
items.push(current);
|
|
736
|
+
}
|
|
737
|
+
return items;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Formats supported values while retaining ordinary Converter semantics by default.
|
|
741
|
+
* Source preservation is an internal compatibility option used by convertToLaTeX.
|
|
742
|
+
*/
|
|
743
|
+
convert(input, options) {
|
|
744
|
+
let retval;
|
|
745
|
+
if (typeof input === 'string' &&
|
|
746
|
+
this.mode === TeX &&
|
|
747
|
+
options?.preserveSource === true &&
|
|
748
|
+
options.decimal !== true) {
|
|
749
|
+
const rpn = Parser_1.Parser.toRPN(Parser_1.Parser.tokenize(input));
|
|
750
|
+
const converted = this.convertSourceRPN(rpn, options);
|
|
751
|
+
retval = converted.args
|
|
752
|
+
? converted.args.map(arg => arg.text).join(',')
|
|
753
|
+
: converted.text;
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
retval = super.convert(input, options);
|
|
757
|
+
}
|
|
758
|
+
return retval;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Parses a supported TeX subset into a Nerdamer parser entity.
|
|
762
|
+
*
|
|
763
|
+
* @remarks
|
|
764
|
+
* Set notation is recognized before ordinary expression preprocessing and produces a
|
|
765
|
+
* value set or dictionary when appropriate. Other input is rewritten to Nerdamer
|
|
766
|
+
* parser syntax, tokenized in pure mode, and evaluated through the process-wide parser.
|
|
767
|
+
* Consequently, parser settings or registered functions can affect the result.
|
|
768
|
+
*
|
|
769
|
+
* The importer supports the converter's common function forms, roots, arbitrary-base
|
|
770
|
+
* logarithms, transforms, derivatives, integrals, limits, sums, products, floor and
|
|
771
|
+
* ceiling notation, equations, vectors, matrices, finite sets, and dictionaries. It does
|
|
772
|
+
* not promise round-tripping arbitrary third-party TeX.
|
|
773
|
+
*
|
|
774
|
+
* @param input - TeX text in the supported conversion subset.
|
|
775
|
+
* @returns The parser entity represented by the supported TeX input.
|
|
776
|
+
* @throws Error When preprocessing leaves syntax that the parser cannot interpret.
|
|
777
|
+
*
|
|
778
|
+
* @example
|
|
779
|
+
* ```ts
|
|
780
|
+
* import nerdamer from 'nerdamer';
|
|
781
|
+
*
|
|
782
|
+
* const converter = new nerdamer.classes.Converter();
|
|
783
|
+
* nerdamer.pretty(converter.fromTeX('\\log_{2}{256}'), 'text'); // "8"
|
|
784
|
+
* ```
|
|
785
|
+
*/
|
|
786
|
+
fromTeX(input) {
|
|
787
|
+
const trimmed = input.trim();
|
|
788
|
+
const matrix = this.parseTeXMatrix(trimmed);
|
|
789
|
+
if (matrix) {
|
|
790
|
+
return matrix;
|
|
791
|
+
}
|
|
792
|
+
const vector = this.parseTeXVector(trimmed);
|
|
793
|
+
if (vector) {
|
|
794
|
+
return vector;
|
|
795
|
+
}
|
|
796
|
+
// Detect set/dictionary notation: \{...\} or \left\{...\right\}
|
|
797
|
+
const setMatch = trimmed.match(/^\\left\s*\\{(.*)\\right\s*\\}$/) || trimmed.match(/^\\{(.*)\\}$/);
|
|
798
|
+
if (setMatch) {
|
|
799
|
+
return this.parseTeXSetOrDictionary(setMatch[1]);
|
|
800
|
+
}
|
|
801
|
+
const str = this.preprocessTeXClean(input);
|
|
802
|
+
const TeXRPN = Parser_1.Parser.tokenize(str, { pure: true });
|
|
803
|
+
return Parser_1.Parser.parse(Parser_1.Parser.parseTeXRPN(TeXRPN));
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
exports.Converter = Converter;
|