lint: Allow anchor tags to span up to four lines.

This starts to address 1533.  I still think the </p> tags
should be on their own line lined up with the start tag,
so the linter won't let through the specific example
shown in the ticket.
This commit is contained in:
Steve Howell 2016-08-18 07:17:06 -07:00 committed by Tim Abbott
parent 88a7ea54d2
commit 747744ad61
2 changed files with 33 additions and 2 deletions

View File

@ -153,13 +153,19 @@ def validate(fn=None, text=None, check_indent=True):
end_line = end_token.line
end_col = end_token.col
if start_tag == 'a':
max_lines = 3
else:
max_lines = 1
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:
problem = 'Mismatched tag.'
elif check_indent and end_line > start_line + 1 and end_col != start_col:
problem = 'Bad indentation.'
elif check_indent and (end_line > start_line + max_lines):
if end_col != start_col:
problem = 'Bad indentation.'
if problem:
raise Exception('''
fn: %s

View File

@ -79,6 +79,31 @@ class ParserTest(unittest.TestCase):
with self.assertRaisesRegexp(Exception, 'split across two lines'): # type: ignore
validate(text=my_html)
def test_anchor_blocks(self):
# type: () -> None
# This is allowed, although strange.
my_html = '''
<a hef="/some/url">
Click here
for more info.
</a>'''
validate(text=my_html)
# This is fine.
my_html = '<a href="/some/url">click here</a>'
validate(text=my_html)
# Even this is fine.
my_html = '''
<a class="twitter-timeline" href="https://twitter.com/ZulipStatus"
data-widget-id="443457763394334720"
data-screen-name="ZulipStatus"
>@ZulipStatus on Twitter</a>.
'''
validate(text=my_html)
def test_tokenize(self):
# type: () -> None
tag = '<meta whatever>bla'