diff options
author | rsiddharth <s@ricketyspace.net> | 2018-02-18 19:28:51 +0000 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2018-02-18 19:28:51 +0000 |
commit | 8c4f391f27dd7bcfe8e8c97843952125a8f0d16f (patch) | |
tree | 0b001522ce00bef71f89cb644dad320aadc4be9c | |
parent | 29c723f28ec273b797930009af28aeb5708b3370 (diff) |
md_tw.py: Add TWMarkdown._client_ts.
* md_tw.py (TWMarkdown)[_client_ts]: New method.
[parse]: Update method.
-rw-r--r-- | md_tw.py | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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')) |