From a8b5a611e9663f63ea232572abaa213c7712d418 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 3 Apr 2007 19:31:17 +0000 Subject: [PATCH] Added support for horizontal rules in Markdown --- Markdown.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Markdown.php b/Markdown.php index 0526275..1a02235 100644 --- a/Markdown.php +++ b/Markdown.php @@ -112,6 +112,7 @@ class BSMarkdown $this->_convertHardLineBreaks(); $this->_convertAtxHeaders(); $this->_convertSetextHeaders(); + $this->_convertHorizontalRules(); $this->_formatParagraphs(); $this->text = $this->_expandHtmlBlocks($this->text); @@ -229,6 +230,22 @@ class BSMarkdown return $hash; } + // ################################################################### + /** + * Converts three stars or dashes (optionally separated by spaces) into + * a horizontal rule. + */ + private function _convertHorizontalRules() + { + $hash = md5('
' . microtime()); + $count = 0; + $this->text = preg_replace('/((-|\*) ?){3,}/', $hash, $this->text, -1, $count); + if ($count > 0) + { + $this->htmlBlockMap[$hash] = '
'; + } + } + // ################################################################### /** * Wraps blocks into paragraphs -- 2.22.5