JetBrains / markdown

Markdown parser written in kotlin
Apache License 2.0
682 stars 75 forks source link

[HELP] Highlighted Syntax code blocks #71

Open davidegurgone opened 3 years ago

davidegurgone commented 3 years ago

Hi, thanks for this precious job!

I am trying to integrate this library for formatting code documentation, how did you integrate syntax highlighting? There is an extension for that?

Thanks a lot, Davide.

davidegurgone commented 3 years ago

After some search I finally found the trick: The library renders code in this way:

<pre><code class="language-java">String foo=&quot;BAR&quot;;
for (int i=0; i&lt;10; 1++) {
    System.out.println(foo + i);
}
</code></pre>

language-java is used by PrismJS client side library to syntax highlight the code in the browser.

valich commented 3 years ago

Hi @davidegurgone, thanks for the kind words.

Generated html contains language in class indeed (source), there is no default way to highlight it. IntelliJ IDEA, for example, uses own syntax highlighting engine for highlighting code blocks in preview. I think using PrismJS is a good choice!