Difference between revisions of "Epub"
(→Mtxrun) |
|||
Line 42: | Line 42: | ||
You are free to choose keys. Metadata is flushed as child of the next element. | You are free to choose keys. Metadata is flushed as child of the next element. | ||
− | == | + | == the example file == |
− | It is also possible to hook css into the output, see thread: [http://www.ntg.nl/pipermail/ntg-context/2011/058907.html ntg-context]. | + | It is also possible to hook css into the output, see thread: [http://www.ntg.nl/pipermail/ntg-context/2011/058907.html ntg-context]. The distribution has a test file <code>export-example.tex</code>. This file exports conforming: |
− | + | <texcode> | |
+ | \setupbackend | ||
+ | [export=export-example.xml, | ||
+ | xhtml=export-example.xhtml, | ||
+ | css=export-example.css] | ||
+ | </texcode> | ||
+ | |||
+ | This file shows some of the possibilities. You will notice that it is a rather normal context file. When the file is processed, you can create an epub file with: | ||
<texcode> | <texcode> | ||
− | + | mtxrun --script epub export-example | |
− | |||
− | |||
− | |||
</texcode> | </texcode> | ||
+ | |||
+ | == additional tagging == | ||
You can mark sections that don't need to be exported: | You can mark sections that don't need to be exported: |
Revision as of 15:01, 17 June 2011
ConTeXt has preliminary epub support starting from current 2011.05.18.
In order to make an epub (archive) from your ConTeXt source files, you need to:
- enable the export backend in your
.tex
file or environment file (see Project structure) - call the appropriate
mtxrun
command (with the epub script) shown in the output of a context run or in the log file
Note: There is no support for graphics yet, that will be included in a later version.
Contents
Export
To enable the export backend, depending on your needs, one of the following lines has to be included at the beginning of the document (before \starttext).
\setupbackend[export=yes] \setupbackend[export=yes,xhtml=yes] \setupbackend[export=yes,xhtml=whatever.xhtml] \setupbackend[export=yes,css={whatever.css,somemore.css}]
The backend can export into:
- xml
- xhtml
- xhtml+css
For making an epub, you need an xhtml export.
When using a css file, images are supported using an extra css file *-images.css
. Images with suffix pdf
are remapped to svg
but png
and jpg
are passed on.
You can add metadata using the following command:
\settaggedmetadata [title=My Document, author=By Me, version=1.0]
You are free to choose keys. Metadata is flushed as child of the next element.
the example file
It is also possible to hook css into the output, see thread: ntg-context. The distribution has a test file export-example.tex
. This file exports conforming:
\setupbackend [export=export-example.xml, xhtml=export-example.xhtml, css=export-example.css]
This file shows some of the possibilities. You will notice that it is a rather normal context file. When the file is processed, you can create an epub file with:
mtxrun --script epub export-example
additional tagging
You can mark sections that don't need to be exported:
\startelement[ignore] titlepage makeup \stopelement
You can also add data:
\settaggedmetadata[name=Me] \startchapter[title=...] .... \stopchapter
In this case the data will be injected just after the start of the chapter tag. So, if you want to have document level metadata, you need to put the set command before \starttext.
Mtxrun
The actual generation of the epub can be triggered with the mtxrun
command shown in the output.
Example log entry:
... backend > export > saving xml data in 'oeps.export backend > export > saving css template in 'oeps.template backend > export > saving xhtml variant in 'oeps.xhtml backend > export > saving specification in 'oeps.specification' (mtxrun --script epub --make oeps.specification) ...
The "oeps" will be replaced with the appropriate name given to the export backend.
Therefore, execute:
mtxrun --script epub --make oeps.specification
This will create an oeps.tree folder with an oeps.epub inside it. When pdf images are used and no suitable svg alternative is present inkscape will be used to create the svg file.
More on this on the mailing list, thread starts at: ntg-context.
Minimal Example
\setupbackend[export=yes,xhtml=test.xhtml] \starttext Hello world! \stoptext
Tools
Viewer:
- calibre
- EPUBReader for Firefox (also does mathml)
- FBReader
- Adobe Digital Editions
Online:
Editor:
Validation:
Specification:
Current Issues
As of 08:41, 16 June 2011 (CEST):
tool | description | error |
mtx-epub.lua |
OPF 2.0.1 | amazoncover, bookid, id & ncx fix |
epubcheck-1.2 | OPS 2.0.1 | test.xhtml : <document> elements from namespace "" are not allowed xhtml DOCTYPE missing, html + body elements |
epubreader | OPS 2.0.1 | This XML file does not appear to have any style information associated with it. |
kindlegen | OPS 2.0.1 | No BODY tag found in content file. |
feature | description |
metadata | add author and title to local:package and local:navigation (mtx-epub.lua) |
cover | add cover element, 600×800 (min. 500) for amazon |
toc | table of contents is missing |
chapter break | new title element → new xhtml |