{"id":22920598,"url":"https://github.com/mathjslab/mathjslab","last_synced_at":"2026-03-27T04:51:31.883Z","repository":{"id":187966220,"uuid":"606645564","full_name":"MathJSLab/mathjslab","owner":"MathJSLab","description":"MathJSLab - An interpreter with language syntax like MATLAB/Octave. ISBN 978-65-00-82338-7","archived":false,"fork":false,"pushed_at":"2024-12-02T01:15:32.000Z","size":564,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-02T01:29:37.622Z","etag":null,"topics":["antlr","antlr4","educational","grammar","interpreter","lexer","math","mathematics","mathjslab","mathml","matlab","octave","parser"],"latest_commit_sha":null,"homepage":"https://mathjslab.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MathJSLab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-26T05:29:31.000Z","updated_at":"2024-12-02T01:15:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"c98b0eaf-d6ba-4400-b008-a9a7d58ec1ce","html_url":"https://github.com/MathJSLab/mathjslab","commit_stats":null,"previous_names":["sergiolindau/mathjslab","mathjslab/mathjslab"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathJSLab%2Fmathjslab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathJSLab%2Fmathjslab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathJSLab%2Fmathjslab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathJSLab%2Fmathjslab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MathJSLab","download_url":"https://codeload.github.com/MathJSLab/mathjslab/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229673741,"owners_count":18105435,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["antlr","antlr4","educational","grammar","interpreter","lexer","math","mathematics","mathjslab","mathml","matlab","octave","parser"],"created_at":"2024-12-14T07:16:22.660Z","updated_at":"2026-03-27T04:51:31.849Z","avatar_url":"https://github.com/MathJSLab.png","language":"TypeScript","readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://mathjslab.com/\" target=\"_blank\" rel=\"noopener\"\u003e\u003cimg src=\"mathjslab-logo.svg\" alt=\"logo\" width=\"210\" height=\"210\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# [MathJSLab](https://mathjslab.com/) - [mathjslab.com](https://mathjslab.com/)\n\n[![NPM Version](https://img.shields.io/npm/v/mathjslab)](https://www.npmjs.com/package/mathjslab)\n[![Website](https://img.shields.io/website?url=https%3A%2F%2Fmathjslab.com%2F)](https://mathjslab.com/)\n[![GitHub Created At](https://img.shields.io/github/created-at/MathJSLab/mathjslab)](https://github.com/MathJSLab/mathjslab)\n[![MIT License](https://img.shields.io/npm/l/mathjslab)](https://github.com/MathJSLab/mathjslab/blob/main/LICENSE)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8396265.svg)](https://doi.org/10.5281/zenodo.8396265)\n[![ISBN](https://img.shields.io/badge/ISBN-978--65--00--82338--7-green?style=flat\u0026link=https://grp.isbn-international.org/search/piid_solr?keys=978-65-00-82338-7)](https://grp.isbn-international.org/search/piid_solr?keys=978-65-00-82338-7)\n[![OpenAIRE](https://img.shields.io/badge/OpenAIRE-blue?style=flat\u0026link=https://explore.openaire.eu/search/advanced/research-outcomes?f0=q\u0026fv0=MathJSLab)](https://explore.openaire.eu/search/advanced/research-outcomes?f0=q\u0026fv0=MathJSLab)\n[![NPM Downloads](https://img.shields.io/npm/d18m/mathjslab)](https://www.npmjs.com/package/mathjslab)\n[![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hy/mathjslab)](https://www.jsdelivr.com/package/npm/mathjslab)\n[![Libraries.io SourceRank](https://img.shields.io/librariesio/sourcerank/npm/mathjslab)](https://libraries.io/npm/mathjslab/sourcerank)\n[![NPM Bundle Size](https://img.shields.io/bundlephobia/min/mathjslab)](https://www.npmjs.com/package/mathjslab)\n[![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/mathjslab)](https://www.npmjs.com/package/mathjslab)\n[![Minzip Size](https://img.shields.io/bundlephobia/minzip/mathjslab)](https://www.npmjs.com/package/mathjslab)\n[![NPM package minimized gzipped size](https://img.shields.io/bundlejs/size/mathjslab)](https://www.npmjs.com/package/mathjslab)\n\n\u003e An [interpreter](https://en.wikipedia.org/wiki/Interpreter_(computing)) with language syntax like [MATLAB\u0026reg;](https://www.mathworks.com/products/matlab.html)/[Octave](https://www.gnu.org/software/octave/) written in [TypeScript](https://www.typescriptlang.org/).\n\n**[ISBN 978-65-00-82338-7](https://grp.isbn-international.org/search/piid_solr?keys=978-65-00-82338-7)**\n\nThis package emulates a parser and evaluator for a subset of\n[MATLAB\u0026reg;](https://www.mathworks.com/products/matlab.html)/[Octave](https://www.gnu.org/software/octave/)\nlanguage. It is written completely in [TypeScript](https://www.typescriptlang.org/).\n\nThe project page with a functional demo use of this package in a\n[Web application](https://en.wikipedia.org/wiki/Web_application) can be found\nat [mathjslab.com](https://mathjslab.com/). The repository is in the\n[MathJSLab Organization](https://github.com/MathJSLab) on\n[GitHub](https://github.com/).\n\n**Important Notice:** This software, the **[MathJSLab](https://mathjslab.com/),\nis not affiliated, sponsored, or endorsed by [The MathWorks, Inc.](https://www.mathworks.com/)**\n[MATLAB\u0026reg;](https://www.mathworks.com/products/matlab.html) is a registered\ntrademark of [The MathWorks, Inc.](https://www.mathworks.com/) For more\ninformation about [MATLAB](https://www.mathworks.com/products/matlab.html), visit\n[www.mathworks.com](https://www.mathworks.com/).\n\nIt can run in browser environment and implements an arbitrary precision\narithmetics using [decimal.js](https://www.npmjs.com/package/decimal.js)\npackage.\n\nIt uses the [ANTLR](https://www.antlr.org/)\n[parser generator](https://en.wikipedia.org/wiki/Compiler-compiler) to\ngenerate a [parser](https://en.wikipedia.org/wiki/Parsing) that create an\n[AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree)\n([Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree)) of input.\n\nOther components besides the [parser](https://en.wikipedia.org/wiki/Parsing)\nare the evaluator, which computes the inputs, and the [MathML](https://www.w3.org/Math/)\nunparser, that generates mathematical representations of the inputs and results.\n\nThis software is intended for **educational purposes**, to provide teachers and\nstudents with a computer aided calculation tool that is capable of running in\na browser environment. So it can be easily adapted to be used on different devices\nand environments.\n\nAll [MathJSLab](https://mathjslab.com/)\n[interpreter](https://en.wikipedia.org/wiki/Interpreter_(computing))\noperations, functions and commands are documented in the\n[demo Web application's](https://github.com/MathJSLab/mathjslab-app) command\n`help NAME`. Its in\n[english](https://github.com/MathJSLab/mathjslab-app/tree/main/help/en),\n[portuguese](https://github.com/MathJSLab/mathjslab-app/tree/main/help/pt)\nand [spanish](https://github.com/MathJSLab/mathjslab-app/tree/main/help/es).\nIt can also be accessed directly from the\n[demo Web application repository](https://github.com/MathJSLab/mathjslab-app/tree/main/help).\nAdditional documentation, beyond the operations, functions and commands, is\navailable in the\n[demo Web application `doc` directory](https://github.com/MathJSLab/mathjslab-app/tree/main/doc).\n\n## Features\n\n- Runs on any [JavaScript](https://www.ecma-international.org/publications-and-standards/standards/ecma-262/) engine. All `mathjslab` code was written synchronously. Asynchronous functions were used only at build time.\n- Improved demo [Web application](https://en.wikipedia.org/wiki/Web_application) at project page: [mathjslab.com](https://mathjslab.com/) ([repository](https://github.com/MathJSLab/mathjslab-app)). The demo [Web application](https://en.wikipedia.org/wiki/Web_application) was coded as a [Progressive Web App (PWA)](https://pt.wikipedia.org/wiki/Progressive_web_app), with the most modern web programming features, such as:\n    * Reusable [Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components) to structure the user interface.\n    * [Responsive](https://en.wikipedia.org/wiki/Responsive_web_design) [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML) elements and [components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components).\n    * [Styles](https://www.w3.org/TR/css/) defined by [SASS](https://sass-lang.com/) templates, with definitions in a more rationalized and modular manner.\n    * [Nunjucks](https://mozilla.github.io/nunjucks/) templates processed by [Eleventy](https://www.11ty.dev/) to dynamically configure values ​​at build time.\n- Comes with a large set of built-in operations, functions and commands well documented in the demo [Web application](https://en.wikipedia.org/wiki/Web_application) in [english](https://github.com/MathJSLab/mathjslab-app/tree/main/help/en), [portuguese](https://github.com/MathJSLab/mathjslab-app/tree/main/help/pt) and [spanish](https://github.com/MathJSLab/mathjslab-app/tree/main/help/es).\n- Includes test suite using [Jest](https://jestjs.io/) [framework](https://en.wikipedia.org/wiki/Software_framework) (most tests not yet implemented).\n- Is easily extensible through configuration parameters passed to [`Evaluator` constructor](https://github.com/MathJSLab/mathjslab/blob/main/src/Evaluator.ts).\n- [Open source](https://opensource.org/) software with fully documented code: [MIT License](https://github.com/MathJSLab/mathjslab/blob/main/LICENSE).\n- Software with assigned [ISBN](https://grp.isbn-international.org/search/piid_solr?keys=978-65-00-82338-7) and [DOI](https://doi.org/10.5281/zenodo.8396265), so that it can be used in academic work and research, being referenced appropriately. Any inclusion of authors will result in an update of the [ISBN](https://grp.isbn-international.org/) records.\n\n## Supported environments\n\n[MathJSLab](https://mathjslab.com/) works on any [ES2015](https://262.ecma-international.org/6.0/) compatible\n[JavaScript](https://www.ecma-international.org/publications-and-standards/standards/ecma-262/)\nengine, including [Node.js](https://nodejs.org/),\n[Chrome](https://www.google.com/chrome/),\n[Firefox](https://www.mozilla.org/en-US/firefox/),\n[Safari](https://www.apple.com/safari/),\n[Opera](https://www.opera.com),\nand [Edge](https://www.microsoft.com/edge).\n\nThere are 6 different bundles:\n- For [Node.js](https://nodejs.org/) environment, [CommonJS](https://nodejs.org/docs/latest/api/modules.html), [ES2015](https://262.ecma-international.org/6.0/) target ([mathjslab.node.cjs2015.js](https://cdn.jsdelivr.net/npm/mathjslab/lib/mathjslab.node.cjs2015.js)).\n- For [Node.js](https://nodejs.org/) environment, [CommonJS](https://nodejs.org/docs/latest/api/modules.html), [ES2020](https://262.ecma-international.org/11.0/) target ([mathjslab.node.cjs2020.js](https://cdn.jsdelivr.net/npm/mathjslab/lib/mathjslab.node.cjs2020.js)).\n- For [Node.js](https://nodejs.org/) environment, [ES Module](https://nodejs.org/api/esm.html), [ES2020](https://262.ecma-international.org/11.0/) target ([mathjslab.node.esm2020.js](https://cdn.jsdelivr.net/npm/mathjslab/lib/mathjslab.node.esm2020.js)).\n- For browser environment, [UMD](https://github.com/umdjs/umd), [ES2015](https://262.ecma-international.org/6.0/) target ([mathjslab.web.umd2015.js](https://cdn.jsdelivr.net/npm/mathjslab/lib/mathjslab.web.umd2015.js)).\n- For browser environment, [UMD](https://github.com/umdjs/umd), [ES2020](https://262.ecma-international.org/11.0/) target ([mathjslab.web.umd2020.js](https://cdn.jsdelivr.net/npm/mathjslab/lib/mathjslab.web.umd2020.js)).\n- For browser environment, [ES Module](https://nodejs.org/api/esm.html), [ES2020](https://262.ecma-international.org/11.0/) target ([mathjslab.web.esm2020.js]((https://cdn.jsdelivr.net/npm/mathjslab/lib/mathjslab.web.esm2020.js))).\n\n\n## Installation\n\nInstall the `mathjslab` package:\n\n```bash\nnpm install mathjslab\n```\n\n## Usage\n\nThe basic [API](https://en.wikipedia.org/wiki/API) is an instantiation of `Evaluator` class with optional configuration.\n\nImport **[MathJSLab](https://mathjslab.com/) [API](https://en.wikipedia.org/wiki/API)**:\n\n```typescript\nimport { Evaluator, TEvaluatorConfig } from 'mathjslab';\n```\n\nInstantiate the `Evaluator` class with:\n\n```typescript\nlet evaluator: Evaluator = new Evaluator(EvaluatorConfiguration);\n```\n\n### Examples\n\n* **Parsing**:\n```typescript\nlet input: AST.NodeInput = evaluator.Parse('x=sqrt(1+2*3)');\n```\n\n* **Evaluation**:\n```typescript\nlet result: AST.NodeInput = evaluator.Evaluate(input);\n```\n\n* **[MathML](https://www.w3.org/Math/) generation**:\n```typescript\nlet mathmlInput: string = evaluator.UnparseMathML(input);\nlet mathmlResult: string = evaluator.UnparseMathML(result);\n```\n\nYou can try [some basic examples](https://codepen.io/collection/BaNkVd) on [CodePen](https://codepen.io/).\n\n## Using a [CDN](https://en.wikipedia.org/wiki/Content_delivery_network)\n\nYou can optimize your application by reducing the size of your bundle by\nloading [MathJSLab package](https://www.npmjs.com/package/mathjslab) through a\n[CDN](https://en.wikipedia.org/wiki/Content_delivery_network).\n\nYou can use [UNPKG](https://unpkg.com/), [jsDelivr](https://www.jsdelivr.com/),\nor any other [CDN](https://en.wikipedia.org/wiki/Content_delivery_network)\nthat delivers content from the [npm registry](https://www.npmjs.com/).\n\n### Using [UNPKG](https://unpkg.com/)\n\nTo load [MathJSLab package](https://www.npmjs.com/package/mathjslab) through\n[UNPKG](https://unpkg.com/browse/mathjslab/)\n[CDN](https://en.wikipedia.org/wiki/Content_delivery_network) copy the\nfollowing [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML) code:\n\n```html\n\u003cscript src=\"https://www.unpkg.com/mathjslab\"\u003e\u003c/script\u003e\n```\n\n### Using [jsDelivr](https://www.jsdelivr.com/)\n\n[![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hy/mathjslab)](https://www.jsdelivr.com/package/npm/mathjslab)\n\nTo load [MathJSLab package](https://www.npmjs.com/package/mathjslab) through\n[jsDelivr](https://www.jsdelivr.com/package/npm/mathjslab)\n[CDN](https://en.wikipedia.org/wiki/Content_delivery_network) copy the\nfollowing [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML) code:\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/mathjslab\"\u003e\u003c/script\u003e\n```\n\n### [MathJSLab](https://www.npmjs.com/package/mathjslab) [module](https://github.com/umdjs/umd) use\n\nThe [UMD module](https://github.com/umdjs/umd) will be loaded with `mathjslab` name. You can instantiate `Evaluator` with:\n\n```typescript\nlet evaluator = new mathjslab.Evaluator(EvaluatorConfiguration);\n```\n\n## Contributing\n\nTo contribute to this project see our\n[contributing guidelines](https://github.com/MathJSLab/mathjslab/blob/main/CONTRIBUTING.md).\n\nJoin the community chat:\n\n[![Join the chat at https://matrix.to/#/#mathjslab:gitter.im](https://badges.gitter.im/Join%20Chat.svg)](https://matrix.to/#/#mathjslab:gitter.im?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n## Project build and test\n\nTo build the project, you only need [Node.js](https://nodejs.org/) and\nthe [Java Runtime Environment](https://www.oracle.com/java/) installed. The\nproject build and dependencies are managed by\n[npm](https://www.npmjs.com/package/npm) through scripts in the\n[`package.json`](https://github.com/MathJSLab/mathjslab/blob/main/package.json)\nfile. The build scripts download the latest version of\n[ANTLR](https://www.antlr.org/) into the resources directory for use by the\nproject. The test suite uses the [Jest](https://jestjs.io/)\n[framework](https://en.wikipedia.org/wiki/Software_framework).\n\n### Build scripts\n\nThe following build scripts are defined:\n\n1. **Before building and testing** `mathjslab`, to **initialize** the project workspace, run:\n```bash\nnpm run update\n```\nThis will update the dependencies, install all of them, and download the\nlatest version of [ANTLR](https://www.antlr.org/), preparing any resources\nneeded to build the project.\n\n2. Run the `mathjslab` **tests**:\n```bash\nnpm run test\n```\n\n3. **Format** and **lint** `mathjslab` code:\n```bash\nnpm run format:lint\n```\n\n4. **Build** `mathjslab` package:\n```bash\nnpm run build\n```\n\n5. To **cleanup** all build files in workspace use:\n```bash\nnpm run clean\n```\n\n6. To **delete resources and dependencies**, the `package-lock.json` file and\n`node_modules` directory too, use:\n```bash\nnpm run clean:all\n```\nAfter run this command you will need to do workspace setup running\n`npm run update` again.\n\n## Language subset\n\nCurrently only the mathematical expressions of the language are implemented. The control and loop structures are not yet implemented.\n\nThere are some differences from the original\n[MATLAB\u0026reg;](https://www.mathworks.com/products/matlab.html)/[Octave](https://www.gnu.org/software/octave/).\nThe main difference is that there are only one a complex numeric type. Other\nimplemented types is boolean, character string, structure and function handle.\n\nCommon arrays (not only cell arrays) can hold any type of element.\n\n## Trademark Notes\n\n- [MATLAB\u0026reg;](https://www.mathworks.com/products/matlab.html) is a registered trademark of [The MathWorks, Inc.](https://www.mathworks.com/)\n- [MathJSLab](https://mathjslab.com/) is not affiliated, sponsored, or endorsed by [The MathWorks, Inc.](https://www.mathworks.com/)\n\n## License\n\n\u003e[MIT License](https://opensource.org/license/mit)\n\u003e\n\u003eCopyright \u0026copy; 2016-2025 [Sergio Lindau](mailto:sergiolindau@gmail.com), [mathjslab.com](https://mathjslab.com/), [ISBN 978-65-00-82338-7](https://grp.isbn-international.org/search/piid_solr?keys=978-65-00-82338-7).\n\u003e\n\u003ePermission is hereby granted, free of charge, to any person obtaining a copy\n\u003eof this software and associated documentation files (the \"Software\"), to deal\n\u003ein the Software without restriction, including without limitation the rights\n\u003eto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\u003ecopies of the Software, and to permit persons to whom the Software is\n\u003efurnished to do so, subject to the following conditions:\n\u003e\n\u003eThe above copyright notice and this permission notice shall be included in all\n\u003ecopies or substantial portions of the Software.\n\u003e\n\u003eTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\u003eIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\u003eFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\u003eAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\u003eLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\u003eOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n\u003eSOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathjslab%2Fmathjslab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathjslab%2Fmathjslab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathjslab%2Fmathjslab/lists"}