mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit book: When showing HTML tag mismatch errors, show clickable links for the opening as well as the closing tags
This commit is contained in:
parent
8add032da1
commit
421bb00a06
@ -23,6 +23,7 @@ XML_ENTITIES = {'lt', 'gt', 'amp', 'apos', 'quot'}
|
|||||||
ALL_ENTITIES = HTML_ENTITTIES | XML_ENTITIES
|
ALL_ENTITIES = HTML_ENTITTIES | XML_ENTITIES
|
||||||
|
|
||||||
replace_pat = re.compile('&(%s);' % '|'.join(re.escape(x) for x in sorted((HTML_ENTITTIES - XML_ENTITIES))))
|
replace_pat = re.compile('&(%s);' % '|'.join(re.escape(x) for x in sorted((HTML_ENTITTIES - XML_ENTITIES))))
|
||||||
|
mismatch_pat = re.compile('tag mismatch:.+?line (\d+).+?line \d+')
|
||||||
|
|
||||||
class XMLParseError(BaseError):
|
class XMLParseError(BaseError):
|
||||||
|
|
||||||
@ -35,6 +36,10 @@ class XMLParseError(BaseError):
|
|||||||
|
|
||||||
def __init__(self, msg, *args, **kwargs):
|
def __init__(self, msg, *args, **kwargs):
|
||||||
BaseError.__init__(self, 'Parsing failed: ' + msg, *args, **kwargs)
|
BaseError.__init__(self, 'Parsing failed: ' + msg, *args, **kwargs)
|
||||||
|
m = mismatch_pat.search(msg)
|
||||||
|
if m is not None:
|
||||||
|
self.has_multiple_locations = True
|
||||||
|
self.all_locations = [(self.name, int(m.group(1)), None), (self.name, self.line, self.col)]
|
||||||
|
|
||||||
class HTMLParseError(XMLParseError):
|
class HTMLParseError(XMLParseError):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user