Repository: getpelican/pelican

Issue:
"'dict_keys' object does not support indexing" in Python 3 using sourcecode directive
When I include a code-block with an option, like this:

```
.. sourcecode:: python
   :linenos:

   ...
```

a WARNING appears and the corresponding file is not processed:

```
WARNING: Could not process /home/juanlu/Development/Python/pelican_test/myproject/content/2013-07-14_hello-world.rst
'dict_keys' object does not support indexing
```

The problem is here:

https://github.com/getpelican/pelican/blob/master/pelican/rstdirectives.py#L35

and the solution is detailed here:

http://stackoverflow.com/questions/8953627/python-dictionary-keys-error

I have read the guidelines but, even being a trivial fix:

```
--- rstdirectives.py    2013-07-14 12:41:00.188687997 +0200
+++ rstdirectives.py.new    2013-07-14 12:36:25.982005000 +0200
@@ -32,7 +32,7 @@
             # no lexer found - use the text one instead of an exception
             lexer = TextLexer()
         # take an arbitrary option if more than one is given
-        formatter = self.options and VARIANTS[self.options.keys()[0]] \
+        formatter = self.options and VARIANTS[list(self.options.keys())[0]] \
                     or DEFAULT
         parsed = highlight('\n'.join(self.content), lexer, formatter)
         return [nodes.raw('', parsed, format='html')]
```

I don't have time to add docs, tests, run the test suite and, summing up, doing it properly. Hence the issue without pull request.



Discussion:
Looks good to me. I'll make this a pull-req and do what is required.

Thanks, Russ. You rock!


Resolving patch:
diff --git a/pelican/rstdirectives.py b/pelican/rstdirectives.py
--- a/pelican/rstdirectives.py
+++ b/pelican/rstdirectives.py
@@ -32,7 +32,7 @@ def run(self):
             # no lexer found - use the text one instead of an exception
             lexer = TextLexer()
         # take an arbitrary option if more than one is given
-        formatter = self.options and VARIANTS[self.options.keys()[0]] \
+        formatter = self.options and VARIANTS[list(self.options.keys())[0]] \
                     or DEFAULT
         parsed = highlight('\n'.join(self.content), lexer, formatter)
         return [nodes.raw('', parsed, format='html')]


Test patch:
diff --git a/pelican/tests/output/basic/category/misc.html b/pelican/tests/output/basic/category/misc.html
--- a/pelican/tests/output/basic/category/misc.html
+++ b/pelican/tests/output/basic/category/misc.html
@@ -82,6 +82,12 @@ <h1><a href="/unbelievable.html" rel="bookmark"
 </footer><!-- /.post-info -->                <p>Or completely awesome. Depends the needs.</p>
 <p><a class="reference external" href="/a-markdown-powered-article.html">a root-relative link to markdown-article</a>
 <a class="reference external" href="/a-markdown-powered-article.html">a file-relative link to markdown-article</a></p>
+<div class="section" id="testing-sourcecode-directive">
+<h2>Testing sourcecode directive</h2>
+<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+</td></tr></table><p>Lovely.</p>
+</div>
 
                 <a class="readmore" href="/unbelievable.html">read more</a>
                 </div><!-- /.entry-content -->
diff --git a/pelican/tests/output/basic/feeds/all-en.atom.xml b/pelican/tests/output/basic/feeds/all-en.atom.xml
--- a/pelican/tests/output/basic/feeds/all-en.atom.xml
+++ b/pelican/tests/output/basic/feeds/all-en.atom.xml
@@ -27,5 +27,11 @@ YEAH !&lt;/p&gt;
 </summary><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry><entry><title>Unbelievable !</title><link href="/unbelievable.html" rel="alternate"></link><updated>2010-10-15T20:30:00Z</updated><author><name></name></author><id>tag:,2010-10-15:unbelievable.html</id><summary type="html">&lt;p&gt;Or completely awesome. Depends the needs.&lt;/p&gt;
 &lt;p&gt;&lt;a class="reference external" href="/a-markdown-powered-article.html"&gt;a root-relative link to markdown-article&lt;/a&gt;
 &lt;a class="reference external" href="/a-markdown-powered-article.html"&gt;a file-relative link to markdown-article&lt;/a&gt;&lt;/p&gt;
+&lt;div class="section" id="testing-sourcecode-directive"&gt;
+&lt;h2&gt;Testing sourcecode directive&lt;/h2&gt;
+&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;formatter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;VARIANTS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Lovely.&lt;/p&gt;
+&lt;/div&gt;
 </summary></entry><entry><title>The baz tag</title><link href="/tag/baz.html" rel="alternate"></link><updated>2010-03-14T00:00:00Z</updated><author><name></name></author><id>tag:,2010-03-14:tag/baz.html</id><summary type="html">&lt;p&gt;This article overrides the listening of the articles under the &lt;em&gt;baz&lt;/em&gt; tag.&lt;/p&gt;
 </summary></entry></feed>
\ No newline at end of file
diff --git a/pelican/tests/output/basic/feeds/all.atom.xml b/pelican/tests/output/basic/feeds/all.atom.xml
--- a/pelican/tests/output/basic/feeds/all.atom.xml
+++ b/pelican/tests/output/basic/feeds/all.atom.xml
@@ -28,5 +28,11 @@ YEAH !&lt;/p&gt;
 </summary><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry><entry><title>Unbelievable !</title><link href="/unbelievable.html" rel="alternate"></link><updated>2010-10-15T20:30:00Z</updated><author><name></name></author><id>tag:,2010-10-15:unbelievable.html</id><summary type="html">&lt;p&gt;Or completely awesome. Depends the needs.&lt;/p&gt;
 &lt;p&gt;&lt;a class="reference external" href="/a-markdown-powered-article.html"&gt;a root-relative link to markdown-article&lt;/a&gt;
 &lt;a class="reference external" href="/a-markdown-powered-article.html"&gt;a file-relative link to markdown-article&lt;/a&gt;&lt;/p&gt;
+&lt;div class="section" id="testing-sourcecode-directive"&gt;
+&lt;h2&gt;Testing sourcecode directive&lt;/h2&gt;
+&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;formatter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;VARIANTS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Lovely.&lt;/p&gt;
+&lt;/div&gt;
 </summary></entry><entry><title>The baz tag</title><link href="/tag/baz.html" rel="alternate"></link><updated>2010-03-14T00:00:00Z</updated><author><name></name></author><id>tag:,2010-03-14:tag/baz.html</id><summary type="html">&lt;p&gt;This article overrides the listening of the articles under the &lt;em&gt;baz&lt;/em&gt; tag.&lt;/p&gt;
 </summary></entry></feed>
\ No newline at end of file
diff --git a/pelican/tests/output/basic/feeds/misc.atom.xml b/pelican/tests/output/basic/feeds/misc.atom.xml
--- a/pelican/tests/output/basic/feeds/misc.atom.xml
+++ b/pelican/tests/output/basic/feeds/misc.atom.xml
@@ -4,5 +4,11 @@
 </summary><category term="foo"></category><category term="bar"></category><category term="baz"></category></entry><entry><title>Unbelievable !</title><link href="/unbelievable.html" rel="alternate"></link><updated>2010-10-15T20:30:00Z</updated><author><name></name></author><id>tag:,2010-10-15:unbelievable.html</id><summary type="html">&lt;p&gt;Or completely awesome. Depends the needs.&lt;/p&gt;
 &lt;p&gt;&lt;a class="reference external" href="/a-markdown-powered-article.html"&gt;a root-relative link to markdown-article&lt;/a&gt;
 &lt;a class="reference external" href="/a-markdown-powered-article.html"&gt;a file-relative link to markdown-article&lt;/a&gt;&lt;/p&gt;
