From 355b16004a57d5b23ef0e31adb818b5dabae3c86 Mon Sep 17 00:00:00 2001 From: Martin Vilcans Date: Wed, 13 Apr 2016 23:40:46 +0200 Subject: Replace two spaces with   in PDF output too --- screenplain/export/html.py | 6 ++---- screenplain/richstring.py | 6 +++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/screenplain/export/html.py b/screenplain/export/html.py index 625fcb4..1f88e64 100644 --- a/screenplain/export/html.py +++ b/screenplain/export/html.py @@ -3,9 +3,6 @@ # http://www.opensource.org/licenses/mit-license.php from __future__ import with_statement -import sys -import re -import cgi import os import os.path @@ -60,7 +57,8 @@ def to_html(text): html = text.to_html() if html == '': return ' ' - return re.sub(' ', '  ', html) + else: + return html class Formatter(object): diff --git a/screenplain/richstring.py b/screenplain/richstring.py index 06adf50..9470c7d 100644 --- a/screenplain/richstring.py +++ b/screenplain/richstring.py @@ -109,7 +109,11 @@ class Segment(object): ordered_styles = self.get_ordered_styles() return ( ''.join(style.start_html for style in ordered_styles) + - cgi.escape(self.text).encode('ascii', 'xmlcharrefreplace') + + re.sub( + ' ', # two spaces + '  ', + cgi.escape(self.text).encode('ascii', 'xmlcharrefreplace'), + ) + ''.join(style.end_html for style in reversed(ordered_styles)) ) -- cgit v1.2.3