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>
CommentFileSizeAuthor
#3 markdown_php.patch2.19 KBmelon

Comments

gábor hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)

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.

Jean-Philippe Fleury’s picture

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 pre without other block-level tags.

melon’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new2.19 KB

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.

eagereyes’s picture

I 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)?

beeradb’s picture

Status: Active » Fixed

looks like this went in at http://drupal.org/cvs?commit=360882

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.