From a2e02ff4b24212412a09e6aef05b95205068eff6 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 24 Feb 2018 21:14:36 +0000 Subject: md_tw.py: Update TWMarkdown.output_list_item. * md_tw.py (TWMarkdown)[output_list_item]: Update method. --- md_tw.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/md_tw.py b/md_tw.py index a292897..467b415 100644 --- a/md_tw.py +++ b/md_tw.py @@ -357,12 +357,11 @@ class TWMarkdown(mistune.Markdown): return self.renderer.block_html(text) def output_list_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 = '' if self.token['type'] == 'text': @@ -370,12 +369,11 @@ class TWMarkdown(mistune.Markdown): else: 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 @@ -383,7 +381,7 @@ class TWMarkdown(mistune.Markdown): body = self.renderer.tw_get('initial_indent') + self.token['text'] # Set prefix - prefix = self._add_prefix(indent, i_indent, s_indent) + prefix = self._add_prefix(indent) # Process list item while self.pop()['type'] != 'list_item_end': @@ -393,7 +391,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)) return rendered_li -- cgit v1.2.3