Difference between revisions of "Epub"

From Wiki
Jump to navigation Jump to search
Line 97: Line 97:
 
== Current Issues ==
 
== Current Issues ==
  
As of 11:01, 29 May 2011 (CEST):
+
As of 22:28, 7 June 2011 (CEST):
  
 
<table>
 
<table>
Line 106: Line 106:
 
</tr>
 
</tr>
 
         <tr>
 
         <tr>
              <td>epubcheck-1.2</td>
 
 
               <td><code>mtx-epub.lua</code></td>
 
               <td><code>mtx-epub.lua</code></td>
 +
              <td>OPF 2.0.1</td>
 
               <td><code>local id        = specification.id        or "BookId"</code><br /><code>package  = format(package,id,id,concat(used,"\n"),file.removesuffix(root))</code></td>
 
               <td><code>local id        = specification.id        or "BookId"</code><br /><code>package  = format(package,id,id,concat(used,"\n"),file.removesuffix(root))</code></td>
 
         </tr>
 
         </tr>
 
         <tr>
 
         <tr>
 
               <td>epubcheck-1.2</td>
 
               <td>epubcheck-1.2</td>
               <td><code>test.opf</code>:<br /><code><spine toc="ncx"></code></td>
+
              <td>OPF 2.0.1</td>
              <td>item with id 'ncx' not found</td>
+
               <td><code>test.opf</code>: <code><spine toc="ncx"></code><br />item with id 'ncx' not found</td>
 
         </tr>
 
         </tr>
 
         <tr>
 
         <tr>

Revision as of 20:30, 7 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:

  1. enable the export backend in your .tex file or environment file (see Project structure)
  2. 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.

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.

cld-mkvi

It is also possible to hook css into the output, see thread: ntg-context.

Example:

\setupbackend
   [export=cld-mkiv-export.xml,
    xhtml=cld-mkiv-export.xhtml,
    css={cld-mkiv-export.css,mathml.css}]

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.


More on this on the mailing list, thread starts at: ntg-context.

Example

\setupbackend[export=yes,xhtml=test.xhtml]
\starttext
Hello world!
\stoptext

Tools

Viewer:

Editor:

Validation:

Specification:

Current Issues

As of 22:28, 7 June 2011 (CEST):

tool description error
mtx-epub.lua OPF 2.0.1 local id = specification.id or "BookId"
package = format(package,id,id,concat(used,"\n"),file.removesuffix(root))
epubcheck-1.2 OPF 2.0.1 test.opf: <spine toc="ncx">
item with id 'ncx' not found
epubcheck-1.2 test.xhtml:
<document>
elements from namespace "" are not allowed
xhtml DOCTYPE missing, html + body elements
epubreader test.epub This XML file does not appear to have any style information associated with it.
kindlegen back-exp.lua No BODY tag found in content file.
kindlegen test.opf Cover not specified, amazon


feature description
id field sort out id name from specs, xhtml name, 3.0 draft, uuid
used[#used+1] = format("<item id=\"%s\" href=\"%s\" media-type=\"%s\"/>",idmaker(filename),filename,mime)
cover add cover element
toc table of contents is missing
chapter break new title element → new xhtml
ncx file add dummy ncx file?
graphics include graphics