markdown-textwrap

text wrap markdown documents
git clone git://git.ricketyspace.net/markdown-textwrap.git
Log | Files | Refs

commit de60264585b4056f849f1defa214ce29506384d2
parent abdefc1c526cc0ce8ec0172c01ae70771c303dba
Author: rsiddharth <s@ricketyspace.net>
Date:   Sat, 24 Feb 2018 21:28:39 +0000

md_tw.py: Update TWMarkdown.output_loose_item.

Refactor indenting.

* md_tw.py (TWMarkdown)[output_loose_item]: Update method.

Diffstat:
md_tw.py | 16+++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/md_tw.py b/md_tw.py @@ -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)