Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using CodeMirror.runmode for highlighting? #37

Closed
vincentwoo opened this issue Aug 4, 2015 · 2 comments
Closed

Consider using CodeMirror.runmode for highlighting? #37

vincentwoo opened this issue Aug 4, 2015 · 2 comments

Comments

@vincentwoo
Copy link

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.

@jbt
Copy link
Owner

jbt commented Aug 4, 2015

This is definitely something I've considered - having consistent highlighting on both input and output is something I'd very much like to have.

As it happens, though, the way I'm currently thinking of tackling that is to go in completely the opposite direction (sorry) and strip out CodeMirror entirely, and using prism for highlighting in both input and output. Current status is over on #25. Still definitely not final though

@vincentwoo
Copy link
Author

I eagerly await your progress - I'm independently building out some of these features in CM land, and it's going... passably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants