<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog of ducklink.com &#187; format</title>
	<atom:link href="http://libg.org/tag/format/feed/" rel="self" type="application/rss+xml" />
	<link>http://libg.org</link>
	<description></description>
	<lastBuildDate>Tue, 18 Jan 2011 04:54:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Show Formatted Source Code with Syntax Highlight</title>
		<link>http://libg.org/2008/09/14/show-formatted-source-code-with-syntax-highlight/</link>
		<comments>http://libg.org/2008/09/14/show-formatted-source-code-with-syntax-highlight/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 07:56:18 +0000</pubDate>
		<dc:creator>Mason</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[highlight]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://libg.org/2008/09/14/show-formatted-source-code-with-syntax-highlight/</guid>
		<description><![CDATA[LibG Code Viewer is a free web tool to view source code with syntax highlight. After I finished my post How to format source code in your blog, I decided to make a small tool for anyone who post source code file on Internet. I called this tool &#8220;LibG Code Viewer&#8220;, it used the method [...]]]></description>
			<content:encoded><![CDATA[<p><strong>LibG Code Viewer</strong> is a free web tool to view source code with syntax highlight.</p>
<p>After I finished my post <a title="Permanent Link to How to format source code in your blog" href="http://libg.org/2008/09/11/how-to-format-source-code-in-your-blog/">How to format source code in your blog</a>, I decided to make a small tool for anyone who post source code file on Internet. I called this tool &#8220;<strong><a href="http://libg.org/code.php" target="_blank">LibG Code Viewer</a></strong>&#8220;, it used the method I described in my previous blog. Here is the usage of this tool:</p>
<table border="1" cellspacing="0" cellpadding="2" width="535">
<tbody>
<tr>
<td width="533" valign="top"><span style="color: #000080;">http://libg.org/code.php?lang=<em>your source language</em>&amp;url=<em>link to your source code</em></span></td>
</tr>
</tbody>
</table>
<p>Below is the list of supported language and sample:</p>
<table border="1" cellspacing="0" cellpadding="2" width="535">
<tbody>
<tr>
<td width="80" valign="top"><strong>Language</strong></td>
<td width="86" valign="top"><strong>Parameter</strong></td>
<td width="367" valign="top"><strong>Sample</strong></td>
</tr>
<tr>
<td width="85" valign="top"><strong>C++</strong></td>
<td width="90" valign="top">cpp</td>
<td width="367" valign="top"><a title="http://libg.org/code.php?lang=cpp&amp;url=http://libg.googlecode.com/svn/trunk/inc/gifloat.h" href="http://libg.org/code.php?lang=cpp&amp;url=http://libg.org/code/sample.cpp">http://libg.org/code.php?lang=<span style="color: #000080;">cpp</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.cpp</span></a></td>
</tr>
<tr>
<td width="88" valign="top"><strong>C#</strong></td>
<td width="93" valign="top">csharp</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=csharp&amp;url=http://libg.org/code/sample.cs " target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">csharp</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.cs</span></a></span></td>
</tr>
<tr>
<td width="91" valign="top"><strong>CSS</strong></td>
<td width="95" valign="top">css</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=css&amp;url=http://libg.org/code/sample.css" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">css</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.css</span></a></span></td>
</tr>
<tr>
<td width="93" valign="top"><strong>Delphi</strong></td>
<td width="96" valign="top">delphi</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=delphi&amp;url=http://libg.org/code/sample.pas" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">delphi</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.pas</span></a></span></td>
</tr>
<tr>
<td width="94" valign="top"><strong>Java</strong></td>
<td width="97" valign="top">java</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=java&amp;url=http://libg.org/code/sample.java" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">java</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.java</span></a></span></td>
</tr>
<tr>
<td width="95" valign="top"><strong>Java Script</strong></td>
<td width="97" valign="top">js</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=js&amp;url=http://libg.org/code/sample.js" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">js</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.js</span></a></span></td>
</tr>
<tr>
<td width="96" valign="top"><strong>PHP</strong></td>
<td width="97" valign="top">php</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=php&amp;url=http://libg.org/code/sample.phpcode">http://libg.org/code.php?lang=<span style="color: #000080;">php</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.phpcode</span></a></span></td>
</tr>
<tr>
<td width="97" valign="top"><strong>Python</strong></td>
<td width="97" valign="top">py</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=py&amp;url=http://libg.org/code/sample.py" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">py</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.py</span></a></span></td>
</tr>
<tr>
<td width="97" valign="top"><strong>Ruby</strong></td>
<td width="97" valign="top">ruby</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=ruby&amp;url=http://libg.org/code/sample.rb" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">ruby</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.rb</span></a></span></td>
</tr>
<tr>
<td width="97" valign="top"><strong>Sql</strong></td>
<td width="97" valign="top">sql</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=sql&amp;url=http://libg.org/code/sample.sql" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">sql</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.sql</span></a></span></td>
</tr>
<tr>
<td width="97" valign="top"><strong>VB</strong></td>
<td width="97" valign="top">vb</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=vb&amp;url=http://libg.org/code/sample.vb" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">vb</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.vb</span></a></span></td>
</tr>
<tr>
<td width="97" valign="top"><strong>XML/HTML</strong></td>
<td width="97" valign="top">xml</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=xml&amp;url=http://libg.org/code/sample.xml" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">xml</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.xml</span></a></span></td>
</tr>
</tbody>
</table>
<p>You can use the form below to test LibG Code Viewer:</p>
<form action="http://libg.org/code.php" target="_blank" enctype="application/x-www-form-urlencoded" method="get">
<table border="1" cellspacing="0" cellpadding="2" width="537">
<tbody>
<tr>
<td width="146" valign="top">Language:</td>
<td width="377" valign="top">
<select name="lang">
<option selected="selected" value="cpp">C++</option>
<option value="csharp">C#</option>
<option value="css">CSS</option>
<option value="delphi">Delphi</option>
<option value="java">Java</option>
<option value="js">Java Script</option>
<option value="php">PHP</option>
<option value="py">Python</option>
<option value="ruby">Ruby</option>
<option value="sql">SQL</option>
<option value="vb">Visual Basic</option>
<option value="xml">XML/HTML</option>
</select>
</td>
</tr>
<tr>
<td width="146" valign="top">Source Code Link:</td>
<td width="377" valign="top">
<input id="url" name="url" size="50" type="text" /></td>
</tr>
<tr>
<td colspan="2" valign="top" align="center">
<div>
<input name="Submit" size="20" type="submit" value="Submit" /></div>
</td>
</tr>
</tbody>
</table>
</form>
]]></content:encoded>
			<wfw:commentRss>http://libg.org/2008/09/14/show-formatted-source-code-with-syntax-highlight/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to format source code in your blog</title>
		<link>http://libg.org/2008/09/11/how-to-format-source-code-in-your-blog/</link>
		<comments>http://libg.org/2008/09/11/how-to-format-source-code-in-your-blog/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 11:59:00 +0000</pubDate>
		<dc:creator>Mason</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://libg.org/2008/09/11/how-to-format-source-code-in-your-blog/</guid>
		<description><![CDATA[When I was writing my post Include Guard: #pragma once vs. #ifndef #define #endif, I searched from Internet and tried at least 5 WordPress plug-in to insert formatted source code. But none of them works well for me. Some can not support C++ source code, some insert complicated html code to my post. Finally I [...]]]></description>
			<content:encoded><![CDATA[<p>When I was writing my post <a href="http://libg.org/2008/09/06/include-guard-pragma-once-vs-ifdef-define-endif/" target="_blank"><em>Include Guard: #pragma once vs. #ifndef #define #endif</em></a>, I searched from Internet and tried at least 5 WordPress plug-in to insert formatted source code. But none of them works well for me. Some can not support C++ source code, some insert complicated html code to my post. Finally I found <a href="http://code.google.com/p/syntaxhighlighter/" target="_blank">syntax highlighting</a> is simply and easy to prettify my code. There is WordPress plug-in <a href="http://wordpress.org/extend/plugins/google-syntax-highlighter/" target="_blank">Google Syntax Highlighter for WordPress</a>, and convenient for WordPress users to integrate to your WordPress blog site. The plug-in author may be wrong here, because the true Google Code highlight tool is <a href="http://code.google.com/p/google-code-prettify/" target="_blank">Google Code Prettify</a>.</p>
<p>SyntaxHighlighter is a pure JavaScript based tool and can parse a lot of programming languages:</p>
<ul>
<li>C++ (cpp, c, c++) </li>
<li>C# (c#, c-sharp, csharp) </li>
<li>CSS (css) </li>
<li>Delphi (delphi, pascal) </li>
<li>Java (java) </li>
<li>Java Script (js, jscript, javascript) </li>
<li>PHP (php) </li>
<li>Python (py, python) </li>
<li>Ruby (rb, ruby, rails, ror) </li>
<li>Sql (sql) </li>
<li>VB (vb, vb.net) </li>
<li>XML/HTML (xml, html, xhtml, xslt) </li>
</ul>
<p>To learn format your source code use this tool, please refer to the usage from <a href="http://code.google.com/p/syntaxhighlighter/wiki/Usage" target="_blank">http://code.google.com/p/syntaxhighlighter/wiki/Usage</a>. This post demonstrated the result of SyntaxHighlighter so you can make a quick decision. I used the code from Microsoft MSDN <a title="http://msdn.microsoft.com/en-us/library/w5c4hyx3(VS.80).aspx" href="http://msdn.microsoft.com/en-us/library/w5c4hyx3(VS.80).aspx" target="_blank">http://msdn.microsoft.com/en-us/library/w5c4hyx3(VS.80).aspx</a> as the sample code for testing.</p>
<p><strong>1. Default usage:</strong></p>
<p>&lt;pre name=&quot;code&quot; class=&quot;cpp&quot;&gt; &#8230; code here &#8230; &lt;/pre&gt;</p>
<p><u>Result:</u></p>
<pre class="cpp" name="code">// Exhibits polymorphism/virtual functions.

#include <iostream>
#include <string>
#define TRUE = 1
using namespace std;

class dog
{
public:
	// Source Code Omitted...

private:
   string _dogSize, _earType;
   int _legs;
   bool _bark;

};

class breed : public dog
{
public:
	/*
	Source Code Omitted...
	*/
};

int main()
{
   dog mongrel;
   breed labrador(&quot;yellow&quot;, &quot;large&quot;);
   mongrel.setEars(&quot;pointy&quot;);
   labrador.setEars(&quot;long&quot;, &quot;floppy&quot;);
   cout &lt;&lt; &quot;Cody is a &quot; &lt;&lt; labrador.getColor() &lt;&lt; &quot; labrador&quot; &lt;&lt; endl;
}</pre>
<p><strong>2. Display no gutter:</strong></p>
<p>&lt;pre name=&quot;code&quot; class=&quot;cpp:<font color="#ff0000">nogutter</font>&quot;&gt; &#8230; code here &#8230; &lt;/pre&gt;</p>
<p><u>Result:</u></p>
<pre class="cpp:nogutter" name="code">// Exhibits polymorphism/virtual functions.

#include <iostream>
#include <string>
#define TRUE = 1
using namespace std;

class dog
{
public:
	// Source Code Omitted...

private:
   string _dogSize, _earType;
   int _legs;
   bool _bark;

};

class breed : public dog
{
public:
	/*
	Source Code Omitted...
	*/
};

int main()
{
   dog mongrel;
   breed labrador(&quot;yellow&quot;, &quot;large&quot;);
   mongrel.setEars(&quot;pointy&quot;);
   labrador.setEars(&quot;long&quot;, &quot;floppy&quot;);
   cout &lt;&lt; &quot;Cody is a &quot; &lt;&lt; labrador.getColor() &lt;&lt; &quot; labrador&quot; &lt;&lt; endl;
}</pre>
<p><strong>3. Display no controls at the top</strong></p>
<p>&lt;pre name=&quot;code&quot; class=&quot;cpp:<font color="#ff0000">nocontrols</font>&quot;&gt; &#8230; code here &#8230; &lt;/pre&gt;</p>
<p><u>Result</u></p>
<pre class="cpp:nocontrols" name="code">// Exhibits polymorphism/virtual functions.

#include <iostream>
#include <string>
#define TRUE = 1
using namespace std;

class dog
{
public:
	// Source Code Omitted...

private:
   string _dogSize, _earType;
   int _legs;
   bool _bark;

};

class breed : public dog
{
public:
	/*
	Source Code Omitted...
	*/
};

int main()
{
   dog mongrel;
   breed labrador(&quot;yellow&quot;, &quot;large&quot;);
   mongrel.setEars(&quot;pointy&quot;);
   labrador.setEars(&quot;long&quot;, &quot;floppy&quot;);
   cout &lt;&lt; &quot;Cody is a &quot; &lt;&lt; labrador.getColor() &lt;&lt; &quot; labrador&quot; &lt;&lt; endl;
}</pre>
<p><strong>4. Collapse the block by default</strong></p>
<p>&lt;pre name=&quot;code&quot; class=&quot;cpp:<font color="#ff0000">collapse</font>&quot;&gt; &#8230; code here &#8230; &lt;/pre&gt;</p>
<p><u>Result</u></p>
<pre class="cpp:collapse" name="code">// Exhibits polymorphism/virtual functions.

#include <iostream>
#include <string>
#define TRUE = 1
using namespace std;

class dog
{
public:
	// Source Code Omitted...

private:
   string _dogSize, _earType;
   int _legs;
   bool _bark;

};

class breed : public dog
{
public:
	/*
	Source Code Omitted...
	*/
};

int main()
{
   dog mongrel;
   breed labrador(&quot;yellow&quot;, &quot;large&quot;);
   mongrel.setEars(&quot;pointy&quot;);
   labrador.setEars(&quot;long&quot;, &quot;floppy&quot;);
   cout &lt;&lt; &quot;Cody is a &quot; &lt;&lt; labrador.getColor() &lt;&lt; &quot; labrador&quot; &lt;&lt; endl;
}</pre>
<p><strong>5. Begin line count at <tt>value</tt>. Default value is 1</strong></p>
<p>&lt;pre name=&quot;code&quot; class=&quot;cpp:<font color="#ff0000">firstline[123]</font>&quot;&gt; &#8230; code here &#8230; &lt;/pre&gt;</p>
<p><u>Result</u></p>
<pre class="cpp:firstline[123]" name="code">// Exhibits polymorphism/virtual functions.

#include <iostream>
#include <string>
#define TRUE = 1
using namespace std;

class dog
{
public:
	// Source Code Omitted...

private:
   string _dogSize, _earType;
   int _legs;
   bool _bark;

};

class breed : public dog
{
public:
	/*
	Source Code Omitted...
	*/
};

int main()
{
   dog mongrel;
   breed labrador(&quot;yellow&quot;, &quot;large&quot;);
   mongrel.setEars(&quot;pointy&quot;);
   labrador.setEars(&quot;long&quot;, &quot;floppy&quot;);
   cout &lt;&lt; &quot;Cody is a &quot; &lt;&lt; labrador.getColor() &lt;&lt; &quot; labrador&quot; &lt;&lt; endl;
}</pre>
<p><strong>6. Show row columns in the first line. </strong></p>
<p>&lt;pre name=&quot;code&quot; class=&quot;cpp:<font color="#ff0000">showcolumns</font>&quot;&gt; &#8230; code here &#8230; &lt;/pre&gt;</p>
<p><u>Result</u></p>
<pre class="cpp:showcolumns" name="code">// Exhibits polymorphism/virtual functions.

#include <iostream>
#include <string>
#define TRUE = 1
using namespace std;

class dog
{
public:
	// Source Code Omitted...

private:
   string _dogSize, _earType;
   int _legs;
   bool _bark;

};

class breed : public dog
{
public:
	/*
	Source Code Omitted...
	*/
};

int main()
{
   dog mongrel;
   breed labrador(&quot;yellow&quot;, &quot;large&quot;);
   mongrel.setEars(&quot;pointy&quot;);
   labrador.setEars(&quot;long&quot;, &quot;floppy&quot;);
   cout &lt;&lt; &quot;Cody is a &quot; &lt;&lt; labrador.getColor() &lt;&lt; &quot; labrador&quot; &lt;&lt; endl;
}</pre>
<p><u></u></p>
<p>If you are using WordPress plug-in, please be sure to remove redundant JavaScript files in your plug-in source code and speed up the page loading. Go to WordPress dashboard, Plugins -&gt; Plugin Editor, select &quot;Google Syntax Highlighter for WordPress&quot;, go to the bottom of the source code, I removed the similar lines to the line below and kept this line to highlight CPP code:</p>
<p>&lt;script class=&quot;javascript&quot; src=&quot;&lt;?php echo $current_path; ?&gt;Scripts/<font color="#ff0000"><strong>shBrushCpp</strong></font>.js&quot;&gt;&lt;/script&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://libg.org/2008/09/11/how-to-format-source-code-in-your-blog/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

