title: PHP code to convert text blocks indented by four spaces into a <pre><code> block [Markdown]
body: <p>I'm not very good at PHP and would like to have a PHP function which turns this (text block indented by four spaces):</p>
  
  <pre><code>    printf("goodbye world!");  /* his suicide note
                                    was in C */
  </code></pre>
  
  <p>Into this:</p>
  
  <pre><code>&lt;pre&gt;&lt;code&gt;    printf("goodbye world!");  /* his suicide note
                                was in C */&lt;/code&gt;&lt;/pre&gt;
  </code></pre>
  
  <p>Leaving all other lines intact.</p>
  
  <p>This is what Markdown does. I found <a href="http://code.google.com/p/markdownsharp/source/browse/trunk/MarkdownSharpTests/source/php/markdown.php#1078" rel="nofollow noreferrer">this PHP port of Markdown</a> (see <code>function doCodeBlocks()</code>), but I don't want to use the entire Markdown file, I just want this one function.</p>
  
  <p>Can someone provide me with the minimal PHP code required to get this to work? So I can do this:</p>
  
  <pre><code>&lt;?php echo markdownPre('Here goes some code:
  
      var x = 1, y = 2;
      alert(x + y);
  
  That should be a pre block.'); ?&gt;
  </code></pre>