mirror of https://github.com/zulip/zulip.git
parent
479aa5b83d
commit
88a7ea54d2
|
@ -154,6 +154,8 @@ def validate(fn=None, text=None, check_indent=True):
|
||||||
end_col = end_token.col
|
end_col = end_token.col
|
||||||
|
|
||||||
problem = None
|
problem = None
|
||||||
|
if (start_tag == 'code') and (end_line == start_line + 1):
|
||||||
|
problem = 'Code tag is split across two lines.'
|
||||||
if start_tag != end_tag:
|
if start_tag != end_tag:
|
||||||
problem = 'Mismatched tag.'
|
problem = 'Mismatched tag.'
|
||||||
elif check_indent and end_line > start_line + 1 and end_col != start_col:
|
elif check_indent and end_line > start_line + 1 and end_col != start_col:
|
||||||
|
|
|
@ -54,6 +54,31 @@ class ParserTest(unittest.TestCase):
|
||||||
'''
|
'''
|
||||||
validate(text=my_html)
|
validate(text=my_html)
|
||||||
|
|
||||||
|
def test_code_blocks(self):
|
||||||
|
# type: () -> None
|
||||||
|
|
||||||
|
# This is fine.
|
||||||
|
my_html = '''
|
||||||
|
<code>
|
||||||
|
x = 5
|
||||||
|
y = x + 1
|
||||||
|
</code>'''
|
||||||
|
validate(text=my_html)
|
||||||
|
|
||||||
|
# This is also fine.
|
||||||
|
my_html = "<code>process_widgets()</code>"
|
||||||
|
validate(text=my_html)
|
||||||
|
|
||||||
|
# This is illegal.
|
||||||
|
my_html = '''
|
||||||
|
<code>x =
|
||||||
|
5</code>
|
||||||
|
'''
|
||||||
|
# See https://github.com/python/typeshed/issues/372
|
||||||
|
# for why we have to ingore types here.
|
||||||
|
with self.assertRaisesRegexp(Exception, 'split across two lines'): # type: ignore
|
||||||
|
validate(text=my_html)
|
||||||
|
|
||||||
def test_tokenize(self):
|
def test_tokenize(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
tag = '<meta whatever>bla'
|
tag = '<meta whatever>bla'
|
||||||
|
|
Loading…
Reference in New Issue