title: Invalid XML entity references from Jekyll
body: <p>I'm using <a href="http://jekyllrb.com" rel="nofollow">Jekyll</a> on <a href="http://pages.github.com" rel="nofollow">GitHub Pages</a> to run <a href="http://blog.ploeh.dk" rel="nofollow">my blog</a>.</p>
  
  <p>It seems as though Jekyll (semi-)randomly incorrectly XML escapes an XML special character as <code>&amp;tt;</code>.</p>
  
  <p>As an example, in the current version of <a href="http://blog.ploeh.dk/rss.xml" rel="nofollow">the RSS feed</a>, this source XML</p>
  
  <pre><code>&lt;/p&gt;
  &lt;p&gt;
  </code></pre>
  
  <p>in <em>a single place</em> becomes</p>
  
  <pre><code>&amp;lt;/p&amp;gt;
  &amp;lt;p&amp;tt;
  </code></pre>
  
  <p>but it should have been</p>
  
  <pre><code>&amp;lt;/p&amp;gt;
  &amp;lt;p&amp;gt;
  </code></pre>
  
  <p><code>&amp;tt;</code> is an invalid XML entity reference, so some XML parsers choke on that and refuse to go on.</p>
  
  <p>At first I suspected an invisible, invalid character at that place in the source, but as far as I can tell, this isn't the case. What's more is that this behaviour doesn't seem to be consistent:</p>
  
  <p>The RSS feed currently has 7 such errors, of which the above is the first. However, the current <a href="http://blog.ploeh.dk/atom.xml" rel="nofollow">Atom feed</a> has only 5 such errors, and <em>they are not in the same places</em>. It's not only <code>&lt;p&gt;</code> tags that are affected, but other tags as well (e.g. <code>&lt;ul&gt;</code> tags should always be escaped as <code>&amp;lt;ul&amp;gt;</code>, but is in a single place instead escaped as <code>&amp;tt;ul&amp;gt;</code>).</p>
  
  <p>Furthermore, when I run</p>
  
  <blockquote>
    <p>jekyll serve -w</p>
  </blockquote>
  
  <p>on my local machine, I still see the same <em>type</em> of error, but not in the same places.</p>
  
  <p>The HTML is XML escaped like this:</p>
  
  <pre><code>{{ post.content | xml_escape }}
  </code></pre>
  
  <p>Why does this happen, and what can I do about it?</p>