+&lt;div class="section" id="testing-sourcecode-directive"&gt;
+&lt;h2&gt;Testing sourcecode directive&lt;/h2&gt;
+&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;formatter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;VARIANTS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Lovely.&lt;/p&gt;
+&lt;/div&gt;
 </summary></entry><entry><title>The baz tag</title><link href="/tag/baz.html" rel="alternate"></link><updated>2010-03-14T00:00:00Z</updated><author><name></name></author><id>tag:,2010-03-14:tag/baz.html</id><summary type="html">&lt;p&gt;This article overrides the listening of the articles under the &lt;em&gt;baz&lt;/em&gt; tag.&lt;/p&gt;
 </summary></entry></feed>
\ No newline at end of file
diff --git a/pelican/tests/output/basic/index.html b/pelican/tests/output/basic/index.html
--- a/pelican/tests/output/basic/index.html
+++ b/pelican/tests/output/basic/index.html
@@ -215,6 +215,12 @@ <h1><a href="/unbelievable.html" rel="bookmark"
 </footer><!-- /.post-info -->                <p>Or completely awesome. Depends the needs.</p>
 <p><a class="reference external" href="/a-markdown-powered-article.html">a root-relative link to markdown-article</a>
 <a class="reference external" href="/a-markdown-powered-article.html">a file-relative link to markdown-article</a></p>
+<div class="section" id="testing-sourcecode-directive">
+<h2>Testing sourcecode directive</h2>
+<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+</td></tr></table><p>Lovely.</p>
+</div>
 
                 <a class="readmore" href="/unbelievable.html">read more</a>
                 </div><!-- /.entry-content -->
diff --git a/pelican/tests/output/basic/unbelievable.html b/pelican/tests/output/basic/unbelievable.html
--- a/pelican/tests/output/basic/unbelievable.html
+++ b/pelican/tests/output/basic/unbelievable.html
@@ -43,6 +43,12 @@ <h1 class="entry-title">
 </footer><!-- /.post-info -->      <p>Or completely awesome. Depends the needs.</p>
 <p><a class="reference external" href="/a-markdown-powered-article.html">a root-relative link to markdown-article</a>
 <a class="reference external" href="/a-markdown-powered-article.html">a file-relative link to markdown-article</a></p>
+<div class="section" id="testing-sourcecode-directive">
+<h2>Testing sourcecode directive</h2>
+<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+</td></tr></table><p>Lovely.</p>
+</div>
 
     </div><!-- /.entry-content -->
 
diff --git a/pelican/tests/output/custom/author/alexis-metaireau3.html b/pelican/tests/output/custom/author/alexis-metaireau3.html
--- a/pelican/tests/output/custom/author/alexis-metaireau3.html
+++ b/pelican/tests/output/custom/author/alexis-metaireau3.html
@@ -51,6 +51,12 @@ <h1><a href="../unbelievable.html" rel="bookmark"
 </footer><!-- /.post-info -->                <p>Or completely awesome. Depends the needs.</p>
 <p><a class="reference external" href="../a-markdown-powered-article.html">a root-relative link to markdown-article</a>
 <a class="reference external" href="../a-markdown-powered-article.html">a file-relative link to markdown-article</a></p>
+<div class="section" id="testing-sourcecode-directive">
+<h2>Testing sourcecode directive</h2>
+<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+</td></tr></table><p>Lovely.</p>
+</div>
 
                 <a class="readmore" href="../unbelievable.html">read more</a>
 <p>There are <a href="../unbelievable.html#disqus_thread">comments</a>.</p>                </div><!-- /.entry-content -->
diff --git a/pelican/tests/output/custom/category/misc.html b/pelican/tests/output/custom/category/misc.html
--- a/pelican/tests/output/custom/category/misc.html
+++ b/pelican/tests/output/custom/category/misc.html
@@ -95,6 +95,12 @@ <h1><a href="../unbelievable.html" rel="bookmark"
 </footer><!-- /.post-info -->                <p>Or completely awesome. Depends the needs.</p>
 <p><a class="reference external" href="../a-markdown-powered-article.html">a root-relative link to markdown-article</a>
 <a class="reference external" href="../a-markdown-powered-article.html">a file-relative link to markdown-article</a></p>
