- find_annotations(annotations, chunk_xml, chunk_no)
- replace_by_verse(chunk_xml)
- output_html = etree.tostring(xslt(chunk_xml, res('xsltScheme.xsl')), pretty_print=True)
- return output_html, toc
-
-
-def transform(provider, slug, output_file):
- """ produces an epub
-
- provider is a DocProvider
- output_file should be filelike object
+ if empty:
+ if not _empty_html_static:
+ _empty_html_static.append(open(res('emptyChunk.html')).read())
+ chars = set()
+ output_html = _empty_html_static[0]
+ else:
+ find_annotations(annotations, chunk_xml, chunk_no)
+ replace_by_verse(chunk_xml)
+ html_tree = xslt(chunk_xml, res('xsltScheme.xsl'))
+ chars = used_chars(html_tree.getroot())
+ output_html = etree.tostring(html_tree, method="html", pretty_print=True)
+ return output_html, toc, chars
+
+
+def transform(provider, slug=None, file_path=None, output_file=None, output_dir=None, make_dir=False, verbose=False, sample=None):
+ """ produces a EPUB file
+
+ provider: a DocProvider
+ slug: slug of file to process, available by provider
+ output_file: file-like object or path to output file
+ output_dir: path to directory to save output file to; either this or output_file must be present
+ make_dir: writes output to <output_dir>/<author>/<slug>.epub instead of <output_dir>/<slug>.epub
+ sample=n: generate sample e-book (with at least n paragraphs)