fnp
/
librarian.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow no cover image in epub
[librarian.git]
/
librarian
/
formats
/
pdf
/
__init__.py
diff --git
a/librarian/formats/pdf/__init__.py
b/librarian/formats/pdf/__init__.py
index
0ff985f
..
a994008
100644
(file)
--- a/
librarian/formats/pdf/__init__.py
+++ b/
librarian/formats/pdf/__init__.py
@@
-11,7
+11,7
@@
from lxml import etree
from urllib import urlretrieve
from StringIO import StringIO
from Texml.processor import process
from urllib import urlretrieve
from StringIO import StringIO
from Texml.processor import process
-from librarian import DCNS, XMLNamespace
+from librarian import DCNS, XMLNamespace
, BuildError
from librarian.formats import Format
from librarian.output import OutputFile
from librarian.renderers import Register, TreeRenderer
from librarian.formats import Format
from librarian.output import OutputFile
from librarian.renderers import Register, TreeRenderer
@@
-52,7
+52,8
@@
class PdfFormat(Format):
def add_file(self, ctx, filename, url=None, path=None, image=False):
from subprocess import call
def add_file(self, ctx, filename, url=None, path=None, image=False):
from subprocess import call
- assert url or path
+ if not url and not path:
+ raise BuildError('No URL or path for image')
save_as = os.path.join(ctx.workdir, filename)
if path is not None:
ext = path.rsplit('.', 1)[-1]
save_as = os.path.join(ctx.workdir, filename)
if path is not None:
ext = path.rsplit('.', 1)[-1]
@@
-72,6
+73,8
@@
class PdfFormat(Format):
if url.startswith('/'):
url = 'http://milpeer.eu' + url
if url.startswith('/'):
url = 'http://milpeer.eu' + url
+ if '.' not in url:
+ raise BuildError('Linked file without extension: %s' % url)
ext = url.rsplit('.', 1)[-1]
if image:
urlretrieve(url, save_as + '_.' + ext)
ext = url.rsplit('.', 1)[-1]
if image:
urlretrieve(url, save_as + '_.' + ext)
@@
-346,6
+349,7
@@
PdfFormat.renderers.register(core.Div, 'video', VideoRenderer('par'))
PdfFormat.renderers.register(core.Div, 'defined', CmdRenderer('textbf'))
PdfFormat.renderers.register(core.Div, 'item', CmdRenderer('item'))
PdfFormat.renderers.register(core.Div, 'defined', CmdRenderer('textbf'))
PdfFormat.renderers.register(core.Div, 'item', CmdRenderer('item'))
+PdfFormat.renderers.register(core.Span, 'item', CmdRenderer('item'))
PdfFormat.renderers.register(core.Div, 'list', EnvRenderer('itemize'))
PdfFormat.renderers.register(core.Div, 'list.enum', EnvRenderer('enumerate'))
PdfFormat.renderers.register(core.Div, 'list', EnvRenderer('itemize'))
PdfFormat.renderers.register(core.Div, 'list.enum', EnvRenderer('enumerate'))