<?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>Huddled Masses &#187; GeSHi</title>
	<atom:link href="http://huddledmasses.org/tag/geshi/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Sat, 28 Jan 2012 21:37:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<cloud domain='huddledmasses.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>PowerShell Highlighting for GeSHi</title>
		<link>http://huddledmasses.org/powershell-highlighting-for-geshi/</link>
		<comments>http://huddledmasses.org/powershell-highlighting-for-geshi/#comments</comments>
		<pubDate>Sun, 10 Jun 2007 03:13:56 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[GeSHi]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://HuddledMasses.org/jaykul/powershell-highlighting-for-geshi/</guid>
		<description><![CDATA[A while back I switched to GeSHi for source code highlighting in my posts, and recently I started writing PowerShell scripts in my posts, and calmly sticking it in &#60;code lang=&#8220;posh&#8221;&#62; tags, half expecting it to just work, like all the other languages &#8230; but of course it didn&#8217;t. So after a few searches on [...]]]></description>
			<content:encoded><![CDATA[	<p>A while back I switched to GeSHi for source code highlighting in my posts, and recently I started writing PowerShell scripts in my posts, and calmly sticking it in &lt;code lang=&#8220;posh&#8221;&gt; tags, half expecting it to just work, like all the other languages &#8230; but of course it didn&#8217;t.  So after a few searches on Google and Ask, I concluded that a PowerShell syntax file doesn&#8217;t yet exist.  So, <a href="http://huddledmasses.org/wordpress/wp-content/plugins/source.php?file=geshi/geshi/posh.php">I made one</a>, feel free to grab it (it&#8217;s <span class="caps">GPL</span>, and I&#8217;ve <em>even left intact the &#8220;any later version&#8221;</em> clause from GeSHi&#8217;s license).</p>

	<p><strong>EDIT: 6/10/2007</strong><br />
I should mention that the way I do highlighting doesn&#8217;t care about &#8220;Nouns&#8221; at all: it just uses a list of Verbs, and matches anything that starts with a &#8220;Verb-&#8221; ... that means that for the sake of the highlighting, you can&#8217;t just say &#8220;Content&#8221; for Get-Content or (even though that actually works in a script).  Also, I changed the version I was using so that it uses regular expression patters for command parameters, instead of a list.  Because you can abbreviate parameters to the shortest distinguishable form, a list doesn&#8217;t really work.</p>

	<p>Let&#8217;s just see in action, shall we? <span id="more-419"></span></p>

	<div class="posh code posh" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Get-Sql.ps1</span><br />
<span style="color: #666666; font-style: italic;">###################################################################################################</span><br />
<span style="color: #666666; font-style: italic;"># NOTICE that I have set default values for the server and database, but not for the query</span><br />
<span style="color: #666666; font-style: italic;"># ALSO NOTICE that I'm not handling authentication (I just use Integrated Security)</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; By default when you run this script it:</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; * creates the functions </span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; * initializes the connection</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; But we don't automatically do a query -- unless you pass one in!</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; Thus, calling the script with no parameters results in an initialized connection, </span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; but it doesn't return anything, so it's basically silent if there are no errors.</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<br />
<span style="color: #666666; font-style: italic;"># the default server and database</span><br />
<span style="color: #666699; font-weight: bold;">param</span><span style="color: #333;">&#40;</span> <span style="color: #660033; font-weight: bold;">$Server</span> <span style="color: #66cc66;">=</span> <span style="color: #009900;">&quot;.&quot;</span>, <span style="color: #660033; font-weight: bold;">$Database</span> <span style="color: #66cc66;">=</span> <span style="color: #009900;">&quot;SOMR&quot;</span>, &nbsp;<span style="color: #660033; font-weight: bold;">$Query</span> <span style="color: #333;">&#41;</span><br />
<br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># change the SqlConnection (it's set to a default when the script it run)</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666699; font-weight: bold;">function</span> global:<span style="color: #0066cc; font-style: italic;">Set-<span style="font-style: normal;">SqlConnection</span></span><span style="color: #333;">&#40;</span> <span style="color: #660033; font-weight: bold;">$Server</span> <span style="color: #66cc66;">=</span> $<span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Read-<span style="font-style: normal;">Host</span></span> <span style="color: #009900;">&quot;SQL Server Name&quot;</span><span style="color: #333;">&#41;</span>, <span style="color: #660033; font-weight: bold;">$Database</span> <span style="color: #66cc66;">=</span> $<span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Read-<span style="font-style: normal;">Host</span></span> <span style="color: #009900;">&quot;Default Database&quot;</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; <span style="color: #660033; font-weight: bold;">$SqlConnection</span>.<span style="color: #003366;">ConnectionString</span> <span style="color: #66cc66;">=</span> <span style="color: #009900;">&quot;Server = $Server; Database = $Database; Integrated Security = True&quot;</span><br />
<span style="color: #333;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># A function to allow the user to </span><br />
<span style="color: #666666; font-style: italic;"># perform a query that returns a table full of data</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666699; font-weight: bold;">function</span> global:<span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">SqlDataTable</span></span><span style="color: #333;">&#40;</span> <span style="color: #660033; font-weight: bold;">$Query</span> <span style="color: #66cc66;">=</span> $<span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Read-<span style="font-style: normal;">Host</span></span> <span style="color: #009900;">&quot;Enter SQL Query&quot;</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
<br />
&nbsp; <span style="color: #660033; font-weight: bold;">$SqlCmd</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">New-<span style="font-style: normal;">Object</span></span> System.<span style="color: #666699; font-weight: bold;">Data</span>.<span style="color: #003366;">SqlClient</span>.<span style="color: #003366;">SqlCommand</span><br />
&nbsp; <span style="color: #660033; font-weight: bold;">$SqlCmd</span>.<span style="color: #003366;">CommandText</span> <span style="color: #66cc66;">=</span> <span style="color: #660033; font-weight: bold;">$Query</span><br />
&nbsp; <span style="color: #660033; font-weight: bold;">$SqlCmd</span>.<span style="color: #003366;">Connection</span> <span style="color: #66cc66;">=</span> <span style="color: #660033; font-weight: bold;">$SqlConnection</span><br />
<br />
&nbsp; <span style="color: #660033; font-weight: bold;">$SqlAdapter</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">New-<span style="font-style: normal;">Object</span></span> System.<span style="color: #666699; font-weight: bold;">Data</span>.<span style="color: #003366;">SqlClient</span>.<span style="color: #003366;">SqlDataAdapter</span><br />
&nbsp; <span style="color: #660033; font-weight: bold;">$SqlAdapter</span>.<span style="color: #003366;">SelectCommand</span> <span style="color: #66cc66;">=</span> <span style="color: #660033; font-weight: bold;">$SqlCmd</span><br />
<br />
&nbsp; <span style="color: #660033; font-weight: bold;">$DataSet</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">New-<span style="font-style: normal;">Object</span></span> System.<span style="color: #666699; font-weight: bold;">Data</span>.<span style="color: #003366;">DataSet</span><br />
&nbsp; <span style="color: #660033; font-weight: bold;">$SqlAdapter</span>.<span style="color: #003366;">Fill</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$DataSet</span><span style="color: #333;">&#41;</span><br />
<br />
&nbsp; <span style="color: #660033; font-weight: bold;">$SqlConnection</span>.<span style="color: #003366;">Close</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #666699; font-weight: bold;">return</span> <span style="color: #660033; font-weight: bold;">$DataSet</span>.<span style="color: #003366;">Tables</span><span style="color: #333;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #333;">&#93;</span><br />
<span style="color: #333;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Initialize the SqlConnection variable</span><br />
<span style="color: #0066cc; font-style: italic;">Set-<span style="font-style: normal;">Variable</span></span> SqlConnection <span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">New-<span style="font-style: normal;">Object</span></span> System.<span style="color: #666699; font-weight: bold;">Data</span>.<span style="color: #003366;">SqlClient</span>.<span style="color: #003366;">SqlConnection</span><span style="color: #333;">&#41;</span> <span style="color: #000066;">-Scope</span> Global <span style="color: #000066;">-Option</span> AllScope <span style="color: #000066;">-Desc</span> <span style="color: #009900;">&quot;Personal variable for Sql Query functions&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Initially create the SqlConnection</span><br />
<span style="color: #0066cc; font-style: italic;">Set-<span style="font-style: normal;">SqlConnection</span></span> <span style="color: #660033; font-weight: bold;">$Server</span> <span style="color: #660033; font-weight: bold;">$Database</span><br />
<br />
<span style="color: #666666; font-style: italic;"># go ahead and run the initial query if we have one...</span><br />
<span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span> <span style="color: #660033; font-weight: bold;">$query</span> <span style="color: #000066;">-gt</span> <span style="color: #660033; font-weight: bold;">$null</span> <span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; <span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">SqlDataTable</span></span> <span style="color: #660033; font-weight: bold;">$Query</span><br />
<span style="color: #333;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Some aliases to let you use the functions with less typing</span><br />
<span style="color: #0066cc; font-style: italic;">Set-<span style="font-style: normal;">Alias</span></span> gsdt <span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">SqlDataTable</span></span> <span style="color: #000066;">-Option</span> AllScope <span style="color: #000066;">-Description</span> <span style="color: #009900;">&quot;Personal Function alias from Get-Sql.ps1&quot;</span><br />
<span style="color: #0066cc; font-style: italic;">Set-<span style="font-style: normal;">Alias</span></span> ssc <span style="color: #0066cc; font-style: italic;">Set-<span style="font-style: normal;">SqlConnection</span></span> <span style="color: #000066;">-Option</span> AllScope <span style="color: #000066;">-Description</span> <span style="color: #009900;">&quot;Personal Function alias from Get-Sql.ps1&quot;</span><br />
&nbsp;</div>

	<p>Now if only I could get it working that well in SciTE!</p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/powershell-highlighting-for-geshi/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TextileWrapper 2.0 and GeSHiWrapper 1.4</title>
		<link>http://huddledmasses.org/textilewrapper-20-and-geshiwrapper-14/</link>
		<comments>http://huddledmasses.org/textilewrapper-20-and-geshiwrapper-14/#comments</comments>
		<pubDate>Wed, 16 Aug 2006 15:01:40 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[GeSHi]]></category>
		<category><![CDATA[Textile]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.huddledmasses.org/jaykul/textilewrapper-20-and-geshiwrapper-14/</guid>
		<description><![CDATA[EDIT I&#8217;m inserting an extra paragraph Just to test if the textile stuff is misbehaving Because I had an error report. I&#8217;m releasing a new version of the WordPress Textile 2 plugin, as well as my own plugin for doing syntax highlighting with GeSHi. But I feel like I need to explain what&#8217;s going on, [...]]]></description>
			<content:encoded><![CDATA[	<p><strong>EDIT</strong> I&#8217;m inserting an extra paragraph<br />
Just to test if the textile stuff is misbehaving<br />
Because I had an error report.</p>

	<p>I&#8217;m releasing a new version of the WordPress Textile 2 plugin, as well as my own plugin for doing syntax highlighting with GeSHi.  But I feel like I need to explain what&#8217;s going on, rather than just posting the downloads.</p>

	<p>There are two big changes to the Textile 2 plugin. I&#8217;ve changed the way I&#8217;m distributing the plugin: instead of a single file, there are two, which must go <strong>together</strong> into a folder in your WordPress plugins directory. To simplify that I&#8217;ve packaged them as a <a href="/wp-content/plugins/TextileWrapper.7z" title="9Kb">.7z</a> <a href="/wp-content/plugins/TextileWrapper.tgz" title="9Kb">.tgz</a> <a href="/wp-content/plugins/TextileWrapper.zip" title="10Kb">.zip</a> which you can just unpack in the plugins folder.  The reason for this change is that this allows me to distribute the <em>unmodified</em> classTextile.php from <a href="http://textism.com/?wp">Dean Allen&#8217;s</a> <a href="http://svn.textpattern.com/releases/4.0.3/source/textpattern/lib/classTextile.php">last textpattern release</a>, and allows <em>you</em> the option of just replacing that file with <a href="http://svn.textpattern.com/development/4.0/textpattern/lib/classTextile.php">the latest from the svn repository</a> in the future.</p>

	<p>I&#8217;ve changed the name to &#8220;TextileWrapper&#8221; to be more in line with what&#8217;s really going on. I want to make perfectly clear that I <em>am not</em> editing Textile at all this time.  Any bugs with the way Textile work are Textile&#8217;s bugs, and should be filed via the <a href="http://www.textism.com/tools/textile/">Textile Homepage</a>.  Any bugs with the way it integrates into WordPress should be filed here.  As far as the version number &#8230; Dean Allen has left Textile as &#8220;2.0 Beta&#8221; for a very long time, despite the fact that he&#8217;s on version 4.3 of <a href="http://www.textpattern.com">Textpattern</a> (which has been using Textile since the beggining).  The internal revision number for the file has been divorced from actual revisions to Textile, because <a href="http://subversion.tigris.org/">Subversion</a> revision&#8217;s the whole project, so there&#8217;s nothing to go on there, either. At any rate, based on all that, I&#8217;ve decided to just call this version 2.8 as it&#8217;s really the next version of my &#8220;Textile 2&#8221; plugin, even though I&#8217;ve renamed it &#8230;  and it really should work with any version of Textile since the first 2.0 Beta.</p>

	<p>I finally came to my senses with this release and realized that the problem with code blocks is really not a Textile problem, but rather, a problem of the various syntax highlighters I&#8217;ve been using.</p>

	<p><span id="more-326"></span>After playing around with some regular expressions, I&#8217;m releasing my GeSHiWrapper plugin as well. It&#8217;s exactly the same concept as TextileWrapper: a simple wrapper around an untouched <a href="http://qbnz.com/highlighter/">GeSHi &#8211; Generic Syntax Highlighter</a> which should allow you to upgrade GeSHi without waiting for me to release new wrappers. As with Textile, I&#8217;ve packaged the whole thing with the current GeSHi: <a href="/wp-content/plugins/GeSHiWrapper.7z" title="213Kb">.7z</a> <a href="/wp-content/plugins/GeSHiWrapper.tgz" title="306Kb">.tgz</a> <a href="/wp-content/plugins/GeSHiWrapper.zip" title="384Kb">.zip</a> which you can just unpack in the plugins folder.</p>

	<p>The GeSHi wrapper is a little more complicated than the TextileWrapper, because it&#8217;s intended purpose is to do code highlighting in a way that works with the various markup plugins (Textile, Markdown, etc) without any problems. To accomplish this, it runs two functions: one before, and one after the actual markup plugin runs (this assumes that you have the priority of the markup plugin set between 2 and 9 &#8212; it&#8217;s usually 6).  The basic idea is that before the markup plugin runs it <strong>extracts</strong> the code blocks, and afterwards, it syntax-highlights them and puts them back.  There are two catches.</p>

	<p>The first problem is a GeSHi problem: it throws out the &#8220;code&#8221; blocks and replaces them with &#8220;div&#8220;s.  This means you can&#8217;t use it to syntax highlight code in-line in a paragraph, because it will invalidate your markup &#8230; but it doesn&#8217;t track that.  What it <strong>does</strong> do, is only replace code blocks with a &#8220;lang&#8221; or &#8220;language&#8221; attribute (which tells it which language the code is in &#8212; that is: php or csharp, not english).  To get GeSHi wrapper to work, you should put your <code>code</code> tags in their own paragraph (GeSHiWrapper will rip off an extra set of <code>p</code> tags), and you must specify the *lang*uage for the source code.  If you use Textile&#8217;s markup to add code tags that <strong>will not</strong> be highlighted, since GeSHi looks for code before Textile runs. </p>

	<p>The second problem is a style problem: since GeSHi puts it&#8217;s code in a <code>&#60;div class=&#34;code lang&#34;&#62;</code> block, you need to make sure you style that div appropriately (particularly note the problem of long source-code lines like regular expressions which may not have spaces, and thus, won&#8217;t wrap properly in Firefox).  Personally, I style the .code class with overflow: auto; to get scrollbars.</p>

	<p>The only GeSHi option that&#8217;s currently exposed in the wrapper (apart from the code language) is line numbering.  If you want line numbering on, you should specify an attribute &#8220;line&#8221; with a numerical value for the number of the first line (note that the first line of code is on the same line as the <code>code</code> tag).  This allows you to quote from the middle of a file and still use the line numbers logically like so: <code>&#60;code lang=&#34;csharp&#34; line=&#34;104&#34;&#62;</code></p>

	<p>Eventuall I&#8217;ll release a new version of this wrapper with a config page for some of the options &#8230; particularly the choice of <code>div</code> or <code>pre</code> and of using  stylesheets and class names instead of embedded styles, but I have a lot of other work to get done first, so if you&#8217;re interested in syntax highlighting that won&#8217;t break with your Markup plugin, don&#8217;t wait for that.</p>

	<p>P.S.:  To show that it&#8217;s all working, I messed around with my <a href="http://www.huddledmasses.org/jaykul/test-post-please-look-away/">most recent test post</a> and added a bunch of highlighted code and a few of the usual Textile torture tests.</p>

	<p>Technorati Tags: <a href="http://technorati.com/tag/WordPress" rel="tag">WordPress</a>, <a href="http://technorati.com/tag/Plugins" rel="tag">Plugins</a>, <a href="http://technorati.com/tag/Textile" rel="tag">Textile</a>, <a href="http://technorati.com/tag/GeSHi" rel="tag">GeSHi</a>, <a href="http://technorati.com/tag/SyntaxHighlight" rel="tag">SyntaxHighlight</a>, <a href="http://technorati.com/tag/Code" rel="tag">Code</a>, <a href="http://technorati.com/tag/Web" rel="tag">Web</a>, <a href="http://technorati.com/tag/Blogging" rel="tag">Blogging</a>, <a href="http://technorati.com/tag/Markup" rel="tag">Markup</a></p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/textilewrapper-20-and-geshiwrapper-14/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

