Fix profunc parse and html tabs. Resolve #2246

This commit is contained in:
Griatch 2020-11-11 00:41:58 +01:00
parent dfbdd3544f
commit 6d73605813
3 changed files with 12 additions and 9 deletions

View file

@ -929,7 +929,10 @@ def init_spawn_value(value, validator=None):
value = validator(value[0](*make_iter(args)))
else:
value = validator(value)
return protfunc_parser(value)
result = protfunc_parser(value)
if result != value:
return validator(result)
return result
def value_to_obj_or_any(value):

View file

@ -156,7 +156,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 +165,7 @@ class TestText2Html(TestCase):
"space": " ",
"spacestart": " ",
}
self.assertEqual("    ",
self.assertEqual("    ",
parser.sub_text(mocked_match))
mocked_match.groupdict.return_value = {
@ -182,16 +182,16 @@ 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"),
self.assertEqual(parser.parse("foo |>foo"),
"foo     foo")
# space, tab, space
self.assertEqual(parser.parse("foo |- foo"),
"foo      foo")
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

View file

@ -308,7 +308,7 @@ class TextToHTMLparser(object):
elif cdict["lineend"]:
return "<br>"
elif cdict["tab"]:
text = cdict["tab"].replace("\t", "<span class=\"tabspace\">&#0009;</span>")
text = cdict["tab"].replace("\t", " " + "&nbsp;" * (self.tabstop - 1))
return text
elif cdict["space"] or cdict["spacestart"]:
text = cdict["space"]