Changes

Jump to navigation Jump to search
729 bytes added ,  08:21, 27 August 2014
fix markup
I’m using ConTeXt’s [[Project structure]], separating content in products (for me: single booklets) and components (for me: single songs) with a common stylesheet (environment).
Unfortunately, ConTeXt has a bug in XML creation in this setup.
 
--[[User:Hraban|Hraban]] 10:19, 27 August 2014 (CEST)
== ConTeXt setup ==
</texcode>
Make sure to tag all your structural elements with <{{cmd>|start...</cmd>}}-<{{cmd>|stop...</cmd>}}, e.g. <{{cmd>|startchapter</cmd>}}, but even <{{cmd>|startparagraph</cmd>}}!
Then you can call ConTeXt and its ePub script:
</code>
The first creates {{code|export.xml }} and a bunch of other files.The second creates a directory "{{code|ebook.tree" }} with the proper structure for ePub. The ePub file in the tree directory is unusable.
We’ll mostly work with "export.xml" that contains all your content (check that, you’ll miss everything that was not properly tagged).
== Fix export.xml ==
If you run the epub script on a single file, you’ll get a well-formed and usable export.xml. If you use a project structure, the root node <{{code>|&lt;document&gt;</code> }} is missing. Just put it in manually (after the comment lines). You can also move the <{{code>|&lt;metadata&gt;</code> }} block out of the first structure, but that’s merely a cosmetical error.
A proper {{code|export.xml }} starts like this:
<codexmlcode>
&lt;?xml version="1.0" encoding="UTF-8" standalone="yes" ?&gt;
&lt;!-- input filename : solo --&gt;>&lt;!-- processing date : Wed Aug 27 13:47:46 2014 --&gt;>&lt;!-- context version : 2014.08.21 09:56 --&gt;>&lt;!-- exporter version : 0.31 --&gt;>
&lt;document language="en" file="solo" date="Wed Aug 27 13:47:46 2014" context="2014.08.21 09:56" version="0.31" xmlns:m="http://www.w3.org/1998/Math/MathML"&gt;
<section detail="chapter" location="aut:1">
...
</codexmlcode>
You don’t need the attributes of the document node, even if we could use the language setting.
Even if the ePub format is supposed to work with any XML, most readers only accept HTML.
I use the free version of [[http://saxon.sourceforge.net Saxon]] and some XSL transformations for the conversion.
The incantation goes like <{{code>|saxon -o:content.xhtml -s:export.xml -xsl:export2html.xsl</code>}}.I installed Saxon on my Mac with MacPorts, then instead of just "saxon" you must call <{{code>|java -jar /opt/local/share/java/saxon9he.jar</code>}}.
This is my **{{code|export2html.xsl**}}:
<codexmlcode>
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version= "2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
h5 = subsection
-->
</xmlcode> Now you have a (hopefully usable) (X)HTML file, you need a {{code|style.css}} for the styling. A simple example: <pre>body { font-family: TeX Gyre Schola, Century Schoolbook, serif; font-size: 12pt; margin: 0 auto; max-width: 40em; line-height: 1.44; -webkit-hyphens: auto; -moz-hyphens: auto; -ms-hyphens: auto; hyphens: auto;} h1, h2, h3, h4, h4, h6 { font-family: Devroye; color: #286000; -webkit-hyphens: manual; -moz-hyphens: manual; -ms-hyphens: manual; hyphens: manual;} .part { page-break-before: always;} .chapter { margin-top: 1em; border-top: 1px solid #600a00;} .lilypond { margin: 1em 0;} .lilypond img { width: 100%;}</pre>

Navigation menu