From 913e04782f970bb8ff1fa1441aa127dfa2155867 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 25 Mar 2018 22:50:16 +0100 Subject: [PATCH 1/2] Add failing test cases to be fixed --- test/data/setext_header_spaces.html | 12 ++++++++++++ test/data/setext_header_spaces.md | 29 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 test/data/setext_header_spaces.html create mode 100644 test/data/setext_header_spaces.md diff --git a/test/data/setext_header_spaces.html b/test/data/setext_header_spaces.html new file mode 100644 index 0000000..daf97c0 --- /dev/null +++ b/test/data/setext_header_spaces.html @@ -0,0 +1,12 @@ +

trailing space

+

trailing space

+

leading and trailing space

+

leading and trailing space

+

1 leading space

+

1 leading space

+

3 leading spaces

+

3 leading spaces

+

too many leading spaces +==

+

too many leading spaces +--

\ No newline at end of file diff --git a/test/data/setext_header_spaces.md b/test/data/setext_header_spaces.md new file mode 100644 index 0000000..4ac35bb --- /dev/null +++ b/test/data/setext_header_spaces.md @@ -0,0 +1,29 @@ +trailing space +== + +trailing space +-- + +leading and trailing space + == + +leading and trailing space + -- + +1 leading space + == + +1 leading space + -- + +3 leading spaces + == + +3 leading spaces + -- + +too many leading spaces + == + +too many leading spaces + -- \ No newline at end of file From f71bec00f4053854ebaf2b842724e35aec6cd5b6 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 25 Mar 2018 22:50:42 +0100 Subject: [PATCH 2/2] Fix space handling in setext headings --- Parsedown.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index bf08700..844a504 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -705,8 +705,10 @@ class Parsedown return; } - if (chop($Line['text'], $Line['text'][0]) === '') - { + if ( + chop(chop($Line['text'], ' '), $Line['text'][0]) === '' + and $Line['indent'] < 4 + ) { $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2'; return $Block;