Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are good jQuery plugins to highlight code and XML content? [closed]

I have a couple of web-pages where I write out some code c#, and some XML. I'd like to find a way to highlight the syntax of the different content to make it easier to read - very much like here on Stackoverflow?

I already use a bit of jQuery so something that plugs into that would be a nice fit.

like image 269
Riri Avatar asked Mar 06 '10 09:03

Riri


People also ask

What is PrismJS?

Syntax Highlighting with PrismJS Prism is a lightweight, extensible syntax highlighter that can be used when working with code blocks in markdown files in blog posts.

Why jQuery is awesome?

jQuery is a lightweight, “write less, do more”, JavaScript library. The purpose of jQuery is to make it much easier to use JavaScript on your website. jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish and wraps them into methods that you can call with a single line of code.

What is the use of highlight JS?

Highlight. js tries to automatically detect the language of a code fragment. The heuristics is essentially simple: it tries to highlight a fragment with all the language definitions and the one that yields most specific modes and keywords wins.


2 Answers

You might want to look into Alex Gorbatchev's SyntaxHighlighter. It's one of the nicest formatters out there, and supports tons of syntaxes if you ever decide to format code in a new language.

like image 33
Max Shawabkeh Avatar answered Sep 26 '22 16:09

Max Shawabkeh


Hm, I don't see where jQuery fits in there too well (because it is for DOM modification, not based on the textual content of the DOM).

Still, you might want to take a look at the very cool google-code-prettify. As far as I know, it is also used here at StackOverflow and it works like a charm for many languages. I use it myself and it's really easy to integrate.

like image 108
mnemosyn Avatar answered Sep 25 '22 16:09

mnemosyn