3

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 2

9

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

1
1

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)

2
  • That's not something that is supported by core, you need one of the modules mentioned in the answer from zerolab
    – Berdir
    Commented Mar 4, 2011 at 14:52
  • You are right. Updating answer... Commented Mar 4, 2011 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.