- # Parse XSLT
- try:
- if file_path:
- if slug:
- raise ValueError('slug or file_path should be specified, not both')
- document = load_including_children(provider, file_path=file_path)
- else:
- if not slug:
- raise ValueError('either slug or file_path should be specified')
- document = load_including_children(provider, slug=slug)
+ if uri and provider:
+ f = provider.by_uri(uri)
+ text = f.read().decode('utf-8')
+ f.close()
+ elif wldoc is not None:
+ text = etree.tostring(wldoc.edoc, encoding=unicode)
+ provider = wldoc.provider
+ else:
+ raise ValueError('Neither a WLDocument, nor provider and URI were provided.')
+
+ text = re.sub(ur"([\u0400-\u04ff]+)", ur"<alien>\1</alien>", text)
+
+ document = WLDocument.from_string(text,
+ parse_dublincore=True, provider=provider)
+ document.swap_endlines()
+
+ for child_uri in document.book_info.parts:
+ child = load_including_children(provider=provider, uri=child_uri)
+ document.edoc.getroot().append(child.edoc.getroot())
+ return document
+
+
+class PDFFormat(Format):
+ """ Base PDF format.
+
+ Available customization:
+ nofootnotes: Doesn't do footnotes.
+ nothemes: Doesn't do themes.
+ defaultleading: Default leading.
+ onehalfleading: Bigger leading.
+ doubleleading: Big leading.
+ nowlfont: Uses standard TeX font instead of JUnicodeWL.
+
+ """