@rockyshi/markdown-it-code-tabs
v1.0.1
Published
markdow-it-code-tabs
Downloads
5
Maintainers
Readme
Install
npm install markdow-it-code-tabs
npm install highlight.js
Use
import markdownit from 'markdown-it';
import javascript from 'highlight.js/lib/languages/javascript';
import CodeTabs from 'markdow-it-code-tabs';
hljs.registerLanguage('javascript', javascript);
const md = markdownit({
html: true,
linkify: true,
typographer: true,
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return '<pre><code class="hljs">' +
hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
'</code></pre>';
} catch (__) {}
}
return '<pre><code class="hljs">' + md.utils.escapeHtml(str) + '</code></pre>';
}
}).use(CodeTabs);
You must add css style to use
import 'markdow-it-code-tabs/style.css';
MD Example
```js [g1:JavaScript]
console.log("hello");
```
```py [g1:Python3]
print("hello")
```