diff --git a/evennia/utils/tests/test_text2html.py b/evennia/utils/tests/test_text2html.py
index a1c45c06f4..3b67cd426e 100644
--- a/evennia/utils/tests/test_text2html.py
+++ b/evennia/utils/tests/test_text2html.py
@@ -120,13 +120,6 @@ class TestText2Html(TestCase):
)
# TODO: doesn't URL encode correctly
- def test_re_double_space(self):
- parser = text2html.HTML_PARSER
- self.assertEqual("foo", parser.re_double_space("foo"))
- self.assertEqual(
- "a red foo", parser.re_double_space("a red foo")
- )
-
def test_sub_mxp_links(self):
parser = text2html.HTML_PARSER
mocked_match = mock.Mock()
@@ -156,7 +149,7 @@ class TestText2Html(TestCase):
"tab": "\t",
"space": "",
}
- self.assertEqual(" ", parser.sub_text(mocked_match))
+ self.assertEqual(" ", parser.sub_text(mocked_match))
mocked_match.groupdict.return_value = {
"htmlchars": "",
@@ -165,7 +158,7 @@ class TestText2Html(TestCase):
"space": " ",
"spacestart": " ",
}
- self.assertEqual(" ", parser.sub_text(mocked_match))
+ self.assertEqual(" ", parser.sub_text(mocked_match))
mocked_match.groupdict.return_value = {
"htmlchars": "",
@@ -181,24 +174,13 @@ class TestText2Html(TestCase):
parser = text2html.HTML_PARSER
parser.tabstop = 4
# single tab
- self.assertEqual(parser.parse("foo|>foo"), "foo foo")
+ self.assertEqual(parser.parse("foo|>foo"), "foo foo")
# space and tab
- self.assertEqual(parser.parse("foo |>foo"), "foo foo")
+ self.assertEqual(parser.parse("foo |>foo"), "foo foo")
# space, tab, space
- self.assertEqual(parser.parse("foo |> foo"), "foo foo")
-
- def test_parse_space_to_html(self):
- """test space parsing - a single space should be kept, two or more
- should get """
- parser = text2html.HTML_PARSER
- # single space
- self.assertEqual(parser.parse("foo foo"), "foo foo")
- # double space
- self.assertEqual(parser.parse("foo foo"), "foo foo")
- # triple space
- self.assertEqual(parser.parse("foo foo"), "foo foo")
+ self.assertEqual(parser.parse("foo |> foo"), "foo foo")
def test_parse_html(self):
self.assertEqual("foo", text2html.parse_html("foo"))
diff --git a/evennia/utils/text2html.py b/evennia/utils/text2html.py
index 91a627f33b..be8f459c87 100644
--- a/evennia/utils/text2html.py
+++ b/evennia/utils/text2html.py
@@ -79,11 +79,11 @@ class TextToHTMLparser(object):
# create stop markers
fgstop = "(?:\033\[1m|\033\[22m){0,1}\033\[3[0-8].*?m|\033\[0m|$"
bgstop = "(?:\033\[1m|\033\[22m){0,1}\033\[4[0-8].*?m|\033\[0m|$"
- bgfgstop = bgstop[:-2] + r"(\s*)" + fgstop
+ bgfgstop = bgstop[:-2] + fgstop
fgstart = "((?:\033\[1m|\033\[22m){0,1}\033\[3[0-8].*?m)"
bgstart = "((?:\033\[1m|\033\[22m){0,1}\033\[4[0-8].*?m)"
- bgfgstart = bgstart + r"(\s*)" + "((?:\033\[1m|\033\[22m){0,1}\033\[[3-4][0-8].*?m){0,1}"
+ bgfgstart = bgstart + r"((?:\033\[1m|\033\[22m){0,1}\033\[[3-4][0-8].*?m){0,1}"
# extract color markers, tagging the start marker and the text marked
re_fgs = re.compile(fgstart + "(.*?)(?=" + fgstop + ")")
@@ -97,12 +97,9 @@ class TextToHTMLparser(object):
re_blink = re.compile("(?:%s)(.*?)(?=%s|%s)" % (blink.replace("[", r"\["), fgstop, bgstop))
re_inverse = re.compile("(?:%s)(.*?)(?=%s|%s)" % (inverse.replace("[", r"\["), fgstop, bgstop))
re_string = re.compile(
- r"(?P[<&>])|(?P[\t]+)|(?P +)|"
- r"(?P^ )|(?P\r\n|\r|\n)",
+ r"(?P[<&>])|(?P[\t]+)|(?P\r\n|\r|\n)",
re.S | re.M | re.I,
)
- re_dblspace = re.compile(r" {2,}", re.M)
- re_invisiblespace = re.compile(r"( <.*?>)( )")
re_url = re.compile(
r'(?\[\]\s])+)(\.(?:\s|$)|&\w+;|)'
)
@@ -111,20 +108,16 @@ class TextToHTMLparser(object):
def _sub_bgfg(self, colormatch):
# print("colormatch.groups()", colormatch.groups())
- bgcode, prespace, fgcode, text, postspace = colormatch.groups()
+ bgcode, fgcode, text = colormatch.groups()
if not fgcode:
- ret = r"""%s%s%s""" % (
+ ret = r"""%s""" % (
self.bg_colormap.get(bgcode, self.fg_colormap.get(bgcode, "err")),
- prespace and " " * len(prespace) or "",
- postspace and " " * len(postspace) or "",
text,
)
else:
- ret = r"""%s%s%s""" % (
+ ret = r"""%s""" % (
self.bg_colormap.get(bgcode, self.fg_colormap.get(bgcode, "err")),
self.fg_colormap.get(fgcode, self.bg_colormap.get(fgcode, "err")),
- prespace and " " * len(prespace) or "",
- postspace and " " * len(postspace) or "",
text,
)
return ret
@@ -265,20 +258,6 @@ class TextToHTMLparser(object):
# change pages (and losing our webclient session).
return self.re_url.sub(r'\1\2', text)
- def re_double_space(self, text):
- """
- HTML will swallow any normal space after the first, so if any slipped
- through we must make sure to replace them with " "
- """
- return self.re_dblspace.sub(self.sub_dblspace, text)
-
- def re_invisible_space(self, text):
- """
- If two spaces are separated by an invisble html element, they act as a
- hidden double-space and the last of them should be replaced by
- """
- return self.re_invisiblespace.sub(self.sub_invisiblespace, text)
-
def sub_mxp_links(self, match):
"""
Helper method to be passed to re.sub,
@@ -332,28 +311,10 @@ class TextToHTMLparser(object):
elif cdict["lineend"]:
return "
"
elif cdict["tab"]:
- text = cdict["tab"].replace("\t", " " + " " * (self.tabstop - 1))
- return text
- elif cdict["space"] or cdict["spacestart"]:
- text = cdict["space"]
- text = " " if len(text) == 1 else " " + text[1:].replace(" ", " ")
+ text = cdict["tab"].replace("\t", " " * (self.tabstop))
return text
return None
- def sub_dblspace(self, match):
- "clean up double-spaces"
- return " " + " " * (len(match.group()) - 1)
-
- def sub_invisiblespace(self, match):
- "clean up invisible spaces"
- return match.group(1) + " "
-
- def handle_single_first_space(self, text):
- "Don't swallow an initial lone space"
- if text.startswith(" "):
- return " " + text[1:]
- return text
-
def parse(self, text, strip_ansi=False):
"""
Main access function, converts a text containing ANSI codes
@@ -383,9 +344,6 @@ class TextToHTMLparser(object):
result = self.convert_linebreaks(result)
result = self.remove_backspaces(result)
result = self.convert_urls(result)
- result = self.re_double_space(result)
- result = self.re_invisible_space(result)
- result = self.handle_single_first_space(result)
# clean out eventual ansi that was missed
## result = parse_ansi(result, strip_ansi=True)
diff --git a/evennia/web/static/webclient/css/webclient.css b/evennia/web/static/webclient/css/webclient.css
index bc94b84ae8..55135acc60 100644
--- a/evennia/web/static/webclient/css/webclient.css
+++ b/evennia/web/static/webclient/css/webclient.css
@@ -49,6 +49,7 @@ div {margin:0px;}
.out {
color: #aaa;
background-color: #000;
+ white-space: pre-wrap;
}
/* Error messages (red) */