-
Notifications
You must be signed in to change notification settings - Fork 81
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
Syntax highlighting for code snippets. #9
Comments
Thanks, good idea. I'm missing this too... Any recommendation for a good syntax highlighting library (written in Java)? |
Isn't RichTextFX capable of that (since it does for for markdown) ? For the parsing and AST part, ANTLR https://github.com/antlr/antlr4 seems to have the most and detailed ready grammars: https://github.com/antlr/grammars-v4 |
Sure, for displaying 😉 ANTLR seems to be overkill for syntax highlighting... Did a quick search and found:
Another alternative would be to use highlight.js, which is written in JavaScript. For the preview, this would be probably easy because the preview is a WebKit component that natively supports JavaScript. For the editor, I could try to use Java Nashorn... |
There are many JS based highlighters. E.g.
Well, in that case maybe for a first version, having only for the preview would be a good start :) . |
uses Prism v1.6.0 syntax highlighter (https://github.com/PrismJS/prism) downloaded Prism v1.6.0 source code ZIP from https://github.com/PrismJS/prism/releases and simply copied needed files
@aadrian thanks for the link to the 25 JS highlighters. This was really helpful. Tried some of them and decided to use Prism. For the preview only. The code is now in the master branch. Give it a try 😉 I'll keep this issue open for the syntax highlighting in the editor. |
Good choice. Even if https://github.com/PrismJS/prism does not have so many languages supported (yet), the project is active and there's also "plug-in" support for further extensions.
The integration looks very good :) .
Now that it works so nicely for preview, it could be interesting to try to apply it to HTML Source and Markdown AST too, since those are also read only :) ? |
Yes, had this in mind too. Now implemented in master 😉 I've also implemented "range highlighting" in the Markdown AST view, which makes it much easier to find the AST that is at the caret in the editor. Now that we have syntax highlighting in HTML Source view, I think I should also implement it for HTML blocks/inlines in the editor (before releasing a new version)... |
It looks very good :) . |
Syntax highlighting for HTML/XML/SVG/MathML in editor is now implemented in master |
The editor is simply fantastic with syntax highlighting ! It needs however a shorter name that is more SEO friendly :) |
Please add syntax highlighting for the code snippets too, depending on the used language: in the editor but also in the output.
Thank you.
The text was updated successfully, but these errors were encountered: