This repository provides a template for creating plugins for markdown-it, a popular Markdown parser for JavaScript.
- Standardized project structure
- Vite and Typescript
- Automatic test case generation based on input (
.md
) and output (.html
) files - Fast testing via Vitest, allowing test-first development and quick iterations
To create a new markdown-it plugin using this template, simply click the button Use this template
above.
src/index.ts
is the plugin entry pointdocs
may be used for additional documentation files, such as a preview imagetest
contains the fixtures used to test the plugin
This template uses file-based test definitions (fixtures). For each test, you create an input markdown file and the corresponding HTML output. Both files must have the same name, which is then used as the name of the test case. Folders can be used to create test suites, e.g. test/invalid-syntax
containing different cases of wrong usage of the plugin.
- Install the required dependencies by running
npm install
. - Specify the desired input/output by creating Markdown and HTML files inside the
/test
directory. Use sub-directories to group them. - Start vitest watch mode:
npm run dev
- Customize the file
src/index.ts
to provide the functionality you need. - Build the plugin:
npm run build