FB2 Input: Workaround for unquoted ampersands

This commit is contained in:
Kovid Goyal 2009-12-01 18:09:50 +00:00
parent 1327e15337
commit b27c880be6

View File

@ -43,7 +43,11 @@ class FB2Input(InputFormatPlugin):
from calibre.ebooks.oeb.base import XLINK_NS from calibre.ebooks.oeb.base import XLINK_NS
NAMESPACES = {'f':FB2NS, 'l':XLINK_NS} NAMESPACES = {'f':FB2NS, 'l':XLINK_NS}
log.debug('Parsing XML...') log.debug('Parsing XML...')
doc = etree.fromstring(stream.read()) raw = stream.read()
try:
doc = etree.fromstring(raw)
except etree.XMLSyntaxError:
doc = etree.fromstring(raw.replace('& ', '&'))
self.extract_embedded_content(doc) self.extract_embedded_content(doc)
log.debug('Converting XML to HTML...') log.debug('Converting XML to HTML...')
ss = open(P('templates/fb2.xsl'), 'rb').read() ss = open(P('templates/fb2.xsl'), 'rb').read()