markdown-it
plugin for opting out of wrapping fenced code in <pre><code>
.
By default, markdown-it
will always wrap rendered fenced code in <pre><code>
. That's a good default: it turns
```js
…
```
into
<pre>
<code>
…
</code>
</pre>
But that's not the behavior you want if you're using a fenced code processor which adds the <pre><code>
wrappers for you, or if you don't want <pre><code>
wrappers at all.
<package manager> add [-D] @olets/markdown-it-wrapperless-fence-rule
import markdownItWrapperlessFenceRule from '@olets/markdown-it-wrapperless-fence-rule';
import MarkdownIt from 'markdown-it';
const md = MarkdownIt();
md.renderer.rules.fence = markdownItWrapperlessFenceRule;
md.use(/* … */);
- Basic: https://stackblitz.com/edit/oletsmarkdown-it-wrapperless-fence-rule-basic-demo?file=main.js
- Shiki: https://stackblitz.com/edit/oletsmarkdown-it-wrapperless-fence-rule-shiki-demo?file=main.js
markdown-it always renders fenced code with an outermost <pre>
markdown-it/markdown-it#269, and that doesn't play nice with transforming Shiki's output shikijs/shiki#811.
Thanks for your interest. Contributions are welcome!
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Check the Issues to see if your topic has been discussed before or if it is being worked on.
Please read CONTRIBUTING.md before opening a pull request.
See LICENSE.