md-highlight
A library that highlights markdown (+ git flavored markdown). This library grammar/parser is heavily based on marked.
Note that this library is not `yet another markdown to html converter. This library is meant to be used by markdown editors to provide syntax highlighting.
API
.highlight(src, [options])
Highlights src
, adding markup that allows styling.
The result is HTML that contains span
tags wrapping known Markdown
blocks.
To style these tags, check the style.css
file for an example.
Available options:
- block: The block grammar to use, see
lib/grammar/block.js
. - inline: The inline grammar to use, see
lib/grammar/inline.js
;
.unhighlight(src)
Removes the highlight markup from the src
.
How to use
Browser
On the browser, this library is only available in the AMD format.
If you use RequireJS specify them like this:
// ...paths : 'md-highlight': '../bower_components/md-highlight/lib/highlighter'// ...
Note that if you want to support IE8
or lower you will need to install es5-shim and require es5-shim
with your AMD loader before requiring this library.
NodeJS
Simply install it with npm install md-highlight
and use it as you would expect.
Tests
bower install
npm install
npm test
You will need bower to install the library dev dependencies.
License
Released under the MIT License.