<?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>Syntactic Whitespace &#187; code</title>
	<atom:link href="http://www.mikedonaghy.org/tag/code/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mikedonaghy.org</link>
	<description>Because semi-colons are for noobs</description>
	<lastBuildDate>Mon, 31 May 2010 17:22:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Syntax Highlighting in Django</title>
		<link>http://www.mikedonaghy.org/post/syntax-highlighting-in-django</link>
		<comments>http://www.mikedonaghy.org/post/syntax-highlighting-in-django#comments</comments>
		<pubDate>Tue, 11 Sep 2007 23:02:12 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[pastebin]]></category>
		<category><![CDATA[python_web]]></category>
		<category><![CDATA[syntax_highlighting]]></category>

		<guid isPermaLink="false">http://mikedonaghy.org/posts/syntax-highlighting-in-django</guid>
		<description><![CDATA[I am currently working on a project with Django A Python web framework , It will be a pastebin application , all good pastebins have syntax highlighting &#8230; I just wanted to show you how I did it &#8230; it can be useful for other projects, 1 def syntax(value,extension): 2 from pygments.lexers import get_lexer_for_filename 3 [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently working on a project with <a href="http://djangoproject.com">Django</a> A <a href="http://python.org">Python</a> web framework ,<br />
It will be a pastebin application , all good pastebins  have syntax highlighting &#8230; I just wanted to show you how I did it &#8230; it can be useful for other projects,</p>
<pre>
<font color="#ffff00">1 </font><font color="#ff6600">def</font> <font color="#ffcc00">syntax</font>(value,extension):
<font color="#ffff00">2 </font>    <font color="#ff80ff">from</font> pygments.lexers <font color="#ff80ff">import</font> get_lexer_for_filename
<font color="#ffff00">3 </font>    <font color="#ff80ff">from</font> pygments <font color="#ff80ff">import</font> highlight
<font color="#ffff00">4 </font>    <font color="#ff80ff">from</font> pygments.formatters <font color="#ff80ff">import</font> HtmlFormatter
<font color="#ffff00">5 </font>    <span style="background-color: #000000"><font color="#ffffff">"</font></span><font color="#66ff00">Highlights the syntax of a file based on file extension</font><span style="background-color: #000000"><font color="#ffffff">"</font></span>
<font color="#ffff00">6 </font>    lexer = get_lexer_for_filename(<span style="background-color: #000000"><font color="#ffffff">"</font></span><font color="#66ff00">file.</font><span style="background-color: #000000"><font color="#ffffff">"</font></span> + extension, stripall=True)
<font color="#ffff00">7 </font>    formatter = HtmlFormatter(linenos=True)
<font color="#ffff00">8 </font>    result = highlight(value, lexer, formatter)
<font color="#ffff00">9 </font>    <font color="#ff6600">return</font> result</pre>
<p>Sorry for the lack of posts , I will have more snippets up soon</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikedonaghy.org/post/syntax-highlighting-in-django/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
