markdown-it-v-codemirror-highlighter

1.0.0 • Public • Published

markdown⁠-⁠it⁠-⁠v⁠-⁠codemirror⁠-⁠highlighter

A code highlighter for markdown⁠-⁠it⁠-⁠v using CodeMirror

Installation

$ npm i markdown-it-v-codemirror-highlighter --save

Or yarn:

$ yarn add markdown-it-v-codemirror-highlighter

Usage

For Node.js:

const MarkdownIt    = require('markdown-it')
const MarkdownItV   = require('markdown-it-v')
const MarkdownItVHL = require('markdown-it-v-codemirror-highlighter')
require('codemirror/mode/clike/clike')    // import language

const md = MarkdownIt()
  .use(MarkdownItV)
  .use(MarkdownItVHL)

let sdom = md.render('```C++' +
`
#include <iostream>
int main() {
  std::cout << "Hello World!";
  return 0;
}
` +
'```')

For browser (using es6 module with web bundler):

import MarkdownIt    from 'markdown-it'
import MarkdownItV   from 'markdown-it-v'
// import the entry point for browser
import MarkdownItVHL from 'markdown-it-v-codemirror-highlighter/dist/browserIndex.common.js'
import 'codemirror/mode/clike/clike'      // import language
import 'codemirror/theme/mdn-like.css'    // import theme css

const md = MarkdownIt()
  .use(MarkdownItV)
  .use(MarkdownItVHL, {
    theme: 'mdn-like'                     // specify theme
  })

let sdom = md.render(textarea.value)      // get markdown document from <textarea>

Package Sidebar

Install

npm i markdown-it-v-codemirror-highlighter

Weekly Downloads

10

Version

1.0.0

License

MIT

Unpacked Size

8.81 kB

Total Files

8

Last publish

Collaborators

  • tttnns