diff --git a/ChangeLog b/ChangeLog index 0c37c837..7598f24a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ * only remove anchors on IIS servers (other servers are doing quite well with anchors... can you spell A-p-a-c-h-e ?) Changed files: linkcheck/{HttpUrlData, UrlData}.py + * correctly propagate and display parsing errors + Changed files: linkcheck/parser/html{lex.l, parse.y}, + linkcheck/linkparse.py 1.8.13 * fix typo in manpage diff --git a/linkcheck/linkparse.py b/linkcheck/linkparse.py index 1b9c432f..7d441ed5 100644 --- a/linkcheck/linkparse.py +++ b/linkcheck/linkparse.py @@ -64,6 +64,8 @@ class LinkParser (HtmlParser): self.content = content self.tags = tags self.urls = [] + # warnings and errors during parsing + self.parse_info = [] self.feed(self.content) debug(HURT_ME_PLENTY, "flushing") self.flush() @@ -108,3 +110,26 @@ class LinkParser (HtmlParser): self.urls.append((url, self.last_lineno(), self.last_column(), name, base)) + + def _errorfun (self, msg, name): + """append msg to error list""" + pos = "%d:%d" % (self.lineno(), self.column()) + self.parse_info.append("%s: %s: %s" % (name, pos, msg)) + print >> sys.stderr, name, pos, msg + + + def error (self, msg): + """signal a filter/parser error""" + self._errorfun(msg, "error:") + + + def warning (self, msg): + """signal a filter/parser warning""" + self._errorfun(msg, "warning:") + + + def fatalError (self, msg): + """signal a fatal filter/parser error""" + self._errorfun(msg, "fatal error:") + +