js syntax highlighting for markdown (not for codeblocks in markdown)

Tobias Bengfort tobias.bengfort at posteo.de
Thu Apr 23 04:21:12 EDT 2015


Hi,

I am currently searching for a js library that will highlight markdown
code. The trouble is that search engines only show me solutions for
integrating markdown parsers with highlighting tools in order to
highlight code blocks in the generated HTML. But that is not what I
want. I want to write an in-browser markdown editor that has syntax
highlighting for the markdown code itself.

TL;DR: Does anyone know such a library?

I have tried [highlight.js][1]. It has markdown support but
unfortunately that is not really good. For example it can not find
nested rules like this:

    >   This is **bad**.

And it does only look at single lines. So in the following example, all
but the first line are interpreted as a code blocks.

    -   My main point here is probably that blabla blablabla
        blablabla bla bla blabla bla blablabla bla blabla
        bla blablabla bla bla blabla bla blablabla bla.

        Thanks for your attention.

It would be great if that library had optional features like fenced code
blocks and intra-word emphasis. It would also be cool if it could spot
errors (e.g. unbalanced emphasis like `**asd*`).

Maybe it would be best if it was part of a markdown parser library
because they could share some code and would have the same dialect
(which is useful if you want syntax highlighting *and* a preview).

I could probably write such a library myself, but I would prefer to use
an existing one.

For anyone interested in the editor idea: I know there are many markdown
editors already. My favorite one is currently
http://lab.lepture.com/editor/. My project is mainly for my personal
entertainment and education. But I hope that the result will fill a gap.

tobias


[1]: https://highlightjs.org/



More information about the Markdown-Discuss mailing list