+<div class="section" id="testing-sourcecode-directive">
+<h2>Testing sourcecode directive</h2>
+<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+</td></tr></table><p>Lovely.</p>
+</div>
 
                 <a class="readmore" href="../unbelievable.html">read more</a>
 <p>There are <a href="../unbelievable.html#disqus_thread">comments</a>.</p>                </div><!-- /.entry-content -->
diff --git a/pelican/tests/output/custom/feeds/all-en.atom.xml b/pelican/tests/output/custom/feeds/all-en.atom.xml
--- a/pelican/tests/output/custom/feeds/all-en.atom.xml
+++ b/pelican/tests/output/custom/feeds/all-en.atom.xml
@@ -27,5 +27,11 @@ YEAH !&lt;/p&gt;
 </summary><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry><entry><title>Unbelievable !</title><link href="http://blog.notmyidea.org/unbelievable.html" rel="alternate"></link><updated>2010-10-15T20:30:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-10-15:unbelievable.html</id><summary type="html">&lt;p&gt;Or completely awesome. Depends the needs.&lt;/p&gt;
 &lt;p&gt;&lt;a class="reference external" href="http://blog.notmyidea.org/a-markdown-powered-article.html"&gt;a root-relative link to markdown-article&lt;/a&gt;
 &lt;a class="reference external" href="http://blog.notmyidea.org/a-markdown-powered-article.html"&gt;a file-relative link to markdown-article&lt;/a&gt;&lt;/p&gt;
+&lt;div class="section" id="testing-sourcecode-directive"&gt;
+&lt;h2&gt;Testing sourcecode directive&lt;/h2&gt;
+&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;formatter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;VARIANTS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Lovely.&lt;/p&gt;
+&lt;/div&gt;
 </summary></entry><entry><title>The baz tag</title><link href="http://blog.notmyidea.org/tag/baz.html" rel="alternate"></link><updated>2010-03-14T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-03-14:tag/baz.html</id><summary type="html">&lt;p&gt;This article overrides the listening of the articles under the &lt;em&gt;baz&lt;/em&gt; tag.&lt;/p&gt;
 </summary></entry></feed>
\ No newline at end of file
diff --git a/pelican/tests/output/custom/feeds/all.atom.xml b/pelican/tests/output/custom/feeds/all.atom.xml
--- a/pelican/tests/output/custom/feeds/all.atom.xml
+++ b/pelican/tests/output/custom/feeds/all.atom.xml
@@ -29,5 +29,11 @@ YEAH !&lt;/p&gt;
 </summary><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry><entry><title>Unbelievable !</title><link href="http://blog.notmyidea.org/unbelievable.html" rel="alternate"></link><updated>2010-10-15T20:30:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-10-15:unbelievable.html</id><summary type="html">&lt;p&gt;Or completely awesome. Depends the needs.&lt;/p&gt;
 &lt;p&gt;&lt;a class="reference external" href="http://blog.notmyidea.org/a-markdown-powered-article.html"&gt;a root-relative link to markdown-article&lt;/a&gt;
 &lt;a class="reference external" href="http://blog.notmyidea.org/a-markdown-powered-article.html"&gt;a file-relative link to markdown-article&lt;/a&gt;&lt;/p&gt;
+&lt;div class="section" id="testing-sourcecode-directive"&gt;
+&lt;h2&gt;Testing sourcecode directive&lt;/h2&gt;
+&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;formatter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;VARIANTS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Lovely.&lt;/p&gt;
+&lt;/div&gt;
 </summary></entry><entry><title>The baz tag</title><link href="http://blog.notmyidea.org/tag/baz.html" rel="alternate"></link><updated>2010-03-14T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-03-14:tag/baz.html</id><summary type="html">&lt;p&gt;This article overrides the listening of the articles under the &lt;em&gt;baz&lt;/em&gt; tag.&lt;/p&gt;
 </summary></entry></feed>
