From: Alejandro R. SedeƱo Date: Tue, 19 Apr 2022 17:50:41 +0000 (-0400) Subject: Try to detect post-list content X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=b55d7bf781300080110c8d036b98641e6844d312;hp=7403cd015eec0f46ba517c1da00eab72814606de;p=vt_decor.git Try to detect post-list content --- diff --git a/vt_decor.py b/vt_decor.py index 7a1ee48..ff56319 100644 --- a/vt_decor.py +++ b/vt_decor.py @@ -163,12 +163,31 @@ class RoostVTDecor(roost.RoostMessage.Decor): else: # Content # collapse whitespace and wrap. - ret += textwrap.fill(re.sub(r'\s+', ' ', m), width, - initial_indent=indent+bindent, - subsequent_indent=indent+bindent, - break_long_words=False, - break_on_hyphens=False).lstrip() - ret += '\n' + if '\n\n' in m: + # list appears to end and have further content. + # deal with final (?) bullet... + bm, rest = m.split('\n\n', 1) + ret += textwrap.fill(re.sub(r'\s+', ' ', bm), width, + initial_indent=indent+bindent, + subsequent_indent=indent+bindent, + break_long_words=False, + break_on_hyphens=False).lstrip() + + # ... and then indent and wrap following content normally. + ret += '\n\n' + ret += textwrap.fill(re.sub(r'\s+', ' ', rest), width, + initial_indent=indent, + subsequent_indent=indent, + break_long_words=False, + break_on_hyphens=False) + ret += '\n' + else: + ret += textwrap.fill(re.sub(r'\s+', ' ', m), width, + initial_indent=indent+bindent, + subsequent_indent=indent+bindent, + break_long_words=False, + break_on_hyphens=False).lstrip() + ret += '\n' return ret.rstrip() except Exception as e: