Currently Viewing Posts Tagged highlight

Highlight source code in the post

There is a great highlight tool written by javascript.

syntaxhighlighter is a Google code project.

Update: Just found it is a new version for Syntaxhighlighter. It is a little bit different than the old one which I mentioned here. Please find the right way to use it.
It is easy to use and looks perfect.

The following are some examples.

1) PHP script

// Pull the array data from the lang pack//
$j = 0;
$counter = 0;
$counter_2 = 0;
$faq_block = array();
$faq_block_titles = array();
for($i = 0; $i < count($faq); $i++)
{
if( $faq[$i][0] != '--' )
{$faq_block[$j][$counter]['id'] = $counter_2;
$faq_block[$j][$counter]['question'] = $faq[$i][0];
$faq_block[$j][$counter]['answer'] = $faq[$i][1];
$counter++;<br />$counter_2++;<br />}
else{$j = ( $counter != 0 ) ? $j + 1 : 0;
$faq_block_titles[$j] = $faq[$i][1];
$counter = 0;
}
}

2) CSS script

.tag1{
font-size: xx-large;
color: #6588c7;}
.tag2{
font-size: x-large;
color: #5578a7;}
.tag3{
font-size: large;
color: #4568a7;}

This code project covers C++ C# CSS Delphi Java Java Script PHP python Ruby Sql VB XML/HTML.

Let’s discuss how to use it in MovableType.

Continue reading “Highlight source code in the post”

  • Archives