erusev / parsedown-extra

Markdown Extra Extension for Parsedown

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Paragraphs/HTML blocks may disappear in HTML block with markdown="1"

sylbru opened this issue · comments

The Markdown source below works fine in my app in my local installation, but gives a different output in my app using the deployed app: the nested div ("More problematic stuff?") and the following paragraph are not rendered at all.

Same versions used in both instances:

  • parsedown 1.7.4
  • parsedown-extra 0.8.1
  • PHP 7.3.16

It works if I either:

  • wrap the <table> in a <div> (I’ll do that for now, but still would like to understand what’s happening)
  • remove the <table>, or the <div> following it
  • use Parsedown (not Extra) instead, but then markdown="1" is ignored

I tried to test it on https://parsedown.org/extra/ but apparently it makes the website crash…

<div markdown="1">

First paragraph _using Markdown_. 

<table>
<tbody>
<tr>
<td>
Problematic table?
</td>
</tr>
</tbody>
</table>

<div>
More problematic stuff?
</div>

This disappears.

</div>

This is ok.

A similar problems happens with <tags> inside backticks. It also makes the parsedown.org/extra website crash with a 500 response code:

<section markdown="1">
An example `<style>` tag.
</section>

Passing this section through the parse method breaks later content (a tags are not closed properly, for example).

I have the same issue. On my local machine everything works fine. But on the production server the parsing breaks. The local machine and the production server have the same PHP Version.

  • PHP 7.4.8
  • Parsedown 1.8.0-beta-7
  • ParsedownExtra 0.8.0
<div markdown="1">
<ul>
<li>Foo</li>
<li>Bar</li>
</ul>

<ul>
<li>Second Foo</li>
<li>Second Bar</li>
</ul>
</div>

On the production server the second list with Second Foo and Second Bar disappear. On the local machine the second list appears.

<div>
<ul>
<li markdown="1">Foo</li>
<li markdown="1">Bar</li>
</ul>

<ul>
<li markdown="1">Second Foo</li>
<li markdown="1">Second Bar</li>
</ul>
</div>

If only the inner tags have the markdown attributes the second list will be appeared on the production server.

I hope I've found the cause. PR is created #155

DOMDocument trim the new line characters in some PHP environments.