epub:convert epub-convert

epubtools/epub-convert.xpl

Import URI: http://transpect.le-tex.de/epubtools/epub-convert.xpl

This step takes a HTML file as input and converts it to an epub file. You need a configuration for the HTML splitting and the OPF metadata. Examples can be found in the sample directory. Invoke this step on the command line with:

calabash/calabash.sh -i source=sample/b978-3-646-92351-3.xhtml 
  -i conf=sample/hierarchy.xml -i meta=sample/epub-config.xml epub-convert.xpl 

Note that it’s advisable to make all file inputs absolute URIs, by using cygpath on Cygwin or readlink -f on Unixy systems. For bash, this is, e.g., source=file:/$(cygpath -ma sample/b978-3-646-92351-3.xhtml)

Input Ports

NameDocumentationConnections

source

An XHTML file (Version number irrelevant; will be output as 1.1), either loaded from a physical location on disk or, alternatively, with its base URI set in an /*/@xml:base attribute. It is important that the source document have a base URI because the locations of all referenced files (CSS, images) will be determined relative to this base URI.

conf

/hierarchy, config file for HTML splitter (see sample/hierarchy.xml).

May be included in meta port doc as /epub-config/hierarchy so you don’t have to submit an extra document to this port

meta

/epub-config – an EPUB file’s metadata and other configuration settings (see sample/epub-config.xml for an example).

Please note that the name “meta” is misleading since the file contains more than just metadata.

Output Ports

NameDocumentationConnections

result

chunks

opf

files

report

baseuri

Options

NameDocumentationDefault

target

''

terminate-on-error

'yes'

clean-target-dir

Whether to erase the target directory prior to splitting etc. Otherwise, files from previous conversions might be included in the resulting zip file.

'no'

debug

'no'

use-svg

''

debug-dir-uri

'debug'

status-dir-uri

'status'

Subpipeline

StepInputsOutputsOptions

p:variable wrap-cover-in-svg

meta on epub-convert

($use-svg[not(. = '')], /epub-config/cover/@svg, 'true')[1]

p:variable target-format

meta on epub-convert

($target[not(. = '')], /epub-config/@format, 'EPUB3')[1]

letex:simple-progress-msg start-msg

source

source on epub-convert

msgs

 <c:messages>
   <c:message xml:lang="en">Starting EPUB generation</c:message>
   <c:message xml:lang="de">Beginne EPUB-Erzeugung</c:message>
 </c:messages>

result

file = 'epub-convert-start.txt'

status-dir-uri = $status-dir-uri

transpect:file-uri base-uri

The output files are stored relative to the base-uri of the document on the primary input port.

source

result on start-msg

result

filename = (base-uri(/*), static-base-uri())[1]

epub:create-ocf create-ocf

meta

meta on epub-convert

result

base-uri = /c:result/@local-href

debug = $debug

debug-dir-uri = $debug-dir-uri

epub:create-ops create-ops

source

source on epub-convert

conf

conf on epub-convert

meta

meta on epub-convert

result

base-uri = /c:result/@local-href

target = $target-format

use-svg = $wrap-cover-in-svg

terminate-on-error = $terminate-on-error

debug = $debug

debug-dir-uri = $debug-dir-uri

epub:create-opf create-opf

source

files on create-ops

result on create-ops

meta

meta on epub-convert

result

base-uri = /c:result/@local-href

target = $target-format

terminate-on-error = $terminate-on-error

use-svg = $wrap-cover-in-svg

debug = $debug

debug-dir-uri = $debug-dir-uri

p:sink d69e206

source

result on create-opf

p:choose conditionally-remove-nav-document-if-epub2

$target-format = 'EPUB2'

p:delete discard-epub2-nav-html

nav.xhtml is only carried along for creating the guide element in EPUB2

source

files on create-ops

result

match = '/*/c:file[matches(@name, 'nav\.xhtml$')]'

p:otherwise

p:identity d69e229

source

files on create-ops

result

p:sink d69e238

source

epub:zip-package zip-package

ocf-filerefs

files on create-ocf

ops-filerefs

result on conditionally-remove-nav-document-if-epub2

opf-fileref

files on create-opf

result

base-uri = /c:result/@local-href

debug = $debug

debug-dir-uri = $debug-dir-uri

letex:simple-progress-msg success-msg

source

result on zip-package

msgs

 <c:messages>
   <c:message xml:lang="en">EPUB generation finished (see the HTML report though – errors will be reported there)</c:message>
   <c:message xml:lang="de">EPUB-Erzeugung abgeschlossen (bitte im HTML-Report nachsehen, ob fehlerfrei)</c:message>
 </c:messages>

result

file = 'epub-convert-success.txt'

status-dir-uri = $status-dir-uri

p:sink d69e287

source

result on success-msg