If we write this:
Voici le code:
<pre>
$a = 5;
$b = 6;
$c = 7;
</pre>
Nous y voyons les valeurs des variables.
Markdown filter adds p tags around pre tag and inside, so presently the module outputs this:
<p>Voici le code:</p>
<p><pre>
$a = 5;</p>
<p>$b = 6;</p>
<p>$c = 7;
</pre></p>
<p>Nous y voyons les valeurs des variables.</p>
but it's a mistake. According to the Markdown documentation:
The only restrictions are that block-level HTML elements — e.g.
<div>, <table>, <pre>, <p>, etc.— must be separated from surrounding content by blank lines, and the start and end tags of the block should not be indented with tabs or spaces. Markdown is smart enough not to add extra (unwanted)tags around HTML block-level tags.
We can also test it here: http://michelf.com/projets/php-markdown/banc-d%27essai/
So the good output should be:
<p>Voici le code:</p>
<pre>
$a = 5;
$b = 6;
$c = 7;
</pre>
<p>Nous y voyons les valeurs des variables.</p>
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | markdown_php.patch | 2.19 KB | melon |
Comments
Comment #1
gábor hojtsyWe are using that markdown library directly. I believe you configured your input format with the built-in Drupal newline filter, and that causes your problems. Please test with that turned off in your input format and respond.
Comment #2
Jean-Philippe Fleury commentedHi Gábor,
No, I don't use the built-in Drupal newline filter. I have no problem with other block-level tags. For example, if I surround my previous code with div, there will be no problem with the output:
but there's always a bug with
prewithout other block-level tags.Comment #3
melon commentedI second that, this is an annyoing bug and happens only with the
<pre>tag. Fortunately this has been fixed in the library, the PHP Markdown Extra v1.2.3 contains this bugfix, and can be downloaded from http://michelf.com/projects/php-markdown/So I assume it's high time to release a new version of this module, please consider it Gábor. Thanks.
I have included a patch to reflect the complete changes in markdown.php for your viewing pleasure.
Comment #4
eagereyes commentedI have the same problem with script tags, but melon's patch doesn't fix that. What can I do to not get those wrapped in p tags (which causes feed validation issues)?
Comment #5
beeradb commentedlooks like this went in at http://drupal.org/cvs?commit=360882