markdown-it-code-webcomponents

1.0.1 • Public • Published

markdown-it-code-webcomponents

中文指南

markdown-it plugin. Support the componentization of block code, inline code and fenced code. Make it more convenient to work with web frameworks like Vue to parse later.

Install

npm i markdown-it-code-webcomponents

API

const md = require('markdown-it')()
  .use(require('markdown-it-code-webcomponents'), { tag: 'my-code' });
  • tag: Tag name for componentization

Text following:

`code here`

    code there
```js
code everywhere
```
```
hello world!
```

Will be converted to:

<p><my-code inline="">code here</my-code></p>
<my-code>code there
</my-code>
<my-code lang="js">code everywhere
</my-code>
<my-code>hello world!
</my-code>

Example

const md = require('markdown-it')()
  .use(require('markdown-it-code-webcomponents'), { tag: 'my-code' });

console.dir(md.render('`code here`\n\n    code there\n```js\ncode everywhere\n```\n```\nhello world!\n```'));

/* output

<p><my-code inline="">code here</my-code></p>
<my-code>code there
</my-code>
<my-code lang="js">code everywhere
</my-code>
<my-code>hello world!
</my-code>

*/

More examples can be found in test.js.

License

MIT

Copyright (c) 2020, lookas

Package Sidebar

Install

npm i markdown-it-code-webcomponents

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

6.94 kB

Total Files

6

Last publish

Collaborators

  • lookas