From ccbdfabaff74f14e3945643b8a06d750686756c2 Mon Sep 17 00:00:00 2001 From: Won-Kyu Park Date: Mon, 17 Feb 2014 23:20:06 +0900 Subject: [PATCH 1/2] support HR and headings as block markups --- Parsedown.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index ebc8097..8f36b8c 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -130,12 +130,12 @@ class Parsedown if ( ! isset($block['closed'])) { - if (strpos($line, $block['start']) !== false) # opening tag + if (stripos($line, $block['start']) !== false) # opening tag { $block['depth']++; } - if (strpos($line, $block['end']) !== false) # closing tag + if (stripos($line, $block['end']) !== false) # closing tag { if ($block['depth'] > 0) { @@ -359,8 +359,15 @@ class Parsedown { $name = $substring; } + $name = strtolower($name); - if ( ! ctype_alpha($name)) + // hr,h1,h2,h3,h4,h5,h6 cases + if ($name[0] == 'h' and strpos('r123456', $name[1]) !== false) + { + if ($name == 'hr') + $is_self_closing = 1; + } + elseif ( ! ctype_alpha($name)) { break; } @@ -392,7 +399,7 @@ class Parsedown 'depth' => 0, ); - if (strpos($outdented_line, $block['end'])) + if (stripos($outdented_line, $block['end'])) { $block['closed'] = true; } From 446fead459b440848de6aa24134c82b8e3e9e65e Mon Sep 17 00:00:00 2001 From: Won-Kyu Park Date: Mon, 17 Feb 2014 23:33:56 +0900 Subject: [PATCH 2/2] simple html cases --- tests/data/html_simple.html | 28 ++++++++++++++++++++++++++ tests/data/html_simple.md | 39 +++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 tests/data/html_simple.html create mode 100644 tests/data/html_simple.md diff --git a/tests/data/html_simple.html b/tests/data/html_simple.html new file mode 100644 index 0000000..61e50b6 --- /dev/null +++ b/tests/data/html_simple.html @@ -0,0 +1,28 @@ +

Headings:

+

Overview

+

blah

+

Block Elements

+

blah

+

+ Span Elements +

+

blah

+

Hr's:

+
+

blah

+
+

blah

+
+

blah

+
+

blah

+
+

blah

+
+

blah

+
+

blah

+
+

blah

+
+

blah

\ No newline at end of file diff --git a/tests/data/html_simple.md b/tests/data/html_simple.md new file mode 100644 index 0000000..7b930df --- /dev/null +++ b/tests/data/html_simple.md @@ -0,0 +1,39 @@ +Headings: + +

Overview

+blah +

Block Elements

+blah +

+ Span Elements +

+blah + +Hr's: + +
+blah + +
+blah + +
+blah + +
+blah + +
+blah + +
+blah + +
+blah + +
+blah + +
+blah