from urllib2 import urlopen
from lxml import etree
-from librarian import OPFNS, NCXNS, XHTMLNS, DCNS
+from librarian import OPFNS, NCXNS, XHTMLNS, DCNS, BuildError
from librarian import core
from librarian.formats import Format
from librarian.formats.cover.evens import EvensCover
EpubFormat.renderers.register(core.Div, 'list', NaturalText('ul'))
EpubFormat.renderers.register(core.Div, 'list.enum', NaturalText('ol'))
EpubFormat.renderers.register(core.Div, 'item', NaturalText('li'))
+EpubFormat.renderers.register(core.Span, 'item', NaturalText('li'))
class DivImageR(EpubRenderer):
def render(self, element, ctx):
src = element.attrib.get('src', '')
ctx.images.append(src)
+ if '/' not in src:
+ raise BuildError('Bad image URL')
src = src.rsplit('/', 1)[1]
return super(DivImageR, self).render(element, Context(ctx, src=src))