{"id":26463830,"url":"https://github.com/executablebooks/markdown-it-amsmath","last_synced_at":"2025-03-19T07:16:35.605Z","repository":{"id":43858935,"uuid":"381211695","full_name":"executablebooks/markdown-it-amsmath","owner":"executablebooks","description":"A markdown-it plugin for amsmath LaTeX environments.","archived":false,"fork":false,"pushed_at":"2024-04-16T23:07:31.000Z","size":1031,"stargazers_count":3,"open_issues_count":4,"forks_count":1,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-02-17T09:06:53.217Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://executablebooks.github.io/markdown-it-amsmath/","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/executablebooks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2021-06-29T02:05:55.000Z","updated_at":"2021-12-02T05:55:32.000Z","dependencies_parsed_at":"2024-04-17T00:25:08.003Z","dependency_job_id":"c64e4761-86fe-45ab-bd83-a9df3716b0fa","html_url":"https://github.com/executablebooks/markdown-it-amsmath","commit_stats":{"total_commits":19,"total_committers":2,"mean_commits":9.5,"dds":"0.26315789473684215","last_synced_commit":"fb64b2153a85e7f05620dd577b6956670bf4ba6a"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":"executablebooks/markdown-it-plugin-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/executablebooks%2Fmarkdown-it-amsmath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/executablebooks%2Fmarkdown-it-amsmath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/executablebooks%2Fmarkdown-it-amsmath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/executablebooks%2Fmarkdown-it-amsmath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/executablebooks","download_url":"https://codeload.github.com/executablebooks/markdown-it-amsmath/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066189,"owners_count":20392407,"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":[],"created_at":"2025-03-19T07:16:35.017Z","updated_at":"2025-03-19T07:16:35.599Z","avatar_url":"https://github.com/executablebooks.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# markdown-it-amsmath\n\n[![ci-badge]][ci-link]\n[![npm-badge]][npm-link]\n\nA [markdown-it](https://github.com/markdown-it/markdown-it) plugin for [amsmath](https://ctan.org/pkg/amsmath) LaTeX environments.\n\nThe following \"top-level\" environments are parsed, with or without (ending `*`) numbering:\n`equation`, `multline`, `gather`, `align`, `alignat`, `flalign`, `matrix`, `pmatrix`, `bmatrix`, `Bmatrix`, `vmatrix`, `Vmatrix`, `eqnarray`.\n\n(these environments are taken from [amsmath version 2.1](http://anorien.csc.warwick.ac.uk/mirrors/CTAN/macros/latex/required/amsmath/amsldoc.pdf))\n\nNote the `split`, `gathered`, `aligned`, `alignedat` are not parsed, since they should be used within a parent environment.\n\nSee \u003chttps://executablebooks.github.io/markdown-it-amsmath/\u003e for a demonstration!\n\n## Usage\n\nYou should \"bring your own\" math render, provided as an option to the plugin.\nThis function should take the string plus (optional) options, and return a string.\nFor example, below the [KaTeX](https://github.com/Khan/KaTeX) render is used.\n\nAs a Node module:\n\n```javascript\nimport { renderToString } from \"katex\"\nimport MarkdownIt from \"markdown-it\"\nimport amsmathPlugin from \"markdown-it-amsmath\"\n\nconst katexOptions = { throwOnError: false, displayMode: true }\nconst renderer = math =\u003e renderToString(math, katexOptions)\nconst mdit = MarkdownIt().use(amsmathPlugin, { renderer })\nconst text = mdit.render(\"\\\\begin{equation}a = 1\\\\end{equation}\")\n```\n\nIn the browser:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eExample Page\u003c/title\u003e\n    \u003clink\n      rel=\"stylesheet\"\n      href=\"https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css\"\n    /\u003e\n    \u003cscript src=\"https://cdn.jsdelivr.net/npm/markdown-it@12/dist/markdown-it.min.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"https://cdn.jsdelivr.net/npm/katex/dist/katex.min.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"https://unpkg.com/markdown-it-amsmath\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv id=\"demo\"\u003e\u003c/div\u003e\n    \u003cscript\u003e\n      const katexOptions = { throwOnError: false, displayMode: true }\n      const renderer = math =\u003e katex.renderToString(math, katexOptions)\n      const mdit = window.markdownit().use(window.markdownitAmsmath, { renderer })\n      const text = mdit.render(\"\\\\begin{equation}a = 1\\\\end{equation}\")\n      document.getElementById(\"demo\").innerHTML = text\n    \u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Development\n\n### Features\n\n- TypeScript\n- Code Formatting ([prettier])\n- Code Linting ([eslint])\n- Testing and coverage ([vitest])\n- Continuous Integration ([GitHub Actions])\n- Bundled as both UMD and ESM ([rollup])\n- Upload as [NPM] package and [unpkg] CDN\n- Simple demonstration website ([GitHub Pages])\n\n### Getting Started\n\n1. Create a GitHub repository [from the template](https://docs.github.com/en/github-ae@latest/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/creating-a-repository-from-a-template).\n2. Replace package details in the following files:\n   - `package.json`\n   - `LICENSE`\n   - `README.md`\n   - `rollup.config.js`\n3. Install the `node_module` dependencies: `npm install` or `npm ci` (see [Install a project with a clean slate](https://docs.npmjs.com/cli/v7/commands/npm-ci)).\n4. Run code formatting; `npm run format`, and linting: `npm run lint:fix`.\n5. Run the unit tests; `npm test`, or with coverage; `npm test -- --coverage`.\n\nNow you can start to adapt the code in `src/index.ts` for your plugin, starting with the [markdown-it development recommendations](https://github.com/markdown-it/markdown-it/blob/master/docs/development.md).\n\nModify the test in `tests/fixtures.spec.ts`, to load your plugin, then the \"fixtures\" in `tests/fixtures`, to provide a set of potential Markdown inputs and expected HTML outputs.\n\nOn commits/PRs to the `master` branch, the GH actions will trigger, running the linting, unit tests, and build tests.\nAdditionally setup and uncomment the [codecov](https://about.codecov.io/) action in `.github/workflows/ci.yml`, to provide automated CI coverage.\n\nFinally, you can update the version of your package, e.g.: `npm version patch -m \"🚀 RELEASE: v%s\"`, push to GitHub; `git push --follow-tags`, build; `npm run build`, and publish; `npm publish`.\n\nFinally, you can adapt the HTML document in `docs/`, to load both markdown-it and the plugin (from [unpkg]), then render text from an input area.\nThis can be deployed by [GitHub Pages].\n\n[ci-badge]: https://github.com/executablebooks/markdown-it-amsmath/workflows/CI/badge.svg\n[ci-link]: https://github.com/executablebooks/markdown-it--plugin-template/actions\n[npm-badge]: https://img.shields.io/npm/v/markdown-it-amsmath.svg\n[npm-link]: https://www.npmjs.com/package/markdown-it-amsmath\n[github actions]: https://docs.github.com/en/actions\n[github pages]: https://docs.github.com/en/pages\n[prettier]: https://prettier.io/\n[eslint]: https://eslint.org/\n[vitest]: https://vitest.dev/\n[rollup]: https://rollupjs.org\n[npm]: https://www.npmjs.com\n[unpkg]: https://unpkg.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexecutablebooks%2Fmarkdown-it-amsmath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexecutablebooks%2Fmarkdown-it-amsmath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexecutablebooks%2Fmarkdown-it-amsmath/lists"}