Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top