Syncs code examples with markdown documentation.
npm install markdown-code-example-inserterSyncs markdown documentation with code examples.
Via npm:
``bash`
npm i -D markdown-code-example-inserter
It's recommended to install this package as a dev dependency as it is a build-step operation.
Add an HTML comment that starts with the following text: example-link:. Then after that text, include a file path to the example file:
`html`
Here's an example from the GitHub repo. And here is the same file with the code examples inserted.
`bash`
npx md-code file1.md file2.md [...moreFiles]
Any of the file names can be a glob. Put the glob in quotes if you wish to prevent your shell from expanding it (this package will expand the glob):
`bash`
npx md-code "./*.md"
Use --check.
Check if the given files are updated, don't write anything.
`bash`
npx md-code file1.md --check
Use --index.
Force an index file for imports that should be rewritten with your package name:
`bash`
npx md-code file1.md --index path/to/index.ts file2.md [...moreFiles]
The index file is used to replace relative imports with package name imports. Like changing import from '../../index' to import from 'my-package'.
Use --ignore.
`bash`
npx md-code ".//.md" --ignore "./test-files//"
Multiple --ignore patterns can be used:
`bash`
npx md-code ".//.md" --ignore "./test-files//" -ignore "./test-files/*/"
node_modules is automatically ignored.
Use --silent
`bash``
npx md-code --silent file1.md