Sunday, 2 October 2011

Add syntax highlighter in drupal

<?php 
if(ereg("^[0-9]{2}-[0-9]{10}$", $phone_number)) {
      echo "valid phone number";
}
else {
       echo "invalid phone number";
}
?>

To activate syntax highlighter in your drupal site to follow the below steps

1. Download syntax highlighter module to following link http://drupal.org/project/syntaxhighlighter
    and extract to sites/all/modules directories

2. The module required following Syntax highlighter javascript library
     download and  extract sites/all/libraries directories

3. Now enable Syntax highlighter module

4. Enable the Syntaxhighlighter filter in an input format Site configuration > Input formats > Configure




5. Go to admin/settings/syntaxhighlighter to configure syntaxhighlighter module


6. If u need to highlight code to use following pre tag

<pre class="brush: js; highlight: [1, 5]; html-script: true">
     your javascript and html code here
</pre>

<pre class="brush: php; highlight: [1, 5]; html-script: true">
      your php and html code here
</pre>

 highlight: [1, 5] is used to highlight the code lines 1 and 5


0 comments:

Post a Comment