Skip to content

Consider using CodeMirror.runmode for highlighting? #37

Closed
@vincentwoo

Description

@vincentwoo

If you're interested in cutting another dependency, you can use something like:

function highlight(code, lang) {
    var dummy = document.createElement('div');
    CodeMirror.runMode(code, lang, dummy);
    return dummy.innerHTML;
}

to perform highlighting instead of hljs. You do have to include all the relevant modes, though.

This has the added benefit of making sure the preview highlighting is identical to the output highlighting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions