Changes

Jump to navigation Jump to search
2,719 bytes added ,  13:24, 9 August 2020
m
Text replacement - "</cmd>" to "}}"
{{todo|Beware, this doesn’t fit the current state of export files as of January 2015!}} < [[Export]] | [[ePub|New ePub docs]] > == Minimal example == A minimal example file would be: <texcode>\setupbackend[export=yes,xhtml=yes] \mainlanguage[de]\language[de] \setupexport [title={A nice book}, author={John Doe}, firstpage={huhn.jpg}, ] \starttextHello world!\stoptext</texcode> Please note, that a cover image is part of a valid epub file, therefore you should provide one even in the most minimal case. It is called huhn.jpg in this case. Make sure it is in the same directory as you tex file. Now you have to call the script to produce the epub <texcode>mtxrun --script epub --make test_00.specification</texcode> assuming that the minimal example tex file is called test_00.tex == More information == ConTeXt has preliminary [http://en.wikipedia.org/wiki/EPUB epub] support starting from [[Context 2011.05.18 | current 2011.05.18]].Some problems were fixed end of August 2014, don’t use an older version!
'''Note:''' There is no support for graphics yet, that will be included in a later version.
 
'''There’s also a more extensive [[Epub Sample|example]].'''
== 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 <{{cmd>|starttext</cmd>}}).
<texcode>
\setupbackend[export=yes]
\setupbackend[export=yes,xhtml=yes]
\setupbackend[export=yes,xhtml=whatever.xhtml]
* xhtml+css
''For making an epub, you need an xhtml export.''
 
If you are unsure, which one of the three backend options you should use, use the minimal one:
 
<texcode>
\setupbackend[export=yes,xhtml=yes]
</texcode>
''For making an epubWhen using a css file, you need images are supported using an xhtml exportextra css file <code>*-images.css</code>. Images with suffix <code>pdf</code> are remapped to <code>svg</code> but <code>png</code> and <code>jpg</code> are passed on.'' You can add metadata using the following command:
<texcode>\setupexport [title={A nice book}, author= cld-mkvi ={John Doe}, firstpage={huhn.jpg}, ]</texcode>
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 example file ==
ExampleYou can also 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=cld-mkivexport-exportexample.xml, xhtml=cld-mkivexport-exportexample.xhtml, css={cldexport-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>mtxrun --script epub -mkiv-make export-example</texcode> == Additional tagging ==  You can mark sections that don't need to be exported:  <texcode>\startelement[ignore]  titlepage makeup  \stopelement</texcode> You can also add data:  <texcode>\settaggedmetadata[name=Me] \startchapter[title=..css,mathml.css}] ....\stopchapter
</texcode>
 
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 {{cmd|starttext}}.
 
== Document styling ==
 
Some style elements are exported to an additional css file and a reference to that file is automatically added. You can exercise some control over the general document rendering:
 
<texcode>
\setupexport
[bodyfont=12pt,
width=600pt,
%align=flushleft,
hyphen=yes]
</texcode>
 
The last option makes sure that the export has enough information to do a reasonable hyohenation. Future versions of the exported might provide some more control.
== Mtxrun ==
The actual generation of the epub can be triggered with the <code>mtxrun</code> command shown in the output.
 
Example log entry:
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: [http://www.ntg.nl/pipermail/ntg-context/2011/058996.html ntg-context].
 
== Example ==
 
<texcode>
\setupbackend[export=yes,xhtml=test.xhtml]
\starttext
Hello world!
\stoptext
</texcode>
== Tools ==
Viewer:
* [http://calibre-ebook.com/ calibre]
* [http://www.epubread.com/ EPUBReader for Firefox](also does mathml)
* [http://www.fbreader.org/ FBReader]
* ''[http://www.adobe.com/products/digitaleditions/ Adobe Digital Editions]''
 
Online:
* [http://bookworm.oreilly.com/ bookworm]
Editor:
Specification:
* [http://idpf.org/epub epub2/3]
== Current Issues ==
As of 2208:2841, 7 16 June 2011 (CEST):
<table>
</tr>
<tr>
<td><code>mtx-epub.lua</code><[https:/td> <td>OPF 2.0.1</td> <td><code>local id = specificationgist.id or "BookId"</code><br /><code>package = format(package,id,id,concat(used,"\n"),filegithub.removesuffix(root))</code></td> <com/tr> <tr> <td><code>1013262 mtx-epub.lua]</code></td>
<td>OPF 2.0.1</td>
<td>[https://gist.github.com/1013262 amazoncover, bookid, id & ncx fix]</td>
</tr>
<tr>
<tdstyle="border-top: 1px solid black">epubcheck-1.2</td> <tdstyle="border-top: 1px solid black">OPS 2.0.1</td> <td style="border-top: 1px solid black"><code>test.xhtml</code>:<br /><code><document></code><br /td> <td>elements from namespace "" are not allowed<br />xhtml DOCTYPE missing, html + body elements</td>
</tr>
<tr>
<td>epubreader</td>
<td><code>testOPS 2.epub</code>0.1</td>
<td>This XML file does not appear to have any style information associated with it.</td>
</tr>
<tr>
<td>kindlegen</td>
<td><code>back-expOPS 2.lua</code>0.1</td>
<td>No BODY tag found in content file.</td>
</tr>
<tr>
<td>kindlegen</td>
<td><code>test.opf</code></td>
<td>Cover not specified, [http://s3.amazonaws.com/kindlegen/AmazonKindlePublishingGuidelinesV1.3.pdf amazon]</td>
</tr>
</table>
</tr>
<tr>
<td>id fieldmetadata</td> <td>sort out id name from specs, [httpadd author and title to local://code.google.com/p/epubcheck/wiki/Errors xhtml name], [httppackage and local://idpf.org/navigation (mtx-epub/30/spec/epub30-ocf.html 3.0 draft], uuid<br />used[#used+1] = format("<item id=\"%s\" href=\"%s\" media-type=\"%s\"/>",idmaker(filename),filename,mimelua)</td>
</tr>
<tr>
<td>cover</td>
<td>add [http://code.google.com/p/epubcheck/issues/detail?id=74 cover element], 600×800 (min. 500) for amazon</td>
</tr>
<tr>
<td>chapter break</td>
<td>new title element → new xhtml</td>
</tr>
<tr>
<td>ncx file</td>
<td>add dummy ncx file?</td>
</tr>
<tr>
<td>graphics</td>
<td>include graphics</td>
</tr>
</table>
 
== Latest news ==
 
(This section is to be integrated in the instructions above.)
 
Now
<texcode>
\setupbackend
[export=yes,
xhtml=yes,
css=export-example.css]
</texcode>
also exports an html file with all tags being 'div' and the default css has been adapted to support both. The default css still need some work because not all browsers handle these div expressions equally well. The idea is to have a decent looking default as template (one can always overload).
 
--Hans 27 August 2014
 
The problem with an invalid export.xml when using project structure is also fixed since 27 August 2014.

Navigation menu