ConTeXt allows for export to xml (and xhtml). With a small wrapper script, it should be possible to convert the output to epub. For example, consider a simple TeX file that inputs another file and has some math in it:
\setupbackend[export=yes]
\starttext
\section {The first section}
\input tufte
\startformula
f(x) = \frac 1n \log \Pr(y^n > x)
\stopformula
\stoptext
Processing it through ConTeXt creates a file \jobname.export
as follows
<?xml version='1.0' standalone='yes' ?>
<!-- input filename : test -->
<!-- processing date : Fri May 6 23:20:25 2011 -->
<!-- context version : 2011.05.06 16:52 -->
<!-- exporter version : 0.20 -->
<document language="en" file="test" date="Fri May 6 23:20:25 2011" context="2011.05.06 16:52" version="0.20" xmlns:m="http://www.w3.org/1998/Math/MathML">
<section detail='section' location='aut:1'>
<sectionnumber>1</sectionnumber>
<sectiontitle>The first section</sectiontitle>
<sectioncontent>
We thrive in information--thick worlds because of our marvelous and everyday capacity to select, edit, single out, structure, highlight, group, pair, merge, harmonize, synthesize, focus, organize, condense, reduce, boil down, choose, categorize, catalog, classify, list, abstract, scan, look into, idealize, isolate, discriminate, distinguish, screen, pigeonhole, pick over, sort, integrate, blend, inspect, filter, lump, skip, smooth, chunk, average, approximate, cluster, aggregate, outline, summarize, itemize, review, dip into, flip through, browse, glance into, leaf through, skim, refine, enumerate, glean, synopsize, winnow the wheat from the chaff and separate the sheep from the goats.
<formula>
<formulacontent>
<m:math>
<m:mrow>
<m:mi>%Gð%@ </m:mi>
<m:mo>(</m:mo>
<m:mi>%Gð¥%@</m:mi>
<m:mo>)</m:mo>
<m:mo>=</m:mo>
<m:mrow>
<m:mfrac>
<m:mrow>
<m:mn>1</m:mn>
</m:mrow>
<m:mrow>
<m:mi>%Gð%@</m:mi>
</m:mrow>
</m:mfrac>
</m:mrow>
<m:mrow>
<m:mi>l</m:mi>
<m:mi>o</m:mi>
<m:mi>g</m:mi>
</m:mrow>
<m:mrow>
<m:mi>P</m:mi>
<m:mi>r</m:mi>
</m:mrow>
<m:mo>(</m:mo>
<m:msup>
<m:mi>%Gð¦%@</m:mi>
<m:mi>%Gð%@</m:mi>
</m:msup>
<m:mo>></m:mo>
<m:mi>%Gð¥%@</m:mi>
<m:mo>)</m:mo>
</m:mrow>
</m:math>
</formulacontent>
</formula>
</sectioncontent>
</section>
</document>
(Note: The unicode math characters get garbled during copy paste). This is a translation of the output of the TeX file: the contents of the \input
ed file are exported and the TeX math is converted into MathML. This feature is still experimental.