Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lost line breaks #610

Merged
merged 2 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Parsedown.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ protected function linesElements(array $lines)
{
if (isset($CurrentBlock))
{
$CurrentBlock['interrupted'] = true;
$CurrentBlock['interrupted'] = (isset($CurrentBlock['interrupted'])
? $CurrentBlock['interrupted'] + 1 : 1
);
}

continue;
Expand Down Expand Up @@ -388,7 +390,7 @@ protected function blockCodeContinue($Line, $Block)
{
if (isset($Block['interrupted']))
{
$Block['element']['element']['text'] .= "\n";
$Block['element']['element']['text'] .= str_repeat("\n", $Block['interrupted']);

unset($Block['interrupted']);
}
Expand Down Expand Up @@ -500,7 +502,7 @@ protected function blockFencedCodeContinue($Line, $Block)

if (isset($Block['interrupted']))
{
$Block['element']['element']['text'] .= "\n";
$Block['element']['element']['text'] .= str_repeat("\n", $Block['interrupted']);

unset($Block['interrupted']);
}
Expand Down
7 changes: 6 additions & 1 deletion test/data/code_block.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@
<hr />
<pre><code>&gt; not a quote
- not a list item
[not a reference]: http://foo.com</code></pre>
[not a reference]: http://foo.com</code></pre>
<hr />
<pre><code>foo


bar</code></pre>
9 changes: 8 additions & 1 deletion test/data/code_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@

> not a quote
- not a list item
[not a reference]: http://foo.com
[not a reference]: http://foo.com

---

foo


bar
6 changes: 5 additions & 1 deletion test/data/fenced_code_block.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
&lt;a href="http://auraphp.com" &gt;Aura Project&lt;/a&gt;</code></pre>
<pre><code>the following isn't quite enough to close
```
still a fenced code block</code></pre>
still a fenced code block</code></pre>
<pre><code>foo


bar</code></pre>
9 changes: 8 additions & 1 deletion test/data/fenced_code_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,11 @@ echo "Hello World";
the following isn't quite enough to close
```
still a fenced code block
````
````

```
foo


bar
```