From 7249d02cffa0a3d3924b28a0b45569697d5ee299 Mon Sep 17 00:00:00 2001 From: Emanuil Rusev Date: Tue, 5 Nov 2013 10:21:48 +0200 Subject: [PATCH] code blocks get unwanted empty lines --- Parsedown.php | 7 ++++++- tests/data/code_block.html | 15 +++++++-------- tests/data/code_block.md | 25 ++++++++++++------------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index 3366288..c60d565 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -216,7 +216,12 @@ class Parsedown { if ($element['type'] === 'code') { - isset($element['interrupted']) and $element['text'] .= "\n"; + if (isset($element['interrupted'])) + { + $element['text'] .= "\n"; + + unset ($element['interrupted']); + } $element['text'] .= "\n".$matches[1]; } diff --git a/tests/data/code_block.html b/tests/data/code_block.html index 37b7660..8ced802 100644 --- a/tests/data/code_block.html +++ b/tests/data/code_block.html @@ -1,9 +1,8 @@ -

Here's a regular code block:

-
<?php
-
-echo 'Hello World!'; 
-
-?>
-

Here's one that holds a list:

-
- list item
+

Here's a code block:

+
<?php
+
+$message = 'Hello World!'; 
+echo $message;
+

Here's one that holds a list:

+
- list item
 - another list item
\ No newline at end of file diff --git a/tests/data/code_block.md b/tests/data/code_block.md index bfa4904..324b86a 100644 --- a/tests/data/code_block.md +++ b/tests/data/code_block.md @@ -1,13 +1,12 @@ -Here's a regular code block: - - - -Here's one that holds a list: - - - list item - - another list item - +Here's a code block: + +