DRY up m.group('code') in FencedBlockPreprocessor.

(imported from commit b23caae1ab63a9adb80025b628bc1a7c6a988ce0)
This commit is contained in:
Steve Howell 2013-11-20 13:42:18 -05:00
parent 6bc25d3d7b
commit c0f312ec29
1 changed files with 5 additions and 4 deletions

View File

@ -136,21 +136,22 @@ class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
quoted_paragraphs.append("\n".join("> " + line for line in lines if line != '')) quoted_paragraphs.append("\n".join("> " + line for line in lines if line != ''))
return "\n\n".join(quoted_paragraphs) return "\n\n".join(quoted_paragraphs)
def format_fence(self, m, lang): def format_fence(self, lang, text):
langclass = '' langclass = ''
if lang: if lang:
langclass = LANG_TAG % (lang,) langclass = LANG_TAG % (lang,)
if lang in ('quote', 'quoted'): if lang in ('quote', 'quoted'):
replacement = self.format_quote(m.group('code')) replacement = self.format_quote(text)
return replacement return replacement
code = self.format_code(langclass, lang, m.group('code')) code = self.format_code(langclass, lang, text)
placeholder = self.markdown.htmlStash.store(code, safe=True) placeholder = self.markdown.htmlStash.store(code, safe=True)
return placeholder return placeholder
def process_fence(self, m, text): def process_fence(self, m, text):
lang = m.group('lang') lang = m.group('lang')
fence_text = self.format_fence(m, lang) code = m.group('code')
fence_text = self.format_fence(lang, code)
return '%s\n%s\n%s'% (text[:m.start()], fence_text, text[m.end():]) return '%s\n%s\n%s'% (text[:m.start()], fence_text, text[m.end():])
def run(self, lines): def run(self, lines):