bugdown: Allow block-level block quotes

It is triggered by specifying the "language" of a code block to
"quote" or "quoted":
    Hamlet said:
    ~~~ quote
    To be or **not** to be.

    That is the question
    ~~~

(imported from commit 847a0602e335e9f2955e32d9955adf8ac8de068c)
This commit is contained in:
Zev Benjamin
2013-09-04 17:03:45 -04:00
parent dd26260884
commit cb78014eef
2 changed files with 52 additions and 0 deletions

View File

@@ -107,6 +107,15 @@ class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
if m.group('lang'):
langclass = LANG_TAG % m.group('lang')
if m.group('lang') in ('quote', 'quoted'):
paragraphs = m.group('code').split("\n\n")
quoted_paragraphs = []
for paragraph in paragraphs:
lines = paragraph.split("\n")
quoted_paragraphs.append("\n".join("> " + line for line in lines if line != ''))
replacement = "\n\n".join(quoted_paragraphs)
return '%s\n%s\n%s'% (text[:m.start()], replacement, text[m.end():])
# If config is not empty, then the codehighlite extension
# is enabled, so we call it to highlite the code
if self.codehilite_conf: