<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -9,7 +9,7 @@ Reprise - As minimal a hAtom blog as possible
   3. For Ruby version:
        gem install BlueCloth rubypants haml ratom
      For Python version:
-       easy_install markdown smartypants Jinja2 lxml
+       easy_install markdown smartypants Jinja2 lxml Pygments
   4. ./reprise.rb or ./reprise.py
   5. Hook up public/ to a web server like nginx
   6. Rewrite requests from /.+/ to /.+\.html/:</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,11 @@ import shutil
 from os.path import abspath, realpath, dirname, join
 from datetime import datetime, timedelta
 from textwrap import dedent
-from markdown import markdown
+from markdown import Markdown
+from markdown import TextPreprocessor
+from pygments import highlight
+from pygments.formatters import HtmlFormatter
+from pygments.lexers import get_lexer_by_name, TextLexer
 from smartypants import smartyPants
 from jinja2 import DictLoader, Environment
 from lxml.builder import ElementMaker
@@ -42,6 +46,32 @@ CONTEXT = {
     'analytics': '',
 }
 
+class CodeBlockPreprocessor(TextPreprocessor):
+    &quot;&quot;&quot; The Pygments Markdown Preprocessor,
+        copyright 2006-2009 by the Pygments team under BSD license. &quot;&quot;&quot;
+
+    pattern = re.compile(
+        r'\[sourcecode:(.+?)\](.+?)\[/sourcecode\]', re.S)
+
+    formatter = HtmlFormatter(noclasses=False)
+
+    def run(self, lines):
+        def repl(m):
+            try:
+                lexer = get_lexer_by_name(m.group(1))
+            except ValueError:
+                lexer = TextLexer()
+            code = highlight(m.group(2), lexer, self.formatter)
+            code = code.replace('\n\n', '\n&amp;nbsp;\n').replace('\n', '&lt;br /&gt;')
+            return '\n\n&lt;div class=&quot;code&quot;&gt;%s&lt;/div&gt;\n\n' % code
+        return self.pattern.sub(
+            repl, lines)
+
+def markdown(content):
+    md = Markdown()
+    md.textPreprocessors.insert(0, CodeBlockPreprocessor())
+    return md.convert(content)
+
 def read_and_parse_entries():
     files = sorted([join(DIRS['source'], f)
                     for f in os.listdir(DIRS['source'])], reverse=True)
@@ -97,7 +127,8 @@ def generate_404(template):
         write_file(join(DIRS['build'], '404.html'), html)
 
 def generate_style(css):
-    write_file(join(DIRS['build'], 'style.css'), css)
+    css2 = HtmlFormatter(style='trac').get_style_defs()
+    write_file(join(DIRS['build'], 'style.css'), ''.join([css, &quot;\n\n&quot;, css2]))
 
 def generate_atom(entries, feed_url):
     A = ElementMaker(namespace='http://www.w3.org/2005/Atom',
@@ -332,12 +363,13 @@ def get_templates():
       text-indent: 1.1em;
     }
 
-    pre &gt; code {
+    pre {
       border: 0.15em solid #eee;
       border-left: 1em solid #eee;
       display: block;
       font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono',
                    'Lucida Console', monospaced;
+      font-size: .75em;
       padding: 1em 1em 1em 2em;
     }
     &quot;&quot;&quot;,}</diff>
      <filename>reprise.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b3d89a54bf606a1c3a3a9d81dbac4fab2ade4e15</id>
    </parent>
  </parents>
  <author>
    <name>Eivind Uggedal</name>
    <email>eu@redflavor.com</email>
  </author>
  <url>http://github.com/uggedal/reprise/commit/ec9bca2fe34e4e867416b34a3d01263f35c76bb8</url>
  <id>ec9bca2fe34e4e867416b34a3d01263f35c76bb8</id>
  <committed-date>2009-03-14T08:30:26-07:00</committed-date>
  <authored-date>2009-03-14T08:30:26-07:00</authored-date>
  <message>Code highlighting with Pygments.</message>
  <tree>1046048915b8dfb1a9ee38f86e5873e53b62c70a</tree>
  <committer>
    <name>Eivind Uggedal</name>
    <email>eu@redflavor.com</email>
  </committer>
</commit>
