Skip to content

Commit

Permalink
Fix error in lists in Markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
samwilson committed Oct 26, 2020
1 parent 526124f commit ccc2b20
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Markdown.php
Expand Up @@ -34,7 +34,7 @@ public function toHtml(string $in): string
$out = preg_replace("|<p>[-*]{3}</p>|", "<hr />", $out);
// Lists.
$out = preg_replace("|<p>\d\.(.*)|", "<ol>\n#$1", $out); // begin ordered
$out = preg_replace("|\d\.(.*)</p>|", "#$1\n</ol>", $out); // end ordered
$out = preg_replace("|\n\d\.(.*)</p>|", "\n#$1\n</ol>", $out); // end ordered
$out = preg_replace("|<p>\*(.*)|", "<ul>\n*$1", $out); // begin unordered
$out = preg_replace("|\n\*(.*)</p>|", "\n*$1\n</ul>", $out); // end unordered
$out = preg_replace("|\n[*#]\s*(.*)|", "\n<li>$1</li>", $out); // list items
Expand Down
1 change: 1 addition & 0 deletions tests/MarkdownTest.php
Expand Up @@ -30,6 +30,7 @@ public function provideToHtml()
["auf\n\n* *emph* word\n* bar", "<p>auf</p>\n\n<ul>\n<li><em>emph</em> word</li>\n<li>bar</li>\n</ul>"],
["1. foo\n2. bar\n", "<ol>\n<li>foo</li>\n<li>bar</li>\n</ol>"],
["1. foo\n2. bar\n\nbaz", "<ol>\n<li>foo</li>\n<li>bar</li>\n</ol>\n\n<p>baz</p>"],
['Not a list 10.20 just numbers.', '<p>Not a list 10.20 just numbers.</p>'],
// Emphasis and code.
['the *foo* `bar` baz', '<p>the <em>foo</em> <code>bar</code> baz</p>'],
// Blockquotes.
Expand Down

0 comments on commit ccc2b20

Please sign in to comment.