Fix profunc parse and html tabs. Resolve #2246
This commit is contained in:
parent
4dd2e71448
commit
b7b2872f43
3 changed files with 12 additions and 9 deletions
|
|
@ -929,7 +929,10 @@ def init_spawn_value(value, validator=None):
|
||||||
value = validator(value[0](*make_iter(args)))
|
value = validator(value[0](*make_iter(args)))
|
||||||
else:
|
else:
|
||||||
value = validator(value)
|
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):
|
def value_to_obj_or_any(value):
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ class TestText2Html(TestCase):
|
||||||
"tab": "\t",
|
"tab": "\t",
|
||||||
"space": "",
|
"space": "",
|
||||||
}
|
}
|
||||||
self.assertEqual(" ", parser.sub_text(mocked_match))
|
self.assertEqual(" ", parser.sub_text(mocked_match))
|
||||||
|
|
||||||
mocked_match.groupdict.return_value = {
|
mocked_match.groupdict.return_value = {
|
||||||
"htmlchars": "",
|
"htmlchars": "",
|
||||||
|
|
@ -165,7 +165,7 @@ class TestText2Html(TestCase):
|
||||||
"space": " ",
|
"space": " ",
|
||||||
"spacestart": " ",
|
"spacestart": " ",
|
||||||
}
|
}
|
||||||
self.assertEqual(" ",
|
self.assertEqual(" ",
|
||||||
parser.sub_text(mocked_match))
|
parser.sub_text(mocked_match))
|
||||||
|
|
||||||
mocked_match.groupdict.return_value = {
|
mocked_match.groupdict.return_value = {
|
||||||
|
|
@ -182,16 +182,16 @@ class TestText2Html(TestCase):
|
||||||
parser = text2html.HTML_PARSER
|
parser = text2html.HTML_PARSER
|
||||||
parser.tabstop = 4
|
parser.tabstop = 4
|
||||||
# single tab
|
# single tab
|
||||||
self.assertEqual(parser.parse("foo|-foo"),
|
self.assertEqual(parser.parse("foo|>foo"),
|
||||||
"foo foo")
|
"foo foo")
|
||||||
|
|
||||||
# space and tab
|
# space and tab
|
||||||
self.assertEqual(parser.parse("foo |-foo"),
|
self.assertEqual(parser.parse("foo |>foo"),
|
||||||
"foo foo")
|
"foo foo")
|
||||||
|
|
||||||
# space, tab, space
|
# space, tab, space
|
||||||
self.assertEqual(parser.parse("foo |- foo"),
|
self.assertEqual(parser.parse("foo |> foo"),
|
||||||
"foo foo")
|
"foo foo")
|
||||||
|
|
||||||
def test_parse_space_to_html(self):
|
def test_parse_space_to_html(self):
|
||||||
"""test space parsing - a single space should be kept, two or more
|
"""test space parsing - a single space should be kept, two or more
|
||||||
|
|
|
||||||
|
|
@ -308,7 +308,7 @@ class TextToHTMLparser(object):
|
||||||
elif cdict["lineend"]:
|
elif cdict["lineend"]:
|
||||||
return "<br>"
|
return "<br>"
|
||||||
elif cdict["tab"]:
|
elif cdict["tab"]:
|
||||||
text = cdict["tab"].replace("\t", "<span class=\"tabspace\">	</span>")
|
text = cdict["tab"].replace("\t", " " + " " * (self.tabstop - 1))
|
||||||
return text
|
return text
|
||||||
elif cdict["space"] or cdict["spacestart"]:
|
elif cdict["space"] or cdict["spacestart"]:
|
||||||
text = cdict["space"]
|
text = cdict["space"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue