Install
~~~shell
npm install markdow-it-code-tabs
npm install highlight.js
~~~
Use
~~~js
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 '
' +
hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
'
';
} catch (__) {}
}
return '
' + md.utils.escapeHtml(str) + '
';
}
}).use(CodeTabs);
~~~
You must add css style to use
~~~js
import 'markdow-it-code-tabs/style.css';
~~~
MD Example
~~~md
``
js [g1:JavaScript]
console.log("hello");
`
`
py [g1:Python3]
print("hello")
``
~~~