diff --git a/doctools/ul_table.py b/doctools/ul_table.py index 1642896e0..caa54e245 100755 --- a/doctools/ul_table.py +++ b/doctools/ul_table.py @@ -65,6 +65,9 @@ def __init__(self, lexer, tag_lexer): self.tok_id = h8_id.Invalid self.start_pos = 0 self.end_pos = 0 + # The tag name is only populated when we are "looking at" + # h8_id.{StartTag,EndTag,StartEndTag} + self.tag_name = None # type: Optional[str] def _CurrentString(self): # type: () -> str @@ -78,6 +81,10 @@ def _Next(self, comment_ok=False): """ self.start_pos = self.end_pos self.tok_id, self.end_pos = self.lexer.Read() + if self.tok_id in (h8_id.StartTag, h8_id.EndTag, h8_id.StartEndTag): + self.tag_name = self.lexer.CanonicalTagName() + else: + self.tag_name = None # Should have called RemoveComments() beforehand. That can still leave # some REPLACE cmoments @@ -119,11 +126,9 @@ def _Eat(self, expected_id, expected_tag): raise htm8.ParseError( 'Expected token %s, got %s' % (h8_id_str(expected_id), h8_id_str(self.tok_id))) - self.tag_lexer.Reset(self.start_pos, self.end_pos) - tag_name = self.tag_lexer.GetTagName() - if expected_tag != tag_name: + if expected_tag != self.tag_name: raise htm8.ParseError('Expected tag %r, got %r' % - (expected_tag, tag_name)) + (expected_tag, self.tag_name)) self._Next() @@ -143,25 +148,19 @@ def FindUlTable(self): Return the START position of the