how to show code snippet in drupal post or page

Wanted to show code snippet in drupal website then you can use following modules for achieve this functionality.

I tried to display php code and html tag in a tutorial.

how to show code snippet in drupal post or page

First simple option is,

Use the tag to post the php code or html code and display in the post
as I have done below


There are nice modules which are useful for showing the code sample in post.

Code Filter
This module provides a simple text format (input filter) that handles and tags so that users can post code without having to worry about manually escaping < and > characters with < and >

Syntax highlighter
This module integrates the SyntaxHighlighter Javascript Library into Drupal for source code list syntax highlighting within any Drupal contents.

GeSHi Filter for syntax highlighting
The GeShi Filter module provides a filter for source code syntax highlighting for a wide range of languages.

Source code can be entered with for example ... or…. Starting from version 5.x-2.0 it is also possible to define your own generic and language specific tags (e.g.) or to work with square bracket style tags (e.g.

). Automatically adding line numbers is possible too with for example

Add a Comment

Your email address will not be published. Required fields are marked *