\ No newline at end of file
diff --git a/pelican/tests/output/custom/feeds/all.rss.xml b/pelican/tests/output/custom/feeds/all.rss.xml
--- a/pelican/tests/output/custom/feeds/all.rss.xml
+++ b/pelican/tests/output/custom/feeds/all.rss.xml
@@ -29,5 +29,11 @@ YEAH !&lt;/p&gt;
 </description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexis Métaireau</dc:creator><pubDate>Wed, 20 Oct 2010 10:14:00 +0200</pubDate><guid>tag:blog.notmyidea.org,2010-10-20:oh-yeah.html</guid><category>oh</category><category>bar</category><category>yeah</category></item><item><title>Unbelievable !</title><link>http://blog.notmyidea.org/unbelievable.html</link><description>&lt;p&gt;Or completely awesome. Depends the needs.&lt;/p&gt;
 &lt;p&gt;&lt;a class="reference external" href="http://blog.notmyidea.org/a-markdown-powered-article.html"&gt;a root-relative link to markdown-article&lt;/a&gt;
 &lt;a class="reference external" href="http://blog.notmyidea.org/a-markdown-powered-article.html"&gt;a file-relative link to markdown-article&lt;/a&gt;&lt;/p&gt;
+&lt;div class="section" id="testing-sourcecode-directive"&gt;
+&lt;h2&gt;Testing sourcecode directive&lt;/h2&gt;
+&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;formatter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;VARIANTS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Lovely.&lt;/p&gt;
+&lt;/div&gt;
 </description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexis Métaireau</dc:creator><pubDate>Fri, 15 Oct 2010 20:30:00 +0200</pubDate><guid>tag:blog.notmyidea.org,2010-10-15:unbelievable.html</guid></item><item><title>The baz tag</title><link>http://blog.notmyidea.org/tag/baz.html</link><description>&lt;p&gt;This article overrides the listening of the articles under the &lt;em&gt;baz&lt;/em&gt; tag.&lt;/p&gt;
 </description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexis Métaireau</dc:creator><pubDate>Sun, 14 Mar 2010 00:00:00 +0100</pubDate><guid>tag:blog.notmyidea.org,2010-03-14:tag/baz.html</guid></item></channel></rss>
\ No newline at end of file
diff --git a/pelican/tests/output/custom/feeds/misc.atom.xml b/pelican/tests/output/custom/feeds/misc.atom.xml
--- a/pelican/tests/output/custom/feeds/misc.atom.xml
+++ b/pelican/tests/output/custom/feeds/misc.atom.xml
@@ -4,5 +4,11 @@
 </summary><category term="foo"></category><category term="bar"></category><category term="baz"></category></entry><entry><title>Unbelievable !</title><link href="http://blog.notmyidea.org/unbelievable.html" rel="alternate"></link><updated>2010-10-15T20:30:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-10-15:unbelievable.html</id><summary type="html">&lt;p&gt;Or completely awesome. Depends the needs.&lt;/p&gt;
 &lt;p&gt;&lt;a class="reference external" href="http://blog.notmyidea.org/a-markdown-powered-article.html"&gt;a root-relative link to markdown-article&lt;/a&gt;
 &lt;a class="reference external" href="http://blog.notmyidea.org/a-markdown-powered-article.html"&gt;a file-relative link to markdown-article&lt;/a&gt;&lt;/p&gt;
+&lt;div class="section" id="testing-sourcecode-directive"&gt;
+&lt;h2&gt;Testing sourcecode directive&lt;/h2&gt;
+&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;formatter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;VARIANTS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Lovely.&lt;/p&gt;
+&lt;/div&gt;
 </summary></entry><entry><title>The baz tag</title><link href="http://blog.notmyidea.org/tag/baz.html" rel="alternate"></link><updated>2010-03-14T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-03-14:tag/baz.html</id><summary type="html">&lt;p&gt;This article overrides the listening of the articles under the &lt;em&gt;baz&lt;/em&gt; tag.&lt;/p&gt;
 </summary></entry></feed>
