From a9b2d38626a95ccad8e4bbdc9d2cc7325ab7b928 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 11 Oct 2007 02:21:42 +0000 Subject: Horizontal rules in block quotes with tests. Fixes [1709864]. --- markdown.py | 9 +++++++-- tests/misc/blockquote-hr.html | 23 +++++++++++++++++++++++ tests/misc/blockquote-hr.txt | 21 +++++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/misc/blockquote-hr.html create mode 100644 tests/misc/blockquote-hr.txt diff --git a/markdown.py b/markdown.py index f0a2b36..0b7fac0 100644 --- a/markdown.py +++ b/markdown.py @@ -442,10 +442,15 @@ HEADER_PREPROCESSOR = HeaderPreprocessor() class LinePreprocessor (Preprocessor): """Deals with HR lines (needs to be done before processing lists)""" + blockquote_re = re.compile(r'^(> )+') + def run (self, lines) : for i in range(len(lines)) : - if self._isLine(lines[i]) : - lines[i] = self.stash.store("
", safe=True) + prefix = '' + m = self.blockquote_re.search(lines[i]) + if m : prefix = m.group(0) + if self._isLine(lines[i][len(prefix):]) : + lines[i] = prefix + self.stash.store("
", safe=True) return lines def _isLine(self, block) : diff --git a/tests/misc/blockquote-hr.html b/tests/misc/blockquote-hr.html new file mode 100644 index 0000000..1d7af0f --- /dev/null +++ b/tests/misc/blockquote-hr.html @@ -0,0 +1,23 @@ +

This is a paragraph. +

+
+ +

Block quote with horizontal lines. +

+
+ +

Double block quote. +

+
+ +

End of the double block quote. +

+

A new paragraph. + With multiple lines. + Even a lazy line. +

+
+ +

The last line. +

+
\ No newline at end of file diff --git a/tests/misc/blockquote-hr.txt b/tests/misc/blockquote-hr.txt new file mode 100644 index 0000000..ef9c44f --- /dev/null +++ b/tests/misc/blockquote-hr.txt @@ -0,0 +1,21 @@ +This is a paragraph. + +--- + +> Block quote with horizontal lines. + +> --- + +> > Double block quote. + +> > --- + +> > End of the double block quote. + +> A new paragraph. +> With multiple lines. +Even a lazy line. + +> --- + +> The last line. -- cgit v1.2.3