From 8c4f391f27dd7bcfe8e8c97843952125a8f0d16f Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 18 Feb 2018 19:28:51 +0000 Subject: md_tw.py: Add TWMarkdown._client_ts. * md_tw.py (TWMarkdown)[_client_ts]: New method. [parse]: Update method. --- md_tw.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/md_tw.py b/md_tw.py index ab20d7d..481e94a 100644 --- a/md_tw.py +++ b/md_tw.py @@ -285,9 +285,20 @@ class TWMarkdown(mistune.Markdown): TWBlockLexer ) + def _clean_ts(self, lines): + out = '' + + for line in lines.split('\n'): + out += line.rstrip() + '\n' + + return out + def parse(self, text): out = super(TWMarkdown, self).parse(text) + # Remove trailing spaces from all lines. + out = self._clean_ts(out) + # Add newline at the end. return '{}\n'.format(out.strip('\n')) -- cgit v1.2.3