This requires codemirror
to be a peer dependency.
yarn add codemirror cm-highlight
import 'codemirror/mode/javascript/javascript'
import highlight from 'cm-highlight'
const code = `const foo = () => {
console.log('foo')
}`
const html = highlight(code, { mode: 'javascript' })
//=> <span class="cm-keyword">...</span>
Then just place html
into an element like <pre class="cm-s-default"><code>${html}</code></pre>
, you can replace default
with the codemirror theme name you actually use.
Type: string
The mode to use (must be loaded as normal)
Type: Number
Default: 2
Replace tab with this amount of spaces.
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
cm-highlight © egoist, Released under the MIT License. Authored and maintained by egoist with help from contributors (list).
egoistian.com · GitHub @egoist · Twitter @rem_rin_rin