{{todo|Beware, this doesn’t fit the current export files and ePub workflow as of January 2015!}} < [[Epub]]| [[XML]] | [[Export]] | [[ePub|New ePub docs]]>
Creating an ebook with ConTeXt is still tedious and needs a lot of manual work - that will not change, since everyone has other needs, uses different structures etc.
Here I’ll show you my workflow for creating ebooks of my songbooklets (that use [[LilyPond]] via [http[modules://modules.contextgarden.net/t-filter |filter module]] for the notes).
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.
Beware, you need a current beta version of ConTeXt, since Hans fixed some export related bugs in the last few days! --[[User:Hraban|Hraban]] 27 August 13 September 2014.
== ConTeXt setup ==
<texcode>
\setupexport[ hyphen=yes,
%firstpage={cover.jpg}, % is ignored
title={Songbook},
\settaggedmetadata[
% here you can set as many metadata entries as you like
%firstpage={cover.jpg}, % is ignored
title={Songbook},
name=ebook, % this becomes the name of the output directory
author={Hraban}] \definehighlight[emph][style=italic] % use \emph{something} instead of {\em something}
</texcode>
Make sure to tag all your structural elements with {{cmd|start...}}-{{cmd|stop...}}, e.g. {{cmd|startchapter}}, but even {{cmd|startparagraph}}!
In places where {{cmd|startparagraph}} does not work, such as itemizations, where it causes a blank line after the bullet and before the item text, use {{cmd|bpar}} (and closing {{cmd|epar}}) to tag paragraphs.
Then you can call ConTeXt and its ePub script:
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|<document>}} is missing. Just put it in manually (after the comment lines). You can also move the {{code|<metadata>}} block out of the first structure, but that’s merely a cosmetical error.
<xsl:variable name="within-paragraph">0</xsl:variable ><!-- statusxsl: are we variable name="within a paragraph? -section">0</xsl:variable ><xsl:variable name="previous-section">0</xsl:variable >
This The [http://www.idpf.org/epub/20/spec/OPF_2.0.1_draft.htm OPF file ] keeps the others together, it lists all resources of the ebook. You will have to adapt the listing of images (since I use only PDFs converted to PNG) and add fonts manually, if you ship any.