Hi,
I'm not very good at PHP and would like to have a PHP function which turns this (text block indented by four spaces):
printf("goodbye world!"); /* his suicide note
was in C */
Into this:
<pre><code> printf("goodbye world!"); /* his suicide note
was in C */</code></pre>
Leaving all other lines intact.
This is what Markdown does. I found this PHP port of Markdown (see function doCodeBlocks()
), but I don't want to use the entire Markdown file, I just want this one function.
Can someone provide me with the minimal PHP code required to get this to work? So I can do this:
<?php echo markdownPre('Here goes some code:
var x = 1, y = 2;
alert(x + y);
That should be a pre block.'); ?>