<?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>Niels' Homepage &#187; Code plugin</title>
	<atom:link href="http://www.heirbaut.nl/category/projects/code-plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.heirbaut.nl</link>
	<description>Everything I want to put on the web</description>
	<lastBuildDate>Thu, 08 Apr 2010 18:49:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>NanoBlogger plug-ins</title>
		<link>http://www.heirbaut.nl/2006/07/02/nanoblogger-plug-ins/</link>
		<comments>http://www.heirbaut.nl/2006/07/02/nanoblogger-plug-ins/#comments</comments>
		<pubDate>Sun, 02 Jul 2006 14:38:59 +0000</pubDate>
		<dc:creator>Niels</dc:creator>
				<category><![CDATA[Code plugin]]></category>
		<category><![CDATA[Gallery plugin]]></category>

		<guid isPermaLink="false">http://www.heirbaut.nl/?p=51</guid>
		<description><![CDATA[New releases of the code and gallery plug-ins for NanoBlogger. The code plug-in now no longer causes two blank line to be sent to stdout. The gallery plug-in now handles different versions of NanoBlogger better, i.e. the version check to determine which version of NanoBlogger is running does not cause an error anymore. It also [...]]]></description>
			<content:encoded><![CDATA[<p> 	New releases of the <a href="http://www.heirbaut.nl/category/projects/code-plugin/">code</a> and <a href="http://www.heirbaut.nl/category/projects/gallery-plugin/">gallery</a> plug-ins for NanoBlogger. The code plug-in now no longer causes two blank line to be sent to stdout. The gallery plug-in now handles different versions of NanoBlogger better, i.e. the version check to determine which version of NanoBlogger is running does not cause an error anymore. It also delays the cleanup of meta files on Apple Mac OS X so I hope this is handles better now.</p>
<ul>
<li>The new gallery plug-in can be downloaded <a href="http://www.heirbaut.nl/downloads/gallery/gallery-0.4.0.tar.gz">here</a>.</li>
<li>The new code plug-in can be downloaded <a href="http://www.heirbaut.nl/downloads/nbcode/nbcode-0.2.0.tar.gz">here</a>.</li>
</ul>
<p>Enjoy and if there are any questions or problems contact me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heirbaut.nl/2006/07/02/nanoblogger-plug-ins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The first release of the Code Formatting Plugin &#8211; Version 0.1.0</title>
		<link>http://www.heirbaut.nl/2006/01/12/the-first-release-of-the-code-formatting-plugin-version-010/</link>
		<comments>http://www.heirbaut.nl/2006/01/12/the-first-release-of-the-code-formatting-plugin-version-010/#comments</comments>
		<pubDate>Thu, 12 Jan 2006 18:32:12 +0000</pubDate>
		<dc:creator>Niels</dc:creator>
				<category><![CDATA[Code plugin]]></category>

		<guid isPermaLink="false">http://www.heirbaut.nl/?p=30</guid>
		<description><![CDATA[As mentioned in a previous blog, a plugin to format code snippets in NanoBlogger entries has been in the making. It seems that a first workable version can be downloaded here. How does it work In short: just start a line before the code snippet with &#8216;CODE(&#60;language&#62;){&#8216; and start a line with &#8216;}CODE&#8216; after the [...]]]></description>
			<content:encoded><![CDATA[<p> 	As mentioned in a <a href="http://www.heirbaut.nl/2006/01/07/progress/">previous</a> blog, a plugin to format code snippets in NanoBlogger entries has been in the making. It seems that a first workable version can be downloaded <a href="http://www.heirbaut.nl/downloads/nbcode/nbcode-0.1.0.tar.gz">here</a>.</p>
<p><strong>How does it work</strong><br />
In short: just <em>start</em> a line before the code snippet with &#8216;<code>CODE(&lt;language&gt;){</code>&#8216; and <em>start</em> a line with &#8216;<code>}CODE</code>&#8216; after the code snippet. No other characters may appear on this line. Example:</p>
<pre><code>CODE(c){
#include &lt;stdio.h&gt;

int main( int argc, char* argv[] )
{
    (void)printf( "Hello, World!n" );

    return 0;
}
}CODE
</code></pre>
<p>This results in the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">include <span style="color: #339933;">&lt;</span>stdio.<span style="color: #202020;">h</span><span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span> <span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span><span style="color: #339933;">*</span> argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;Hello, World!n&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Here are some other examples:</p>
<p><strong>C#:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Hello
<span style="color: #000000;">&#123;</span>
    <span style="color: #FF0000;">class</span> World
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span> <span style="color: #666666;">&quot;Hello, World!&quot;</span> <span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><strong>Bourne Shell/BASH:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Hello, World!&quot;</span></pre></td></tr></table></div>

<p>The real XHTML generation is done by <a href="http://www.vim.org">ViM</a>, so be sure that that is installed on the PC you use for NanoBlogger. Since XHTML is basically XML where you are expected to do the formatting in a stylesheet, you can add the following to your stylesheet if the code needs to have a black background:</p>
<pre><code>.nbcode { line-height: 120%; }
.nbcode .Comment { color: #00ffff; font-weight: bold; }
.nbcode .Constant { color: #ff40ff; font-weight: bold; }
.nbcode .Error { color: #ffffff; background-color: #ff6060; font-weight: bold; }
.nbcode .Identifier { color: #00ffff; font-weight: bold; }
.nbcode .PreProc { color: #8080ff; font-weight: bold; }
.nbcode .Special { color: #ff6060; font-weight: bold; }
.nbcode .Statement { color: #ffff00; font-weight: bold; }
.nbcode .Title { color: #ff40ff; font-weight: bold; }
.nbcode .Todo { color: #808080; background-color: #ffff00; }
.nbcode .Type { color: #00ff00; font-weight: bold; }
.nbcode .lnr { color: #ffff00; font-weight: bold; }
.nbcode body { color: #ffffff; background-color: #000000; }
.nbcode pre { color: #ffffff; background-color: #000000; }
</code></pre>
<p>Or the following if a white background is preferred:</p>
<pre><code>.nbcode { line-height: 120%; }
.nbcode .Comment { color: #8080ff; }
.nbcode .Constant { color: #ff6060; }
.nbcode .Error { color: #ffffff; background-color: #ff6060; font-weight: bold; }
.nbcode .Identifier { color: #00ffff; }
.nbcode .PreProc { color: #ff40ff; }
.nbcode .Special { color: #ff40ff; }
.nbcode .Statement { color: #ffff00; }
.nbcode .Title { color: #ff40ff; }
.nbcode .Todo { color: #808080; background-color: #ffff00; }
.nbcode .Type { color: #00ff00; }
.nbcode .lnr { color: #ffff00; }
.nbcode body { color: #000000; background-color: #ffffff; }
.nbcode pre { color: #000000; background-color: #ffffff; }
</code></pre>
<p><strong>Installation:</strong><br />
Depending on the version of NanoBlogger used place the plugin <code>code.sh</code> in one of the following directories:</p>
<ul>
<li>plugins/entry/mod  (&gt;=3.2)</li>
<li>plugins/entry/body (3.1)</li>
<li>plugins/entry      (&gt;=2.8 &amp;&amp; &lt;3.1)</li>
</ul>
<p>The plugin combines nicely with for example Markdown, as long as the plugin is called on the entry body before the Markdown plugin. Since <code>code.sh</code> comes before <code>markdown.sh</code> alphabetically this should not be a problem.</p>
<p>If you do not want NanoBlogger to call <code>code.sh</code> for every entry, the plugin can alternatively be placed in <code>plugins/entry/format</code>. If the code formatting plugin capabilities are needed just add <code>code</code> to the <code>FORMAT:</code> meta tag in the entry. As mentioned above, be sure to put it before any other format setting like <code>markdown</code>.</p>
<p>From <code>blog.conf</code>, <code>nb.conf</code> or using environment variables, the following variables can be set to influence the behavior of the plugin:</p>
<ul>
<li><em><code>NBCODE_VIM</code></em><br />
Where ViM can be found. Defaults to <code>vim</code>.</li>
<li><em><code>NBCODE_TABSTOP</code></em><br />
Number of spaces a tab counts for. Defaults to 4.</li>
<li><em><code>NBCODE_SHIFTWIDTH</code></em><br />
Number of spaces for each indent. Defaults to 4.</li>
<li><em><code>NBCODE_EXPANDTAB</code></em><br />
Replace tabs with spaces (yes/no). Defaults to <code>yes</code>.</li>
<li><em><code>NBCODE_NUMBERING</code></em><br />
Add line numbering (yes/no). Defaults to <code>yes</code>.</li>
</ul>
<p>Since this is the first release expect some bugs. Feel free to contact me for comments, questions and suggestions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heirbaut.nl/2006/01/12/the-first-release-of-the-code-formatting-plugin-version-010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
