From e015ac050c62b06c6ca0a81f073db4db286ca2ea Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 14 Sep 2010 13:38:29 -0400 Subject: [PATCH] Improve html_toc.py parser error messages. --- _script/html_toc.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/_script/html_toc.py b/_script/html_toc.py index 0375ded..b530fad 100755 --- a/_script/html_toc.py +++ b/_script/html_toc.py @@ -47,8 +47,12 @@ class ToCTree (object): tree = etree.parse(StringIO('\n'.join(lines)), parser=parser) if len(parser.error_log) > 0: print >> sys.stderr, '%s: parsing error' % self._path - print >> sys.stderr, '(listed lines offset by +2)' - print >> sys.stderr, parser.error_log + for error in parser.error_log: + print >> sys.stderr, ' '+'\n '.join([ + '%s (line %d)' % (error.message, error.line-2), + ' '+lines[error.line][:error.column], + ' '+' '*error.column + lines[error.line][error.column:], + ]) return (tree, 2) def _page_title(self): -- 2.26.2