I'm developing a website to publish my codes from different programing languages. I want to highlight syntax of codes with different colors. But, doing it manually is time consuming. Is there any module or method which could do this automatically? Strictly, it should be done in CSS way.
2 Answers
There are several options to highlight code.
From the modules available on d.o. -- GeSHi Filter and Syntax highlighter
A very recent module (yet to make it to Drupal.org) is Wiredcraft's highlight_js on GitHub. They provide a Drupal 7 only version, but (*shameless plug*) I've ported it to Drupal 6 -- https://github.com/ThinkFabrik/highlight_js/tree/6.x-1.0
Edit: depending on the module you may either have to create a new input filter or use Full HTML to get best results
-
I use GeSHi on a couple of my sites. Drupal.org uses drupal.org/project/codefilter (Code Filter), which does a pretty good job with just PHP. Commented Mar 5, 2011 at 18:41
With the code filter module filter you can enclose php code in <?php
and ?>
to highlight it. But this only works for php code. Other code can be enclosed in <code>
tags, but the result is not syntax highlighted.
(edited to reflect Berdir's comment)
-
That's not something that is supported by core, you need one of the modules mentioned in the answer from zerolab– BerdirCommented Mar 4, 2011 at 14:52
-