\ No newline at end of file
diff --git a/pelican/tests/output/custom/feeds/misc.rss.xml b/pelican/tests/output/custom/feeds/misc.rss.xml
--- a/pelican/tests/output/custom/feeds/misc.rss.xml
+++ b/pelican/tests/output/custom/feeds/misc.rss.xml
@@ -4,5 +4,11 @@
 </description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexis Métaireau</dc:creator><pubDate>Wed, 29 Feb 2012 00:00:00 +0100</pubDate><guid>tag:blog.notmyidea.org,2012-02-29:second-article.html</guid><category>foo</category><category>bar</category><category>baz</category></item><item><title>Unbelievable !</title><link>http://blog.notmyidea.org/unbelievable.html</link><description>&lt;p&gt;Or completely awesome. Depends the needs.&lt;/p&gt;
 &lt;p&gt;&lt;a class="reference external" href="http://blog.notmyidea.org/a-markdown-powered-article.html"&gt;a root-relative link to markdown-article&lt;/a&gt;
 &lt;a class="reference external" href="http://blog.notmyidea.org/a-markdown-powered-article.html"&gt;a file-relative link to markdown-article&lt;/a&gt;&lt;/p&gt;
+&lt;div class="section" id="testing-sourcecode-directive"&gt;
+&lt;h2&gt;Testing sourcecode directive&lt;/h2&gt;
+&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;formatter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;VARIANTS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Lovely.&lt;/p&gt;
+&lt;/div&gt;
 </description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexis Métaireau</dc:creator><pubDate>Fri, 15 Oct 2010 20:30:00 +0200</pubDate><guid>tag:blog.notmyidea.org,2010-10-15:unbelievable.html</guid></item><item><title>The baz tag</title><link>http://blog.notmyidea.org/tag/baz.html</link><description>&lt;p&gt;This article overrides the listening of the articles under the &lt;em&gt;baz&lt;/em&gt; tag.&lt;/p&gt;
 </description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexis Métaireau</dc:creator><pubDate>Sun, 14 Mar 2010 00:00:00 +0100</pubDate><guid>tag:blog.notmyidea.org,2010-03-14:tag/baz.html</guid></item></channel></rss>
\ No newline at end of file
diff --git a/pelican/tests/output/custom/index3.html b/pelican/tests/output/custom/index3.html
--- a/pelican/tests/output/custom/index3.html
+++ b/pelican/tests/output/custom/index3.html
@@ -51,6 +51,12 @@ <h1><a href="./unbelievable.html" rel="bookmark"
 </footer><!-- /.post-info -->                <p>Or completely awesome. Depends the needs.</p>
 <p><a class="reference external" href="./a-markdown-powered-article.html">a root-relative link to markdown-article</a>
 <a class="reference external" href="./a-markdown-powered-article.html">a file-relative link to markdown-article</a></p>
+<div class="section" id="testing-sourcecode-directive">
+<h2>Testing sourcecode directive</h2>
+<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+</td></tr></table><p>Lovely.</p>
+</div>
 
                 <a class="readmore" href="./unbelievable.html">read more</a>
 <p>There are <a href="./unbelievable.html#disqus_thread">comments</a>.</p>                </div><!-- /.entry-content -->
diff --git a/pelican/tests/output/custom/unbelievable.html b/pelican/tests/output/custom/unbelievable.html
--- a/pelican/tests/output/custom/unbelievable.html
+++ b/pelican/tests/output/custom/unbelievable.html
@@ -50,6 +50,12 @@ <h1 class="entry-title">
 </footer><!-- /.post-info -->      <p>Or completely awesome. Depends the needs.</p>
 <p><a class="reference external" href="./a-markdown-powered-article.html">a root-relative link to markdown-article</a>
 <a class="reference external" href="./a-markdown-powered-article.html">a file-relative link to markdown-article</a></p>
+<div class="section" id="testing-sourcecode-directive">
+<h2>Testing sourcecode directive</h2>
+<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+</td></tr></table><p>Lovely.</p>
+</div>
 
     </div><!-- /.entry-content -->
     <div class="comments">