From b9808f23e0684dfc004b2e49684fd940fe63a775 Mon Sep 17 00:00:00 2001 From: Emanuil <4thmail@gmail.com> Date: Tue, 24 Sep 2013 22:36:24 +0300 Subject: [PATCH] setext underlines should not work on interrupted paragraphs --- Parsedown.php | 4 ++-- tests/data/setext.html | 2 -- tests/data/setext.md | 5 ----- tests/data/setext_header.html | 5 +++++ tests/data/setext_header.md | 12 ++++++++++++ 5 files changed, 19 insertions(+), 9 deletions(-) delete mode 100644 tests/data/setext.html delete mode 100644 tests/data/setext.md create mode 100644 tests/data/setext_header.html create mode 100644 tests/data/setext_header.md diff --git a/Parsedown.php b/Parsedown.php index 308da63..8d6ce06 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -205,7 +205,7 @@ class Parsedown # Setext Header (---) - if ($element['type'] === 'p' and preg_match('/^[-]+[ ]*$/', $line)) + if ($element['type'] === 'p' and ! isset($element['interrupted']) and preg_match('/^[-]+[ ]*$/', $line)) { $element['type'] = 'h.'; $element['level'] = 2; @@ -315,7 +315,7 @@ class Parsedown # Setext Header (===) - if ($element['type'] === 'p' and preg_match('/^[=]+[ ]*$/', $line)) + if ($element['type'] === 'p' and ! isset($element['interrupted']) and preg_match('/^[=]+[ ]*$/', $line)) { $element['type'] = 'h.'; $element['level'] = 1; diff --git a/tests/data/setext.html b/tests/data/setext.html deleted file mode 100644 index 0b00bb3..0000000 --- a/tests/data/setext.html +++ /dev/null @@ -1,2 +0,0 @@ -
not a header
+