<p:declare-stepxmlns:p="http://www.w3.org/ns/xproc"xmlns:px="http://www.daisy.org/ns/pipeline/xproc"xmlns:c="http://www.w3.org/ns/xproc-step"xmlns:pef="http://www.daisy.org/ns/2008/pef"xmlns:ocf="urn:oasis:names:tc:opendocument:xmlns:container"xmlns:dc="http://purl.org/dc/elements/1.1/"xmlns:opf="http://www.idpf.org/2007/opf"type="px:epub3-to-pef.script"version="1.0"exclude-inline-prefixes="#all"name="main">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h1px:role="name">EPUB 3 to braille</h1><ppx:role="desc"xml:space="preserve">Transforms a EPUB 3 publication into an embosser ready braille document.</p>
<apx:role="homepage"href="http://daisy.github.io/pipeline/Get-Help/User-Guide/Scripts/epub3-to-pef/">
Online documentation
</a>
</p:documentation>
<p:optionname="source"required="true"px:type="anyFileURI"px:sequence="false"px:media-type="application/epub+zip application/oebps-package+xml">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Input EPUB 3</h2><ppx:role="desc"xml:space="preserve">The EPUB you want to convert to braille.
You may alternatively use the EPUB package document (the OPF-file) if your input is a unzipped/"exploded" version of an EPUB.</p>
</p:documentation>
</p:option><p:optionname="preamble"required="false"select="''"px:type="anyFileURI"px:sequence="false"px:media-type="application/xhtml+xml text/html">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Preamble HTML</h2><ppx:role="desc">An HTML file to be prepended to the EPUB spine.</p>
</p:documentation>
</p:option><p:outputport="validation-status"px:media-type="application/vnd.pipeline.status+xml">
<p:pipestep="convert"port="status"/>
</p:output><p:optionname="stylesheet"required="false"px:type="anyURI"select="''"px:sequence="true"px:separator=" "px:media-type="text/css text/x-scss application/xslt+xml">
<p:documentationxmlns="http://www.w3.org/1999/xhtml"><h2px:role="name">Style sheets</h2><ppx:role="desc"xml:space="preserve">A list of CSS/Sass style sheets to take into account.
Must be a space separated list of URIs, absolute or relative to the input.
Style sheets specified through this option are called "[user style
sheets](https://www.w3.org/TR/CSS2/cascade.html#cascade)". Style sheets can also be attached to the
source document. These are referred to as "[author style
sheets](https://www.w3.org/TR/CSS2/cascade.html#cascade)". They can be linked (using an
['xml-stylesheet' processing instruction](https://www.w3.org/TR/xml-stylesheet) or a ['link'
element](https://www.w3.org/Style/styling-XML#External)), embedded (using a ['style'
element](https://www.w3.org/Style/styling-XML#Embedded)) and/or inlined (using '[style'
attributes](https://www.w3.org/TR/css-style-attr/)). Only author styles that apply to "embossed"
media are taken into account.
All style sheets are applied at once, but the order in which they are specified has an influence on
the [cascading order](https://www.w3.org/TR/CSS2/cascade.html#cascading-order). Author styles take
precedence over user styles.
Style sheets are interpreted according to [braille
CSS](http://braillespecs.github.io/braille-css) rules.
For info on how to use Sass (Syntactically Awesome StyleSheets) see the [Sass
manual](http://sass-lang.com/documentation/file.SASS_REFERENCE.html).
A number of [partials](https://sass-lang.com/documentation/at-rules/import#partials) (helper style
sheet modules) are available for use in Sass style sheets:
- [http://www.daisy.org/pipeline/modules/braille/html-to-pef/_generate-toc.scss](http://daisy.github.io/pipeline/modules/braille/html-to-pef/src/main/resources/css/_generate-toc.scss/):
for generating a table of content
- [http://www.daisy.org/pipeline/modules/braille/html-to-pef/_tables.scss](http://daisy.github.io/pipeline/modules/braille/html-to-pef/src/main/resources/css/tables):
for styling tables
- [http://www.daisy.org/pipeline/modules/braille/html-to-pef/_definition-lists.scss](http://daisy.github.io/pipeline/modules/braille/html-to-pef/src/main/resources/css/definition-lists):
for styling definition lists
- [http://www.daisy.org/pipeline/modules/braille/html-to-pef/_legacy.scss](http://daisy.github.io/pipeline/modules/braille/html-to-pef/src/main/resources/css/_legacy.scss/):
collection of styles that used to be included by default
</p>
</p:documentation>
</p:option><p:optionname="apply-document-specific-stylesheets"px:type="boolean"select="'false'">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Apply document-specific CSS</h2><ppx:role="desc"xml:space="preserve">If this option is enabled, any pre-existing CSS in the EPUB with media "embossed" (or "all") will be used.
The input EPUB may already contain CSS that applies to embossed media. Such document-specific CSS
takes precedence over any CSS attached when running this script.
For instance, if the EPUB already contains the rule `p { padding-left: 2; }`,
and using this script the rule `p#docauthor { padding-left: 4; }` is provided, then the
`padding-left` property will get the value `2` because that's what was defined in the EPUB,
even though the provided CSS is more specific.
</p>
</p:documentation>
</p:option><p:optionname="stylesheet-parameters"required="false"px:type="stylesheet-parameters"select="'()'"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Style sheet parameters</h2><ppx:role="desc"xml:space="preserve">A list of parameters passed to the style sheets.
Style sheets, whether they're user style sheets (specified with the "stylesheet" option) or author
style sheets (associated with the source), may have parameters (Sass variables). The
"stylesheet-parameters" option, which takes a comma-separated list of key-value pairs enclosed in
parenthesis, can be used to set these variables.
For example, if a style sheet uses the Sass variable "foo":
~~~sass
@if $foo {
/* some style that should only be enabled when "foo" is truthy */
}
~~~
you can control that variable with the following parameters list: `(foo:true)`.</p>
</p:documentation></p:option><p:optionname="braille-code"px:type="liblouis-table-query"required="false"select="''"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Braille code</h2><ppx:role="desc"xml:space="preserve">Braille code to be used for braille transcription.
If set, [braille transcription](http://daisy.github.io/pipeline/Get-Help/User-Guide/Braille/) is
done using the selected braille code. If left empty, the braille code is determined by the document
language. Note that braille transcription can also be controlled through CSS `@text-transform`
rules.</p>
</p:documentation></p:option><p:optionname="transform"required="false"px:type="transform-query"select="'(translator:liblouis)(formatter:dotify)'"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Transformer features</h2><ppx:role="desc"xml:space="preserve">Features of the braille transformer.
Features of the [braille transformer](http://daisy.github.io/pipeline/Get-Help/User-Guide/Braille/)
to be used for creating the paginated braille document from the CSS styled input document. Together
with the "Braille code" option this determines the transformer that is selected.</p>
</p:documentation></p:option><p:optionname="include-preview"required="false"px:type="boolean"select="'false'"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Include preview</h2><ppx:role="desc"xml:space="preserve">Whether or not to include a HTML preview of the braille result.</p>
</p:documentation></p:option><p:optionname="include-pef"required="false"px:type="boolean"select="'false'"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Include PEF</h2><ppx:role="desc"xml:space="preserve">Whether or not to keep the intermediary PEF file (for debugging).</p>
</p:documentation></p:option><p:optionname="include-obfl"required="false"px:type="boolean"select="'false'"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Include OBFL</h2><ppx:role="desc"xml:space="preserve">Whether or not the keep the intermediary OBFL file (for debugging).</p>
</p:documentation></p:option><p:optionname="output-file-format"required="false"px:type="transform-query"select="''"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Output file format</h2><ppx:role="desc"xml:space="preserve">The file format in which to store the braille result.
The file format must be expressed as a list of parenthesis enclosed key-value pairs. For example, to
select a file format suited for the U.S., set the option to `(locale:en-US)`. To use the braille
character set used in the Netherlands and store to a file with extension ".brl", set the option to
`(locale:nl)(file-extension:'.brl')`.
If left blank, the braille will be stored in PEF format.</p>
</p:documentation></p:option><p:optionname="preview-table"required="false"px:type="preview-table"select="''"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">ASCII braille table for HTML preview</h2><ppx:role="desc"xml:space="preserve">The ASCII braille table used to render the HTML and PDF previews.
If left blank, the locale information in the input document will be used to select a suitable table.</p>
</p:documentation></p:option><p:optionname="page-width"required="false"px:type="integer"select="'40'"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Page width</h2><ppx:role="desc"xml:space="preserve">The number of columns available for printing.
Sets the default page width (this can be overwritten with `@page` rules) and affects media queries
that use the 'width' feature. The variable `$page-width` is available in Sass style sheets.
See the CSS specification for more info:
- the [`@page`](http://braillespecs.github.io/braille-css/#h4_the-page-rule) rule
- the [`size`](http://braillespecs.github.io/braille-css/#the-size-property) property
- the [page dimensions media features](https://www.w3.org/TR/mediaqueries-4/#mf-dimensions)
</p>
</p:documentation></p:option><p:optionname="page-height"required="false"px:type="integer"select="'25'"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Page height</h2><ppx:role="desc"xml:space="preserve">The number of rows available for printing.
Sets the default page height (this can be overwritten with `@page` rules) and affects media queries
that use the 'height' feature. The variable `$page-height` is available in Sass style sheets.
See the CSS specification for more info:
- the [`@page`](http://braillespecs.github.io/braille-css/#h4_the-page-rule) rule
- the [`size`](http://braillespecs.github.io/braille-css/#the-size-property) property
- the [page dimensions media features](https://www.w3.org/TR/mediaqueries-4/#mf-dimensions)
</p>
</p:documentation></p:option><p:optionname="duplex"required="false"px:type="boolean"select="'true'"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Duplex</h2><ppx:role="desc"xml:space="preserve">When enabled, will print on both sides of the paper.</p>
</p:documentation></p:option><p:optionname="hyphenation-at-page-breaks"required="false"select="'false'"><p:pipeinfo><px:type>
<choicexmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">
<value>false</value>
<a:documentationxml:lang="en">Never hyphenate words at page boundaries</a:documentation>
<value>except-at-volume-breaks</value>
<a:documentationxml:lang="en">Allow hyphenation at page boundaries except when it's a volume boundary</a:documentation>
<value>true</value>
<a:documentationxml:lang="en">Allow hyphenation at page boundaries</a:documentation>
</choice>
</px:type></p:pipeinfo><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Hyphenation at page boundaries</h2><ppx:role="desc"xml:space="preserve">Whether hyphenation of words at page boundaries is allowed or not.
This option only determines whether hyphenation is allowed at page boundaries. The "Hyphenation"
option and the CSS determine how the hyphenation is done, when allowed.
</p>
</p:documentation></p:option><p:optionname="allow-text-overflow-trimming"px:type="boolean"required="false"select="'false'"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Trimming of overflowing text</h2><ppx:role="desc"xml:space="preserve">Allow trimming of overflowing text.
By default, text that overflows its containing box will result in an error. By selecting this
option, overflowing text will be truncated and generate a warning instead whenever
possible. Notably, this will happen with text within page margins (top, right, bottom and left) that
is too long to fit the space.
</p>
</p:documentation></p:option><p:optionname="result"required="true"px:output="result"px:type="anyDirURI"px:media-type="text"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Output file</h2><ppx:role="desc">The output braille file.</p>
</p:documentation></p:option><p:optionname="pef"required="false"px:output="result"px:type="anyDirURI"px:media-type="application/x-pef+xml"select="''"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">PEF</h2><ppx:role="desc">The intermediary PEF file.</p>
</p:documentation></p:option><p:optionname="preview"required="false"px:output="result"px:type="anyDirURI"px:media-type="text/html"select="''"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Preview</h2><ppx:role="desc">An HTML preview of the braille result.</p>
</p:documentation></p:option><p:optionname="obfl"required="false"px:output="result"px:type="anyDirURI"px:media-type="application/x-obfl+xml"select="''"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">OBFL</h2><ppx:role="desc">The intermediary OBFL file.</p>
</p:documentation></p:option>
<p:importhref="http://www.daisy.org/pipeline/modules/braille/epub3-to-pef/library.xpl">
<p:documentation>
px:epub3-to-pef.load
px:epub3-to-pef
px:epub3-to-pef.store
</p:documentation>
</p:import>
<p:importhref="http://www.daisy.org/pipeline/modules/braille/common-utils/library.xpl">
<p:documentation>
px:delete-parameters
</p:documentation>
</p:import>
<p:importhref="http://www.daisy.org/pipeline/modules/fileset-utils/library.xpl">
<p:documentation>
px:fileset-load
</p:documentation>
</p:import>
<p:in-scope-namesname="in-scope-names"/>
<px:delete-parametersname="input-options"px:message="Collecting parameters"px:progress=".01"parameter-names="epub preamble stylesheet stylesheet-parameters apply-document-specific-stylesheets transform braille-code output-file-format include-pef include-preview include-obfl result pef preview obfl temp-dir">
<p:inputport="source">
<p:pipeport="result"step="in-scope-names"/>
</p:input>
</px:delete-parameters>
<p:sink/>
<px:epub3-to-pef.loadname="load"px:message="Loading EPUB"px:progress=".04">
<p:with-optionname="epub"select="$source"/>
<p:with-optionname="preamble"select="$preamble"/>
<p:with-optionname="temp-dir"select="concat($temp-dir,'load/')"/>
</px:epub3-to-pef.load>
<px:fileset-loadname="opf"media-types="application/oebps-package+xml">
<p:inputport="in-memory">
<p:pipestep="load"port="in-memory.out"/>
</p:input>
</px:fileset-load>
<p:sink/>
<p:identity>
<p:inputport="source">
<p:pipeport="fileset.out"step="load"/>
</p:input>
</p:identity>
<px:epub3-to-pefname="convert"px:message="Converting from EPUB to PEF"px:progress=".90">
<p:with-optionname="epub"select="$source"/>
<p:inputport="in-memory.in">
<p:pipeport="in-memory.out"step="load"/>
</p:input>
<p:with-optionname="temp-dir"select="concat($temp-dir,'convert/')"/>
<p:with-optionname="stylesheet"select="$stylesheet"/>
<p:with-optionname="stylesheet-parameters"select="$stylesheet-parameters"/>
<p:with-optionname="apply-document-specific-stylesheets"select="$apply-document-specific-stylesheets"/>
<p:with-optionname="transform"select="concat($braille-code,($transform,'(translator:liblouis)(formatter:dotify)')[not(.='')][1])"/>
<p:with-optionname="include-obfl"select="$include-obfl"/>
<p:inputport="parameters">
<p:pipeport="result"step="input-options"/>
</p:input>
</px:epub3-to-pef>
<p:sink/>
<p:identity>
<p:inputport="source">
<p:pipestep="convert"port="in-memory.out"/>
</p:input>
</p:identity>
<p:deletematch="/*/@xml:base"/>
<px:epub3-to-pef.storepx:message="Storing results"px:progress=".05">
<p:with-optionname="epub"select="$source"/>
<p:inputport="opf">
<p:pipestep="opf"port="result"/>
</p:input>
<p:inputport="obfl">
<p:pipestep="convert"port="obfl"/>
</p:input>
<p:with-optionname="include-pef"select="$include-pef"/>
<p:with-optionname="include-preview"select="$include-preview"/>
<p:with-optionname="output-file-format"select="$output-file-format"/>
<p:with-optionname="preview-table"select="$preview-table"/>
<p:with-optionname="output-dir"select="$result"/>
<p:with-optionname="pef-output-dir"select="$pef"/>
<p:with-optionname="preview-output-dir"select="$preview"/>
<p:with-optionname="obfl-output-dir"select="$obfl"/>
</px:epub3-to-pef.store>
</p:declare-step>