Hans, Since I didn't got a working epub for the first few tries, I did some further inspections with epubcheck[1].
Using this minimal example: \setupbackend[export=test.xml,xhtml=test.xhtml,css={test.css,mathml.css}] \starttext Test \stoptext The main errors are: * opf: id has to be either "stylesheet" for css or the xhtml filename without the suffix * opf: itemref needs to be the name of the xhtml without the suffix Here's a very dirty quick fix I did to get a working epub: add after line 112 or so: + local id = file.removesuffix(filename) line 116: - used[#used+1] = format("<item id='%s' href='%s' media-type='%s'/>",i,filename,mime) + if suffix == "css" then + id = "stylesheet" + elseif suffix == "ncx" then + id = file.suffix(filename) + end + used[#used+1] = format("<item id='%s' href='%s' media-type='%s'/>",id,filename,mime) line 121: - package = format(package,identifier,identifier,concat(used,"\n"),root) + package = format(package,identifier,identifier,concat(used,"\n"),file.removesuffix(root)) I'm sure you make a better fix (I've attached the patched one in case it's easier to diff). Not sure if you want to do something about the other errors, but it'd be nice to have a valid epub in the end. Adam [1] http://code.google.com/p/epubcheck/
Epubcheck Version 1.2 ERROR: test.tree/test.epub: extra field length for first filename must be 0, but was 28 ERROR: test.tree/test.epub/OPS/test.opf(3): value of attribute "unique-identifier" is invalid; must be an XML name without colons ERROR: test.tree/test.epub/OPS/test.opf(8): value of attribute "id" is invalid; must be an XML name without colons ERROR: test.tree/test.epub/OPS/test.opf(13): value of attribute "id" is invalid; must be an XML name without colons ERROR: test.tree/test.epub/OPS/test.opf(14): value of attribute "id" is invalid; must be an XML name without colons ERROR: test.tree/test.epub/OPS/test.opf(15): value of attribute "id" is invalid; must be an XML name without colons ERROR: test.tree/test.epub/OPS/test.opf(18): item with id 'ncx' not found ERROR: test.tree/test.epub/OPS/test.opf(19): item with id 'test.xhtml' not found ERROR: test.tree/test.epub/OPS/test.xhtml(12): elements from namespace "" are not allowed Check finished with warnings or errors!
if not modules then modules = { } end modules ['mtx-epub'] = { version = 1.001, comment = "companion to mtxrun.lua", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" } local format = string.format local concat = table.concat local helpinfo = [[ --make create epub zip file example: mtxrun --script epub --make mydocument ]] local application = logs.application { name = "mtx-epub", banner = "ConTeXt EPUB Helpers 0.10", helpinfo = helpinfo, } -- script code scripts = scripts or { } scripts.epub = scripts.epub or { } local mimetype = "application/epub+zip" local container = [[ <?xml version="1.0" encoding="UTF-8" ?> <container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> <rootfiles> <rootfile full-path="OPS/%s" media-type="application/oebps-package+xml"/> </rootfiles> </container> ]] local package = [[ <?xml version="1.0"?> <package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="%s"> <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> <dc:title>My Title</dc:title> <dc:language>en</dc:language> <dc:identifier id="%s" /> <dc:creator opf:file-as="Self, My" opf:role="aut">MySelf</dc:creator> </metadata> <manifest> %s </manifest> <spine toc="ncx"> <itemref idref="%s" /> </spine> </package> ]] local mimetypes = { xhtml = "application/xhtml+xml", css = "text/css", } -- specification = { -- name = "document", -- identifier = "123", -- root = "a.xhtml", -- files = { -- "a.xhtml", -- "b.css", -- "c.png", -- } -- } function scripts.epub.make() local filename = environment.files[1] if filename and filename ~= "" then filename = file.basename(filename) local specfile = file.replacesuffix(filename,"specification") local specification = lfs.isfile(specfile) and dofile(specfile) or { } -- inspect(specification) local name = specification.name or file.removesuffix(filename) local identifier = specification.identifier or os.uuid() local files = specification.files or { file.addsuffix(filename,"xhtml") } local root = specification.root or files[1] local epubname = name local epubpath = file.replacesuffix(name,"tree") local epubfile = file.replacesuffix(name,"epub") local epubroot = file.replacesuffix(name,"opf") lfs.mkdir(epubpath) lfs.mkdir(file.join(epubpath,"META-INF")) lfs.mkdir(file.join(epubpath,"OPS")) local used = { } for i=1,#files do local filename = files[i] local suffix = file.suffix(filename) local id = file.removesuffix(filename) local mime = mimetypes[suffix] if mime then file.copy(filename,file.join(epubpath,"OPS",filename)) if suffix == "css" then id = "stylesheet" elseif suffix == "ncx" then id = file.suffix(filename) end used[#used+1] = format("<item id='%s' href='%s' media-type='%s'/>",id,filename,mime) end end container = format(container,epubroot) package = format(package,identifier,identifier,concat(used,"\n"),file.removesuffix(root)) io.savedata(file.join(epubpath,"mimetype"),mimetype) io.savedata(file.join(epubpath,"META-INF","container.xml"),container) io.savedata(file.join(epubpath,"OPS",epubroot),package) lfs.chdir(epubpath) os.remove(epubfile) os.execute(format("zip %s -0 %s",epubfile,"mimetype")) os.execute(format("zip %s -r %s",epubfile,"META-INF")) os.execute(format("zip %s -r %s",epubfile,"OPS")) lfs.chdir("..") application.report("epub archive: %s",file.join(epubpath,epubfile)) end end -- if environment.argument("make") then scripts.epub.make() else application.help() end
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________