Extract get_html_tag in check-templates.

(imported from commit 365a2bb4e9b2bf94f7b8e16a40fec0b461b64ab8)
This commit is contained in:
Steve Howell 2014-02-27 10:50:18 -05:00 committed by Jessica McKellar
parent c7a9e08105
commit 7e49396fc5
1 changed files with 10 additions and 6 deletions

View File

@ -68,12 +68,7 @@ def validate(fn, check_indent=True):
break break
c = text[state.i] c = text[state.i]
if c == '<': if c == '<':
end = state.i + 1 s = get_html_tag(text, state.i)
while end < len(text) and text[end] != '>':
end += 1
if text[end] != '>':
raise Exception('Tag missing >')
s = text[state.i:end+1]
if s.startswith('</'): if s.startswith('</'):
state.matcher(s) state.matcher(s)
else: else:
@ -88,6 +83,15 @@ def validate(fn, check_indent=True):
if state.depth != 0: if state.depth != 0:
return state.matcher("(NO TAG)") return state.matcher("(NO TAG)")
def get_html_tag(text, i):
end = i + 1
while end < len(text) and text[end] != '>':
end += 1
if text[end] != '>':
raise Exception('Tag missing >')
s = text[i:end+1]
return s
def check_our_files(): def check_our_files():
git_files = map(str.strip, subprocess.check_output(['git', 'ls-files']).split('\n')) git_files = map(str.strip, subprocess.check_output(['git', 'ls-files']).split('\n'))