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 @@ -

line

-

line

\ No newline at end of file diff --git a/tests/data/setext.md b/tests/data/setext.md deleted file mode 100644 index 959ea3e..0000000 --- a/tests/data/setext.md +++ /dev/null @@ -1,5 +0,0 @@ -line -- - -line ----- \ No newline at end of file diff --git a/tests/data/setext_header.html b/tests/data/setext_header.html new file mode 100644 index 0000000..41f2b04 --- /dev/null +++ b/tests/data/setext_header.html @@ -0,0 +1,5 @@ +

h1

+

h2

+

single character

+

not a header

+
\ No newline at end of file diff --git a/tests/data/setext_header.md b/tests/data/setext_header.md new file mode 100644 index 0000000..49e03e0 --- /dev/null +++ b/tests/data/setext_header.md @@ -0,0 +1,12 @@ +h1 +== + +h2 +-- + +single character +- + +not a header + +------------ \ No newline at end of file