commonmark / commonmark-java

Java library for parsing and rendering CommonMark (Markdown)
BSD 2-Clause "Simplified" License
2.26k stars 287 forks source link

I want to render code how to write (code highlights), I have seen for a long time or no idea. #138

Closed qiudaozhang closed 6 years ago

qiudaozhang commented 6 years ago

Steps to reproduce the problem (provide example input): render the code like java

Expected behavior: hightlights

Actual behavior: no hightlights

noties commented 6 years ago

Hey,

I have a simplified clone of PrismJs for Java: prism4j. It's not sophisticated and doesn't have theming built-in, but it will allow you to tokenize a supported syntax and apply styling to your needs. I use it in my Markwon library (syntax-highlight module) to provide syntax highlighting to Android applications.

PrismJs is RegEx based so do not expect something too precise, but it does help with general highlighting. If you have any questions you can create an issue in the repository and I will try to answer it.

robinst commented 6 years ago

@qiudaozhang I'm not exactly sure what you want. But if it's syntax highlighting, see @noties pointers.

commonmark-java provides the functionality to provide custom rendering of code blocks, so you'd want to use that together with a syntax highlighting library.

Providing syntax highlighting in commonmark-java itself is not in the scope of this project.

qiudaozhang commented 6 years ago

thanks , i use js have resolve it.

molekola-io commented 3 years ago

Hi @qiudaozhang how did you fixed with js? Client side on browser?

AnzhiZhang commented 3 weeks ago

You may have a look for highlight.js or some java libs