pre block-level tag shouldn't be surrounded by a p tag
jpfle - March 28, 2009 - 19:57
| Project: | Markdown filter |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
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>
#1
We 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.
#2
Hi 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:
Voici le code:
<div>
<pre>
$a = 5;
$b = 6;
$c = 7;
</pre>
</div>
Nous y voyons les valeurs des variables.
but there's always a bug with
prewithout other block-level tags.#3
I 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.