diff options
author | rsiddharth <s@ricketyspace.net> | 2018-02-24 21:28:39 +0000 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2018-02-24 21:28:39 +0000 |
commit | de60264585b4056f849f1defa214ce29506384d2 (patch) | |
tree | 9354e12f3633d0e1ca1e3e940ecd7967a966e7d7 /md_tw.py | |
parent | abdefc1c526cc0ce8ec0172c01ae70771c303dba (diff) |
md_tw.py: Update TWMarkdown.output_loose_item.
Refactor indenting.
* md_tw.py (TWMarkdown)[output_loose_item]: Update method.
Diffstat (limited to 'md_tw.py')
-rw-r--r-- | md_tw.py | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -396,20 +396,18 @@ class TWMarkdown(mistune.Markdown): return rendered_li def output_loose_item(self): - i_indent = False # initial indent - s_indent = True # subsequent indent + rm_i_indent = True # Remove initial indent. indent = ''.ljust(self.token['spaces']) def process(): - nonlocal i_indent + nonlocal rm_i_indent txt = self.tok() - if not i_indent: + if rm_i_indent: txt = txt.lstrip() - # Set initial indent after processing first item - i_indent = True - self._add_prefix(indent, i_indent, s_indent) + # Don't remove initial indent after processing first item. + rm_i_indent = False return txt @@ -423,7 +421,7 @@ class TWMarkdown(mistune.Markdown): self.renderer.tw_set(width=item_width) # Set prefix - prefix = self._add_prefix(indent, i_indent, s_indent) + prefix = self._add_prefix(indent) while self.pop()['type'] != 'list_item_end': body += process() @@ -432,7 +430,7 @@ class TWMarkdown(mistune.Markdown): rendered_li = self.renderer.list_item(body) # Remove prefix - self._remove_prefix(len(indent), i_indent, s_indent) + self._remove_prefix(len(indent)) # Revert width self.renderer.tw_set(width=o_width) |