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
http://drupal.org/project/codefilter
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
http://drupal.org/project/syntaxhighlighter
This module integrates the SyntaxHighlighter Javascript Library into Drupal for source code list syntax highlighting within any Drupal contents.
—————————————-

GeSHi Filter for syntax highlighting
http://drupal.org/project/geshifilter
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

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.