summaryrefslogtreecommitdiffstats
path: root/md_tw.py
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2018-04-01 06:39:37 +0000
committerrsiddharth <s@ricketyspace.net>2018-04-01 06:45:20 +0000
commitbb09de93520ec43b23b70c99c1f5439a16cb255e (patch)
treef522d89569feff0ee4b73ca7ad393e7c4a4c988b /md_tw.py
parent472fbff768ad431f3ca030bf899180252394f18d (diff)
md_tw.py: Update TWMarkdown.output_block_quote.
Add subsequent indent text to all 'block' tokens inside block quote. * md_tw.py (TWMarkdown.output_block_quote): Update method. (TWRenderer.block_quote): Update method. * tests/data/renderer-block-quote-w.md: New file. * tests/data/renderer-block-quote.md: New file. * tests/data/renderer-fences-w.md: Update file. * tests/test_md_tw.py (test_render_block-_quote): New test.
Diffstat (limited to 'md_tw.py')
-rw-r--r--md_tw.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/md_tw.py b/md_tw.py
index 866f1fa..0ed992e 100644
--- a/md_tw.py
+++ b/md_tw.py
@@ -270,7 +270,7 @@ class TWRenderer(mistune.Renderer):
return out
def block_quote(self, text):
- out = '{}\n'.format(text.rstrip('>\n'))
+ out = '{}\n\n'.format(text)
return out
def block_html(self, html):
@@ -368,8 +368,32 @@ class TWMarkdown(mistune.Markdown):
# Add prefix
self._add_prefix('> ')
+ def process():
+ if self.token['type'] == 'text':
+ txt = self.renderer.tw_fill(self.tok_text())
+ else:
+ # Append subsequent indent.
+ txt = ''.join([
+ self.tok().rstrip(),
+ '\n',
+ self.renderer.tw_get('subsequent_indent'),
+ '\n'
+ ])
+
+ return txt
+
+ body = self.renderer.placeholder()
+ while self.pop()['type'] != 'block_quote_end':
+ body += process()
+
+ # Remove last trailing subsequent indent.
+ body = body.rstrip(
+ self.renderer.tw_get('subsequent_indent') +
+ '\n'
+ )
+
# Render block quote
- rendered_bq = super(TWMarkdown, self).output_block_quote()
+ rendered_bq = self.renderer.block_quote(body)
# Remove prefix
self._remove_prefix(len('> '))