cm-highlight
Install
This requires codemirror
to be a peer dependency.
yarn add codemirror cm-highlight
Usage
const code = `const foo = () => { console.log('foo')}` const html = //=> <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.
API
highlight(code, [options])
options
mode
Type: string
The mode to use (must be loaded as normal)
tabSize
Type: Number
Default: 2
Replace tab with this amount of spaces.
Todos
- Support line numbers.
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
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