Skip to content

olets/markdown-it-wrapperless-fence-rule

Repository files navigation

@olets/markdown-it-wrapperless-fence-rule

GitHub release (latest by date) GitHub commits since latest release

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.

Installation

<package manager> add [-D] @olets/markdown-it-wrapperless-fence-rule

Usage

import markdownItWrapperlessFenceRule from '@olets/markdown-it-wrapperless-fence-rule';
import MarkdownIt from 'markdown-it';

const md = MarkdownIt();

md.renderer.rules.fence = markdownItWrapperlessFenceRule;

md.use(/* … */);

Examples

Motivation

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.

Contributing

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.

License

See LICENSE.

About

markdown-it plugin for opting out of wrapping fenced code in <pre><code>

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published