Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/EpubCreator?V=5
QUERY_STRINGV=5
CONTENT_TYPE
DOCUMENT_URI/revision/EpubCreator
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.71.254.98
REMOTE_PORT50516
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR18.119.131.72
HTTP_CF_RAY87e7f0769846223a-ORD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected])
HTTP_CF_CONNECTING_IP18.119.131.72
HTTP_CDN_LOOPcloudflare
HTTP_CF_IPCOUNTRYUS

Body


Error

Unknow state transition: LINE -> END

-code

1

-level

0

-errorstack

INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit EpubCreator \[Keith\ Vetter\]\ 2014-03-14\ :\ I've\ been\ working\ with\ eBooks\ for\ over\ a\ndecade\ now,\ so\ I\ thought\ I'd\ share\ a\ simple\ command\ line\ tool\nI\ use\ to\ create\ an\ epub\ from\ a\ single\ text\ or\ xhtml\ file.\n\nYou\ need\ to\ specify\ the\ epub's\ title,\ author\ and\ content,\ which\ can\ be\neither\ an\ xhtml\ file\ or\ raw\ text\ (which\ will\ get\ converted\ into\nxhtml).\ You\ can\ also\ specify\ a\ cover\ image.\ If\ the\ xhtml\ source\ has\nimages,\ you\ can\ include\ them\ also.\n\nThe\ command\ line\ usage\ is:\n\ \ epubCreator\ \"Pride\ and\ Prejudice\"\ \"Jane\ Austen\"\ p_and_p.xhtml\ cover.jpg\ img1.jpg\ img2.jpg\n\nAn\ http://www.idpf.org/epub/30/spec/epub30-publications.html%|%epub\ file%|%\nis\ essentially\ a\ zip\ file\ with\ some\ metadata\ files\ and\ one\ or\ more\ xhtml\nfiles\ with\ the\ book's\ content.\ \n\n\n======\n##+##########################################################################\n#\n#\ epubCreator.tsh\ --\ command\ line\ tool\ to\ create\ an\ epub\ version\ 3.0\n#\ file\ from\ a\ single\ text\ or\ xhmtml\ file,\ an\ optional\ cover\ image\ and\n#\ a\ list\ of\ 0\ or\ more\ images\n#\ by\ Keith\ Vetter\ 2014-03-14\n#\n#\ usage:\ epubCreator\ Title\ Author\ BookContent\ ?CoverImage?\ OtherImages...\n#\npackage\ require\ uuid\npackage\ require\ fileutil\n\narray\ set\ EXT\ \{\"\"\ \"\"\ .png\ image/png\ .gif\ image/gif\ .jpg\ image/jpeg\n\ \ \ \ .jpeg\ image/jpeg\ .svg\ image/svg+xml\}\n\n################################################################\n\nproc\ Init\ \{rawname\ title\ author\ cover\ images\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ guid\ \[::uuid::uuid\ generate\]\n\n\ \ \ \ set\ E(rawname)\ \$rawname\n\ \ \ \ set\ E(basename)\ \[file\ tail\ \[file\ rootname\ \$E(rawname)\]\]\n\ \ \ \ set\ E(dirname)\ \[file\ normalize\ \[file\ dirname\ \$E(rawname)\]\]\n\ \ \ \ set\ E(output,tempdir)\ \[file\ join\ \[::fileutil::tempdir\]\ \"epub_\$guid\"\]\n\ \ \ \ set\ E(output,final)\ \[file\ join\ \$E(dirname)\ \"\$E(basename).epub\"\]\n\n\ \ \ \ set\ E(epub)\ EPUB\n\ \ \ \ set\ E(epub,tempdir)\ \[file\ join\ \$E(output,tempdir)\ \$E(epub)\]\n\ \ \ \ set\ E(html,name)\ \"\$E(basename).xhtml\"\n\ \ \ \ set\ E(html,tempname)\ \[file\ join\ \$E(epub,tempdir)\ \"\$E(html,name)\"\]\n\ \ \ \ set\ E(opf,name)\ \ \[file\ join\ \$E(epub)\ package.opf\]\n\ \ \ \ set\ E(opf,tempname)\ \ \[file\ join\ \$E(output,tempdir)\ \$E(opf,name)\]\n\ \ \ \ set\ E(mimetype)\ mimetype\n\ \ \ \ set\ E(mimetype,tempname)\ \[file\ join\ \$E(output,tempdir)\ \$E(mimetype)\]\n\ \ \ \ set\ E(meta-inf)\ META-INF\n\ \ \ \ set\ E(meta-inf,tempdir)\ \[file\ join\ \$E(output,tempdir)\ \$E(meta-inf)\]\n\ \ \ \ set\ E(meta-inf,tempname)\ \[file\ join\ \$E(meta-inf,tempdir)\ container.xml\]\n\ \ \ \ set\ E(nav,name)\ nav.xhtml\n\ \ \ \ set\ E(nav,tempname)\ \[file\ join\ \$E(epub,tempdir)\ \$E(nav,name)\]\n\ \ \ \ set\ E(cover,source)\ \$cover\n\ \ \ \ set\ E(cover,name)\ \[file\ tail\ \$cover\]\n\ \ \ \ set\ E(cover,format)\ \$::EXT(\[file\ extension\ \$cover\])\n\ \ \ \ set\ E(images)\ \$images\n\ \ \ \ set\ E(date)\ \[clock\ format\ \[clock\ seconds\]\ -gmt\ 1\ -format\ \"%Y-%m-%dT%TZ\"\]\n\n\ \ \ \ file\ mkdir\ \$E(output,tempdir)\n\ \ \ \ file\ mkdir\ \$E(meta-inf,tempdir)\n\ \ \ \ file\ mkdir\ \$E(epub,tempdir)\n\n\ \ \ \ set\ E(guid)\ \"ebook:\$guid\"\n\ \ \ \ set\ E(title)\ \$title\n\ \ \ \ set\ E(author)\ \$author\n\}\nproc\ MakeEpubFiles\ \{\}\ \{\n\ \ \ \ global\ E\n\n\ \ \ \ WriteAllData\ \$E(html,tempname)\ \[TextToHtml\]\n\ \ \ \ WriteAllData\ \$E(mimetype,tempname)\ \"application/epub+zip\"\n\ \ \ \ WriteAllData\ \$E(meta-inf,tempname)\ \[subst\ \$::CONTAINER_XML\]\n\ \ \ \ WriteAllData\ \$E(opf,tempname)\ \[MakeOPF\]\n\ \ \ \ WriteAllData\ \$E(nav,tempname)\ \[subst\ \$::NAV_XHTML\]\n\}\nproc\ TextToHtml\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ fin\ \[open\ \$E(rawname)\ r\]\n\ \ \ \ set\ data\ \[read\ \$fin\]\ \;\ list\n\ \ \ \ close\ \$fin\n\n\ \ \ \ if\ \{\[string\ first\ \"<html\"\ \$data\]\ ==\ -1\}\ \{\n\ \ \ \ \ \ \ \ set\ data\ \[string\ map\ \{&\ &amp\;\ <\ &lt\;\ >\ &gt\;\ \\x22\ &quot\;\ '\ &apos\;\}\ \$data\]\ \;\ list\n\ \ \ \ \ \ \ \ regsub\ -all\ -line\ \{^\$\}\ \$data\ \{</p><p>\}\ data\n\n\ \ \ \ \ \ \ \ set\ data\ \"\[subst\ \$::HTML_TEMPLATE\]\"\ \;\ list\n\ \ \ \ \}\n\ \ \ \ return\ \$data\n\}\nproc\ MakeOPF\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ opf\ \[subst\ \$::CONTENT_OPF\]\n\ \ \ \ if\ \{\$E(cover,source)\ eq\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ regsub\ -all\ -line\ \{^.*id_cover.*\$\}\ \$opf\ \"\"\ opf\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ file\ copy\ \$E(cover,source)\ \$E(epub,tempdir)\n\ \ \ \ \}\n\n\ \ \ \ \;#\ Copy\ any\ additional\ images\n\ \ \ \ set\ image_items\ \"\"\n\ \ \ \ for\ \{set\ i\ 0\}\ \{\$i\ <\ \[llength\ \$E(images)\]\}\ \{incr\ i\}\ \{\n\ \ \ \ \ \ \ \ set\ iname\ \[lindex\ \$E(images)\ \$i\]\n\ \ \ \ \ \ \ \ file\ copy\ \$iname\ \$E(epub,tempdir)\n\ \ \ \ \ \ \ \ set\ tailname\ \[file\ tail\ \$iname\]\n\ \ \ \ \ \ \ \ set\ media\ \$::EXT(\[file\ extension\ \$iname\])\n\ \ \ \ \ \ \ \ set\ id\ \"id_image_\$i\"\n\ \ \ \ \ \ \ \ set\ line\ \"<item\ href=\\\"\$tailname\\\"\ id=\\\"\$id\\\"\ media-type=\\\"\$media\\\"/>\\n\"\n\ \ \ \ \ \ \ \ append\ image_items\ \$line\n\ \ \ \ \}\n\ \ \ \ if\ \{\$image_items\ ne\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ regsub\ -line\ \{^.*other\ images\ go\ here.*\$\}\ \$opf\ \$image_items\ opf\n\ \ \ \ \}\n\ \ \ \ return\ \$opf\n\}\nproc\ ZipEpub\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ cd\ \$E(output,tempdir)\n\ \ \ \ exec\ zip\ -rX\ \$E(output,final)\ \$E(mimetype)\ \$E(meta-inf)/\ \$E(epub)/\n\}\nproc\ WriteAllData\ \{fname\ data\}\ \{\n\ \ \ \ set\ fout\ \[open\ \$fname\ w\]\;\ puts\ -nonewline\ \$fout\ \$data\;\ close\ \$fout\;\n\}\nproc\ Cleanup\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ file\ delete\ -force\ --\ \$E(output,tempdir)\n\}\n################################################################\nset\ HTML_TEMPLATE\ \{<?xml\ version=\"1.0\"?>\n<html\ xmlns=\"http://www.w3.org/1999/xhtml\"\ xml:lang=\"en\"\ lang=\"en\"\n\ \ \ \ \ \ xmlns:epub=\"http://www.idpf.org/2007/ops\">\n\ \ <head>\n\ \ \ \ <title>\$E(title)</title>\n\ \ </head>\n\ \ <body>\n\ \ \ \ <p>\n\ \ \ \ \$data\n\ \ \ \ </p>\n\ \ </body>\n</html>\n\}\n\nset\ CONTAINER_XML\ \{<?xml\ version=\"1.0\"?>\n<container\ version=\"1.0\"\ xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\">\n\ \ <rootfiles>\n\ \ \ \ <rootfile\ media-type=\"application/oebps-package+xml\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ full-path=\"\$E(opf,name)\"\ />\n\ \ </rootfiles>\n</container>\n\}\n\nset\ CONTENT_OPF\ \{<?xml\ version=\"1.0\"\ encoding=\"UTF-8\"?>\n<package\ xmlns=\"http://www.idpf.org/2007/opf\"\ version=\"3.0\"\ unique-identifier=\"uuid\">\n\ \ <metadata\ xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\ xmlns:opf=\"http://www.idpf.org/2007/opf\">\n\ \ \ \ <dc:title>\$E(title)</dc:title>\n\ \ \ \ <dc:creator>\$E(author)</dc:creator>\n\ \ \ \ <dc:identifier\ id=\"uuid\">\$E(guid)</dc:identifier>\n\ \ \ \ <dc:language>en</dc:language>\n\ \ \ \ <meta\ property=\"dcterms:modified\">\$E(date)</meta>\n\ \ \ \ <meta\ name=\"cover\"\ content=\"id_cover\"/>\n\ \ </metadata>\n\ \ <manifest>\n\ \ \ \ <item\ id=\"id_cover\"\ href=\"\$E(cover,name)\"\ media-type=\"\$E(cover,format)\"\ properties=\"cover-image\"/>\n\ \ \ \ <item\ id=\"id_html\"\ href=\"\$E(html,name)\"\ media-type=\"application/xhtml+xml\"/>\n\ \ \ \ <item\ id=\"nav\"\ href=\"nav.xhtml\"\ media-type=\"application/xhtml+xml\"\ properties=\"nav\"/>\n\ \ \ \ <!--\ other\ images\ go\ here\ -->\n\ \ </manifest>\n\ \ <spine>\n\ \ \ \ <itemref\ idref=\"id_html\"/>\n\ \ </spine>\n</package>\n\}\n\nset\ NAV_XHTML\ \{<?xml\ version=\"1.0\"\ encoding=\"UTF-8\"?>\n<html\ xmlns=\"http://www.w3.org/1999/xhtml\"\ xml:lang=\"en\"\ lang=\"en\"\n\ \ \ \ \ \ xmlns:epub=\"http://www.idpf.org/2007/ops\">\n\ \ <head>\n\ \ </head>\n\ \ <body>\n\ \ \ \ <nav\ epub:type=\"toc\"\ id=\"toc\">\n\ \ \ \ \ \ <ol>\n\ \ \ \ \ \ \ \ <li><a\ href=\"\$E(html,name)\">The\ Content</a></li>\n\ \ \ \ \ \ </ol>\n\ \ \ \ </nav>\n\ \ </body>\n</html>\n\}\n\n################################################################\n\nputs\ \"\\nepubCreator\ v0.3\\nby\ Keith\ Vetter\\n\"\nif\ \{\[llength\ \$argv\]\ <\ 3\}\ \{\n\ \ \ \ puts\ stderr\ \"usage:\ epubCreator\ <title>\ <author>\ <data\ file>\ ?<cover\ image>?\ ?<other\ images>...?\"\n\ \ \ \ puts\ stderr\ \"for\ example:\"\n\ \ \ \ puts\ stderr\ \"\ \ epubCreator\ \\\"Pride\ and\ Prejudice\\\"\ \\\"Jane\ Austen\\\"\ p_and_p.xhtml\ cover.jpg\ chapter1.jpg\"\n\ \ \ \ return\n\}\nset\ images\ \[lassign\ \$argv\ title\ author\ fname\ cover\]\n\nInit\ \$fname\ \$title\ \$author\ \$cover\ \$images\n\nMakeEpubFiles\nZipEpub\nCleanup\nputs\ \"created\ \$E(output,final)\"\nreturn\n\n======\n\n----\n'''\[ak\]\ -\ 2014-03-14\ 23:42:26'''\n\n\[Tcllib\]\ contains\ a\ package\n\[https://core.tcl.tk/tcllib/doc/trunk/embedded/www/tcllib/files/modules/zip/encode.html%|%\"zipfile::encode\ (doc)\"\]\nthat\ can\ obviate\ the\ need\ for\ 'exec\ zip'.\ It\ requires\ \[Trf\]\ and\ \[zlibtcl\]\ though.\ Note\ that\ while\ Tcl\ 8.6\ provides\ zip\ functions\ in-core,\ the\ \[Tcllib\]\ package\ currently\ makes\ no\ use\ of\ that.\n\n----\n'''\[clif\ flynt\]\ -\ 2014-07-14\ '''\n\nI\ modified\ and\ extended\ Keith's\ code\ a\ bit.\ \ After\ some\ tweaking,\ I've\ got\ it\ passing\ the\ epubcheck\ validator,\naccepting\ multiple\ files\ and\ a\ couple\ other\ tweaks.\n\nCheck\ the\ comments\ for\ the\ new,\ expanded\ command\ line.\ \n\n======\n\n############################################################################\n#\n#\ epubCreator.tcl\ --\ command\ line\ tool\ to\ create\ an\ epub\ version\ 3.0\n#\ file\ from\ a\ single\ text\ or\ xhmtml\ file,\ an\ optional\ cover\ image\ and\n#\ a\ list\ of\ 0\ or\ more\ images\n#\ by\ Keith\ Vetter\ 2014-03-14\n#\ Mods\ Clif\ Flynt,\ 2014-04-01\n#\ \ Support\ for\ multiple\ text/html\ files\ (multiple\ chapters)\n#\ \ Support\ for\ additional\ .css\ file\n#\ \ Support\ for\ filename.epub\ different\ from\ \"book\ title.epub\"\n#\ \ Support\ for\ toc.ncx\ as\ well\ as\ nav.html\n#\ \ Expanded\ command\ line\ processing\n#\n#\ usage:\ epubCreator\ \\\n#\ -title\ Title\ -author\ 'last,\ first'\ -data\ file1.txt\ file2.html\ file3.xhtml...\\\n#\ -cover\ Cover.jpg\ -images\ additional\ Images\ -css\ Style.css\ -html\ (1/0)\ \\\n#\ -name\ BookName\n#\n#\ \ -title\ \ \ \ \ \ \ Title\ for\ book\n#\ \ -author\ \ \ \ \ \ Name\ of\ author\ as\ last,\ first\n#\ \ -data\ \ \ \ \ \ \ \ List\ of\ data\ files\ to\ include\ in\ the\ text\n#\ \ -cover\ \ \ \ \ \ \ An\ image\ file\ for\ the\ cover\n#\ \ -images\ \ \ \ \ \ Additional\ images\ that\ might\ be\ reference\ by\ text\n#\ \ -css\ \ \ \ \ \ \ \ \ An\ optional\ css\ file\ if\ you\ want\ special\ formatting\n#\ \ -html\ \ \ \ \ \ \ \ 1\ or\ 0\ to\ define\ whether\ the\ input\ data\ is\ already\ in\ html\ format\n#\ \ -name\ \ \ \ \ \ \ \ The\ name\ for\ the\ .epub\ file,\ if\ different\ from\ title\n#\n\npackage\ require\ uuid\npackage\ require\ fileutil\n\narray\ set\ EXT\ \{\"\"\ \"\"\ .png\ image/png\ .gif\ image/gif\ .jpg\ image/jpeg\n\ \ \ \ .jpeg\ image/jpeg\ .svg\ image/svg+xml\}\n\n\n\nproc\ parseList\ \{list\ stateVarName\ \{throwError\ 1\}\}\ \{\n\ \ \ \ upvar\ \$stateVarName\ stateArray\n\n\ \ \ \ set\ errs\ \"\"\n\ \ \ \ \n\ \ \ \ foreach\ arg\ \$list\ \{\n\ \ \ \ \ \ \ \ if\ \{(\[string\ first\ \"-\"\ \$arg\]\ ==\ 0)\ &&\n\ \ \ \ \ \ \ \ \ \ \ \ \ (\[llength\ \$arg\]\ ==\ 1)\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ index\ \[string\ range\ \$arg\ 1\ end\]\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{!\[info\ exists\ stateArray(\$index)\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$throwError\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ error\ \"No\ default\ for\ \$\{stateVarName\}(\$index).\\nValid\ fields\ are\ \[lsort\ \[array\ names\ stateArray\]\]\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ lappend\ errs\ \"No\ default\ for\ \$\{stateVarName\}(\$index)\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ cmd\ set\n\ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\[info\ exists\ cmd\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$cmd\ stateArray(\$index)\ \$arg\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ cmd\ lappend\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\ \n\ \ \ \ \}\n\ \ \ \ return\ \$errs\n\}\n\nproc\ Init\ \{rawname\ title\ author\ cover\ images\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ guid\ \[::uuid::uuid\ generate\]\n\n\ \ \ \ set\ E(rawname)\ \$rawname\n\ \ \ \ set\ E(basename)\ \[file\ tail\ \[file\ rootname\ \$E(rawname)\]\]\n\ \ \ \ set\ E(dirname)\ \[file\ normalize\ \[file\ dirname\ \$E(rawname)\]\]\n\ \ \ \ set\ E(output,tempdir)\ \[file\ join\ \[::fileutil::tempdir\]\ \"epub_\$guid\"\]\n\ \ \ \ if\ \{\$E(name)\ eq\ \"\"\}\ \{\n\ \ \ \ \ \ set\ E(output,final)\ \[file\ join\ \$E(dirname)\ \"\$E(basename).epub\"\]\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ set\ E(output,final)\ \[file\ join\ \$E(dirname)\ \"\$E(name).epub\"\]\n\ \ \ \ \}\n\n\ \ \ \ set\ E(epub)\ EPUB\n\ \ \ \ set\ E(epub,tempdir)\ \[file\ join\ \$E(output,tempdir)\ \$E(epub)\]\n\ \ \ \ set\ E(html,name)\ \"\$E(basename).xhtml\"\n\ \ \ \ set\ E(html,tempname)\ \[file\ join\ \$E(epub,tempdir)\ \"\$E(html,name)\"\]\n\ \ \ \ set\ E(ncx,tempname)\ \[file\ join\ \$E(epub,tempdir)\ \"toc.ncx\"\]\n\ \ \ \ set\ E(opf,name)\ \ \[file\ join\ \$E(epub)\ package.opf\]\n\ \ \ \ set\ E(opf,tempname)\ \ \[file\ join\ \$E(output,tempdir)\ \$E(opf,name)\]\n\ \ \ \ set\ E(mimetype)\ mimetype\n\ \ \ \ set\ E(mimetype,tempname)\ \[file\ join\ \$E(output,tempdir)\ \$E(mimetype)\]\n\ \ \ \ set\ E(meta-inf)\ META-INF\n\ \ \ \ set\ E(meta-inf,tempdir)\ \[file\ join\ \$E(output,tempdir)\ \$E(meta-inf)\]\n\ \ \ \ set\ E(meta-inf,tempname)\ \[file\ join\ \$E(meta-inf,tempdir)\ container.xml\]\n\ \ \ \ set\ E(nav,name)\ nav.xhtml\n\ \ \ \ set\ E(nav,tempname)\ \[file\ join\ \$E(epub,tempdir)\ \$E(nav,name)\]\n\ \ \ \ set\ E(cover,source)\ \$cover\n\ \ \ \ set\ E(cover,name)\ \[file\ tail\ \$cover\]\n\ \ \ \ set\ E(cover,format)\ \$::EXT(\[file\ extension\ \$cover\])\n\ \ \ \ set\ E(images)\ \$images\n\ \ \ \ set\ E(date)\ \[clock\ format\ \[clock\ seconds\]\ -gmt\ 1\ -format\ \"%Y-%m-%dT%TZ\"\]\n\n\ \ \ \ file\ mkdir\ \$E(output,tempdir)\n\ \ \ \ file\ mkdir\ \$E(meta-inf,tempdir)\n\ \ \ \ file\ mkdir\ \$E(epub,tempdir)\n\n\ \ \ \ set\ E(guid)\ \"ebook:\$guid\"\n\ \ \ \ set\ E(title)\ \$title\n\ \ \ \ set\ E(author)\ \$author\n\ \ \ \ \n\ \ \ \ if\ \{\$E(css)\ ne\ \"\"\}\ \{\n\ \ \ \ \ \ set\ E(css,name)\ \$E(css)\n\ \ \ \ \ \ set\ E(css,tempname)\ \[file\ join\ \$E(epub,tempdir)\ stylesheet.css\]\n\ \ \ \ \ \ set\ E(opf,stylesheet)\ \{<item\ href=\"stylesheet.css\"\ id=\"css\"\ media-type=\"text/css\"/>\}\n\ \ \ \ \}\n\}\nproc\ MakeEpubFiles\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ i\ 0\n\ \ \ \ if\ \{\$E(cover,source)\ ne\ \"\"\}\ \{\n\ \ \ \ \ \ set\ E(rawname)\ \[list\ cover.xhtml\ \{*\}\$E(rawname)\]\n\ \ \ \ \ \ set\ of\ \[open\ cover.xhtml\ w\]\n\ \ \ \ \ \ puts\ \$of\ \[BodyToHtml\ \"<img\ src=\\\"\[file\ tail\ \$E(cover,source)\]\\\"></img>\"\]\n\ \ \ \ \ \ close\ \$of\n\ \ \ \ \}\n\ \ \ \ foreach\ rawname\ \$E(rawname)\ \{\n\ \ \ \ \ \ incr\ i\n\ \ \ \ \ \ set\ basename\ \[file\ tail\ \[file\ rootname\ \$rawname\]\]\n\ \ \ \ \ \ set\ E(html,name)\ \"\$basename.xhtml\"\n\ \ \ \ \ \ set\ E(html,tempname)\ \[file\ join\ \$E(epub,tempdir)\ \"\$E(html,name)\"\]\n\ \ \ \ \ \ append\ E(opf,html_items)\ \[subst\ \{\n\ \ \ \ <item\ id=\"id_html_\$i\"\ href=\"\$E(html,name)\"\ media-type=\"application/xhtml+xml\"/>\}\]\n\ \ \ \ \ \ append\ E(opf,ref_items)\ \[subst\ \{\n\ \ \ \ \ \ \ \ <itemref\ idref=\"id_html_\$i\"/>\}\]\n\ \ \ \ \ \ append\ navs\ \[subst\ \$::NAV_XHTML1\]\n\ \ \ \ \ \ append\ ncxs\ \[subst\ \$::CONTENT_NCX1\]\n\ \ \ \ \ \ if\ \{\$E(html)\}\ \{\n\ \ \ \ \ \ \ \ WriteAllData\ \$E(html,tempname)\ \$rawname\n\ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ WriteAllData\ \$E(html,tempname)\ \[TextToHtml\ \$rawname\]\n\ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \ \ WriteAllData\ \$E(mimetype,tempname)\ \"application/epub+zip\"\n\ \ \ \ WriteAllData\ \$E(meta-inf,tempname)\ \[subst\ \$::CONTAINER_XML\]\n\ \ \ \ WriteAllData\ \$E(opf,tempname)\ \[MakeOPF\]\n\ \ \ \ WriteAllData\ \$E(nav,tempname)\ \"\[subst\ \$::NAV_XHTML0\]\\n\$navs\\n\$::NAV_XHTML2\"\n\ \ \ \ WriteAllData\ \$E(ncx,tempname)\ \"\[subst\ \$::CONTENT_NCX0\]\\n\$ncxs\\n\$::CONTENT_NCX2\"\n\ \ \ \ if\ \{\[info\ exists\ E(css,tempname)\]\}\ \{\n\ \ \ \ \ \ WriteAllData\ \$E(css,tempname)\ \$E(css)\n\ \ \ \ \}\n\}\nproc\ TextToHtml\ \{rawname\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ fin\ \[open\ \$rawname\ r\]\n\ \ \ \ set\ data\ \[read\ \$fin\]\ \n\ \ \ \ close\ \$fin\n\n\ \ \ \ if\ \{\[string\ first\ \"<html\"\ \$data\]\ ==\ -1\}\ \{\n\ \ \ \ \ \ \ \ set\ data\ \[string\ map\ \{&\ &amp\;\ <\ &lt\;\ >\ &gt\;\ \\x22\ &quot\;\ '\ &apos\;\}\ \$data\]\ \;\ list\n\ \ \ \ \ \ \ \ regsub\ -all\ -line\ \{^\$\}\ \$data\ \{</p><p>\}\ data\n\n\ \ \ \ \ \ \ \ set\ data\ \"\[subst\ \$::HTML_TEMPLATE\]\"\ \;\ list\n\ \ \ \ \}\n\ \ \ \ return\ \$data\n\}\n\nproc\ BodyToHtml\ \{data\}\ \{\n\ \ \ \ global\ E\n\n\ \ \ \ set\ data\ \"\[subst\ \$::HTML_TEMPLATE\]\"\ \n\ \ \ \ return\ \$data\n\}\n\nproc\ MakeOPF\ \{\}\ \{\n\ \ \ \ global\ E\n\n\ \ \ \ set\ data\ \"\[subst\ \$::HTML_TEMPLATE\]\"\ \n\ \ \ \ return\ \$data\n\}\n\nproc\ MakeOPF\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ html_items\ \{\}\n\ \ \ \ set\ image_items\ \{\}\n\ \ \ \ set\ ref_items\ \{\}\n\ \ \ \ set\ opf\ \[subst\ \$::CONTENT_OPF\]\n\ \ \ \ if\ \{\$E(cover,source)\ eq\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ regsub\ -all\ -line\ \{^.*id_cover.*\$\}\ \$opf\ \"\"\ opf\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ file\ copy\ \$E(cover,source)\ \$E(epub,tempdir)\n\ \ \ \ \}\n\n\ \ \ \ \;#\ Copy\ any\ additional\ images\n\ \ \ \ set\ image_items\ \"\"\n\ \ \ \ for\ \{set\ i\ 0\}\ \{\$i\ <\ \[llength\ \$E(images)\]\}\ \{incr\ i\}\ \{\n\ \ \ \ \ \ \ \ set\ iname\ \[lindex\ \$E(images)\ \$i\]\n\ \ \ \ \ \ \ \ file\ copy\ \$iname\ \$E(epub,tempdir)\n\ \ \ \ \ \ \ \ set\ tailname\ \[file\ tail\ \$iname\]\n\ \ \ \ \ \ \ \ set\ media\ \$::EXT(\[file\ extension\ \$iname\])\n\ \ \ \ \ \ \ \ set\ id\ \"id_image_\$i\"\n\ \ \ \ \ \ \ \ set\ line\ \"<item\ href=\\\"\$tailname\\\"\ id=\\\"\$id\\\"\ media-type=\\\"\$media\\\"/>\\n\"\n\ \ \ \ \ \ \ \ append\ image_items\ \$line\n\ \ \ \ \}\n\ \ \ \ if\ \{\$image_items\ ne\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ regsub\ -line\ \{^.*other\ images\ go\ here.*\$\}\ \$opf\ \$image_items\ opf\n\ \ \ \ \}\n\ \ \ \ return\ \$opf\n\}\nproc\ ZipEpub\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ cd\ \$E(output,tempdir)\n\n\ \ \ \ #\ Get\ rid\ of\ any\ previous\ epub\ else\ zip\ will\ append\ to\ the\n\ \ \ \ #\ existing\ file,\ leaving\ behind\ elements\ you\ thought\ had\ been\ removed\n\ \ \ \ catch\ \{file\ delete\ \$E(output,final)\}\n\ \ \ \ exec\ zip\ -rX\ \$E(output,final)\ \$E(mimetype)\ \$E(meta-inf)/\ \$E(epub)/\n\}\nproc\ WriteAllData\ \{fname\ data\}\ \{\n\ \ \ \ if\ \{\[file\ exists\ \$data\]\}\ \{\n\ \ \ \ \ \ set\ if\ \[open\ \$data\]\n\ \ \ \ \ \ set\ data\ \[read\ \$if\]\n\ \ \ \ \ \ close\ \$if\n\ \ \ \ \}\n\ \ \ \ set\ fout\ \[open\ \$fname\ w\]\;\ \n\ \ \ \ puts\ -nonewline\ \$fout\ \$data\;\ \n\ \ \ \ close\ \$fout\;\n\}\nproc\ Cleanup\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ file\ delete\ -force\ --\ \$E(output,tempdir)\n\ \ \ \ file\ delete\ cover.xhtml\n\}\nset\ HTML_TEMPLATE\ \{<?xml\ version=\"1.0\"?>\n<html\ xmlns=\"http://www.w3.org/1999/xhtml\"\ xml:lang=\"en\"\ lang=\"en\"\n\ \ \ \ \ \ xmlns:epub=\"http://www.idpf.org/2007/ops\">\n\ \ <head>\n\ \ \ \ <title>\$E(title)</title>\n\ \ \ \ <link\ href=\"stylesheet.css\"\ type=\"text/css\"\ rel=\"stylesheet\"/>\n\ \ </head>\n\ \ <body>\n\ \ \ \ <p>\n\ \ \ \ \$data\n\ \ \ \ </p>\n\ \ </body>\n</html>\n\}\n\nset\ CONTAINER_XML\ \{<?xml\ version=\"1.0\"?>\n<container\ version=\"1.0\"\ xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\">\n\ \ <rootfiles>\n\ \ \ \ <rootfile\ media-type=\"application/oebps-package+xml\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ full-path=\"\$E(opf,name)\"\ />\n\ \ </rootfiles>\n</container>\n\}\n\n#\ NCX\ format\n#\ per:\ http://www.gbenthien.net/Kindle%20and%20EPUB/ncx.html\n\nset\ CONTENT_NCX0\ \{<?xml\ version=\"1.0\"\ encoding=\"UTF-8\"?>\n<ncx\ xmlns=\"http://www.daisy.org/z3986/2005/ncx/\"\ version=\"2005-1\"\ xml:lang=\"en\">\n<head>\n<meta\ name=\"dtb:uid\"\ content=\"\$::E(guid)\"/>\n<meta\ name=\"dtb:depth\"\ content=\"1\"/>\n<meta\ name=\"dtb:totalPageCount\"\ content=\"0\"/>\n<meta\ name=\"dtb:maxPageNumber\"\ content=\"0\"/>\n</head>\n\n\n<docTitle><text>\$::E(name)</text></docTitle>\n<docAuthor><text>\$::E(author)</text></docAuthor>\n\n\n\n<navMap>\n\n\}\nset\ CONTENT_NCX1\ \{\n<navPoint\ id=\"navpoint-\$i\"\ playOrder=\"\$i\">\n<navLabel><text>Chapter\ \$i</text></navLabel>\n<content\ src=\"\$::E(html,name)\"/>\n</navPoint>\n\}\n\nset\ CONTENT_NCX2\ \{\n</navMap>\n</ncx>\n\}\nset\ CONTENT_OPF\ \{<?xml\ version=\"1.0\"\ encoding=\"UTF-8\"?>\n<package\ xmlns=\"http://www.idpf.org/2007/opf\"\ version=\"3.0\"\ unique-identifier=\"uuid\">\n\ \ <metadata\ xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\ xmlns:opf=\"http://www.idpf.org/2007/opf\">\n\ \ \ \ <dc:title>\$E(title)</dc:title>\n\ \ \ \ <dc:creator>\$E(author)</dc:creator>\n\ \ \ \ <dc:identifier\ id=\"uuid\">\$E(guid)</dc:identifier>\n\ \ \ \ <dc:language>en</dc:language>\n\ \ \ \ <meta\ property=\"dcterms:modified\">\$E(date)</meta>\n\ \ \ \ <meta\ name=\"cover\"\ content=\"id_cover\"/>\n\ \ </metadata>\n\ \ <manifest>\n\ \ \ \ \$::E(opf,stylesheet)\n\ \ \ \ <item\ id=\"id_cover\"\ href=\"\$E(cover,name)\"\ media-type=\"\$E(cover,format)\"/>\n\ \ \ \ \$::E(opf,html_items)\n\ \ \ \ <item\ id=\"toc\"\ href=\"toc.ncx\"\ media-type=\"application/x-dtbncx+xml\"\ />\n\ \ \ \ \$image_items\n\ \ \ \ <item\ id=\"nav\"\ href=\"nav.xhtml\"\ media-type=\"application/xhtml+xml\"\ properties=\"nav\"/>\n\ \ </manifest>\n\ \ <spine\ toc=\"toc\">\n\ \ \ \ \$::E(opf,ref_items)\n\ \ </spine>\n</package>\n\}\n\nset\ NAV_XHTML0\ \{<?xml\ version=\"1.0\"\ encoding=\"UTF-8\"?>\n<html\ xmlns=\"http://www.w3.org/1999/xhtml\"\ xml:lang=\"en\"\ lang=\"en\"\n\ \ \ \ \ \ xmlns:epub=\"http://www.idpf.org/2007/ops\">\n\ \ <head>\n\ \ <title>\$::E(name)</title>\n\ \ </head>\n\ \ <body>\n\ \ <nav\ epub:type=\"toc\"\ id=\"toc\">\n\ \ <ol>\n\}\nset\ NAV_XHTML1\ \{\ \ \ \ \ \ <li><a\ href=\"\$E(html,name)\">Chapter\ \$i</a></li>\n\}\nset\ NAV_XHTML2\ \{\n\ \ \ \ </ol>\n\ \ </nav>\n</body>\n</html>\n\}\n\n\nputs\ \"\\nepubCreator\ v0.3\\nby\ Keith\ Vetter\\n\"\nif\ \{\[llength\ \$argv\]\ <\ 3\}\ \{\n\ \ \ \ puts\ stderr\ \"usage:\ epubCreator\ -title\ <title>\ -author\ <author>\ -data\ <data\ file1>\ <data\ file2>\ ...\ -cover\ ?<cover\ image>?\ -images\ ?<other\ images>\ ...?\"\n\ \ \ \ puts\ stderr\ \"for\ example:\"\n\ \ \ \ puts\ stderr\ \"\ \ epubCreator\ -title\ \\\"Pride\ and\ Prejudice\\\"\ -author\ \\\"Austen,\ Jane\\\"\ p_and_p.xhtml\ -cover\ cover.jpg\ chapter1.html\"\n\ \ \ \ return\n\}\n#\ set\ images\ \[lassign\ \$argv\ title\ author\ fname\ cover\]\n\narray\ set\ E\ \{\n\ \ title\ \{\}\n\ \ author\ \{\}\n\ \ data\ \{\}\n\ \ cover\ \{\}\n\ \ images\ \{\}\n\ \ css\ \{\}\n\ \ html\ \{0\}\n\ \ name\ \{\}\n\}\n\ parseList\ \$argv\ E\ 1\n\nInit\ \$E(data)\ \$E(title)\ \$E(author)\ \$E(cover)\ \$E(images)\n\nMakeEpubFiles\n#\ parray\ E\n#\ puts\ \"TMP:\ ..\$E(output,tempdir)..\"\nZipEpub\nCleanup\nputs\ \"created\ \$E(output,final)\"\nreturn\n\n\n<<categories>>Enter\ Category\ Here regexp2} CALL {my render EpubCreator \[Keith\ Vetter\]\ 2014-03-14\ :\ I've\ been\ working\ with\ eBooks\ for\ over\ a\ndecade\ now,\ so\ I\ thought\ I'd\ share\ a\ simple\ command\ line\ tool\nI\ use\ to\ create\ an\ epub\ from\ a\ single\ text\ or\ xhtml\ file.\n\nYou\ need\ to\ specify\ the\ epub's\ title,\ author\ and\ content,\ which\ can\ be\neither\ an\ xhtml\ file\ or\ raw\ text\ (which\ will\ get\ converted\ into\nxhtml).\ You\ can\ also\ specify\ a\ cover\ image.\ If\ the\ xhtml\ source\ has\nimages,\ you\ can\ include\ them\ also.\n\nThe\ command\ line\ usage\ is:\n\ \ epubCreator\ \"Pride\ and\ Prejudice\"\ \"Jane\ Austen\"\ p_and_p.xhtml\ cover.jpg\ img1.jpg\ img2.jpg\n\nAn\ http://www.idpf.org/epub/30/spec/epub30-publications.html%|%epub\ file%|%\nis\ essentially\ a\ zip\ file\ with\ some\ metadata\ files\ and\ one\ or\ more\ xhtml\nfiles\ with\ the\ book's\ content.\ \n\n\n======\n##+##########################################################################\n#\n#\ epubCreator.tsh\ --\ command\ line\ tool\ to\ create\ an\ epub\ version\ 3.0\n#\ file\ from\ a\ single\ text\ or\ xhmtml\ file,\ an\ optional\ cover\ image\ and\n#\ a\ list\ of\ 0\ or\ more\ images\n#\ by\ Keith\ Vetter\ 2014-03-14\n#\n#\ usage:\ epubCreator\ Title\ Author\ BookContent\ ?CoverImage?\ OtherImages...\n#\npackage\ require\ uuid\npackage\ require\ fileutil\n\narray\ set\ EXT\ \{\"\"\ \"\"\ .png\ image/png\ .gif\ image/gif\ .jpg\ image/jpeg\n\ \ \ \ .jpeg\ image/jpeg\ .svg\ image/svg+xml\}\n\n################################################################\n\nproc\ Init\ \{rawname\ title\ author\ cover\ images\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ guid\ \[::uuid::uuid\ generate\]\n\n\ \ \ \ set\ E(rawname)\ \$rawname\n\ \ \ \ set\ E(basename)\ \[file\ tail\ \[file\ rootname\ \$E(rawname)\]\]\n\ \ \ \ set\ E(dirname)\ \[file\ normalize\ \[file\ dirname\ \$E(rawname)\]\]\n\ \ \ \ set\ E(output,tempdir)\ \[file\ join\ \[::fileutil::tempdir\]\ \"epub_\$guid\"\]\n\ \ \ \ set\ E(output,final)\ \[file\ join\ \$E(dirname)\ \"\$E(basename).epub\"\]\n\n\ \ \ \ set\ E(epub)\ EPUB\n\ \ \ \ set\ E(epub,tempdir)\ \[file\ join\ \$E(output,tempdir)\ \$E(epub)\]\n\ \ \ \ set\ E(html,name)\ \"\$E(basename).xhtml\"\n\ \ \ \ set\ E(html,tempname)\ \[file\ join\ \$E(epub,tempdir)\ \"\$E(html,name)\"\]\n\ \ \ \ set\ E(opf,name)\ \ \[file\ join\ \$E(epub)\ package.opf\]\n\ \ \ \ set\ E(opf,tempname)\ \ \[file\ join\ \$E(output,tempdir)\ \$E(opf,name)\]\n\ \ \ \ set\ E(mimetype)\ mimetype\n\ \ \ \ set\ E(mimetype,tempname)\ \[file\ join\ \$E(output,tempdir)\ \$E(mimetype)\]\n\ \ \ \ set\ E(meta-inf)\ META-INF\n\ \ \ \ set\ E(meta-inf,tempdir)\ \[file\ join\ \$E(output,tempdir)\ \$E(meta-inf)\]\n\ \ \ \ set\ E(meta-inf,tempname)\ \[file\ join\ \$E(meta-inf,tempdir)\ container.xml\]\n\ \ \ \ set\ E(nav,name)\ nav.xhtml\n\ \ \ \ set\ E(nav,tempname)\ \[file\ join\ \$E(epub,tempdir)\ \$E(nav,name)\]\n\ \ \ \ set\ E(cover,source)\ \$cover\n\ \ \ \ set\ E(cover,name)\ \[file\ tail\ \$cover\]\n\ \ \ \ set\ E(cover,format)\ \$::EXT(\[file\ extension\ \$cover\])\n\ \ \ \ set\ E(images)\ \$images\n\ \ \ \ set\ E(date)\ \[clock\ format\ \[clock\ seconds\]\ -gmt\ 1\ -format\ \"%Y-%m-%dT%TZ\"\]\n\n\ \ \ \ file\ mkdir\ \$E(output,tempdir)\n\ \ \ \ file\ mkdir\ \$E(meta-inf,tempdir)\n\ \ \ \ file\ mkdir\ \$E(epub,tempdir)\n\n\ \ \ \ set\ E(guid)\ \"ebook:\$guid\"\n\ \ \ \ set\ E(title)\ \$title\n\ \ \ \ set\ E(author)\ \$author\n\}\nproc\ MakeEpubFiles\ \{\}\ \{\n\ \ \ \ global\ E\n\n\ \ \ \ WriteAllData\ \$E(html,tempname)\ \[TextToHtml\]\n\ \ \ \ WriteAllData\ \$E(mimetype,tempname)\ \"application/epub+zip\"\n\ \ \ \ WriteAllData\ \$E(meta-inf,tempname)\ \[subst\ \$::CONTAINER_XML\]\n\ \ \ \ WriteAllData\ \$E(opf,tempname)\ \[MakeOPF\]\n\ \ \ \ WriteAllData\ \$E(nav,tempname)\ \[subst\ \$::NAV_XHTML\]\n\}\nproc\ TextToHtml\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ fin\ \[open\ \$E(rawname)\ r\]\n\ \ \ \ set\ data\ \[read\ \$fin\]\ \;\ list\n\ \ \ \ close\ \$fin\n\n\ \ \ \ if\ \{\[string\ first\ \"<html\"\ \$data\]\ ==\ -1\}\ \{\n\ \ \ \ \ \ \ \ set\ data\ \[string\ map\ \{&\ &amp\;\ <\ &lt\;\ >\ &gt\;\ \\x22\ &quot\;\ '\ &apos\;\}\ \$data\]\ \;\ list\n\ \ \ \ \ \ \ \ regsub\ -all\ -line\ \{^\$\}\ \$data\ \{</p><p>\}\ data\n\n\ \ \ \ \ \ \ \ set\ data\ \"\[subst\ \$::HTML_TEMPLATE\]\"\ \;\ list\n\ \ \ \ \}\n\ \ \ \ return\ \$data\n\}\nproc\ MakeOPF\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ opf\ \[subst\ \$::CONTENT_OPF\]\n\ \ \ \ if\ \{\$E(cover,source)\ eq\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ regsub\ -all\ -line\ \{^.*id_cover.*\$\}\ \$opf\ \"\"\ opf\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ file\ copy\ \$E(cover,source)\ \$E(epub,tempdir)\n\ \ \ \ \}\n\n\ \ \ \ \;#\ Copy\ any\ additional\ images\n\ \ \ \ set\ image_items\ \"\"\n\ \ \ \ for\ \{set\ i\ 0\}\ \{\$i\ <\ \[llength\ \$E(images)\]\}\ \{incr\ i\}\ \{\n\ \ \ \ \ \ \ \ set\ iname\ \[lindex\ \$E(images)\ \$i\]\n\ \ \ \ \ \ \ \ file\ copy\ \$iname\ \$E(epub,tempdir)\n\ \ \ \ \ \ \ \ set\ tailname\ \[file\ tail\ \$iname\]\n\ \ \ \ \ \ \ \ set\ media\ \$::EXT(\[file\ extension\ \$iname\])\n\ \ \ \ \ \ \ \ set\ id\ \"id_image_\$i\"\n\ \ \ \ \ \ \ \ set\ line\ \"<item\ href=\\\"\$tailname\\\"\ id=\\\"\$id\\\"\ media-type=\\\"\$media\\\"/>\\n\"\n\ \ \ \ \ \ \ \ append\ image_items\ \$line\n\ \ \ \ \}\n\ \ \ \ if\ \{\$image_items\ ne\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ regsub\ -line\ \{^.*other\ images\ go\ here.*\$\}\ \$opf\ \$image_items\ opf\n\ \ \ \ \}\n\ \ \ \ return\ \$opf\n\}\nproc\ ZipEpub\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ cd\ \$E(output,tempdir)\n\ \ \ \ exec\ zip\ -rX\ \$E(output,final)\ \$E(mimetype)\ \$E(meta-inf)/\ \$E(epub)/\n\}\nproc\ WriteAllData\ \{fname\ data\}\ \{\n\ \ \ \ set\ fout\ \[open\ \$fname\ w\]\;\ puts\ -nonewline\ \$fout\ \$data\;\ close\ \$fout\;\n\}\nproc\ Cleanup\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ file\ delete\ -force\ --\ \$E(output,tempdir)\n\}\n################################################################\nset\ HTML_TEMPLATE\ \{<?xml\ version=\"1.0\"?>\n<html\ xmlns=\"http://www.w3.org/1999/xhtml\"\ xml:lang=\"en\"\ lang=\"en\"\n\ \ \ \ \ \ xmlns:epub=\"http://www.idpf.org/2007/ops\">\n\ \ <head>\n\ \ \ \ <title>\$E(title)</title>\n\ \ </head>\n\ \ <body>\n\ \ \ \ <p>\n\ \ \ \ \$data\n\ \ \ \ </p>\n\ \ </body>\n</html>\n\}\n\nset\ CONTAINER_XML\ \{<?xml\ version=\"1.0\"?>\n<container\ version=\"1.0\"\ xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\">\n\ \ <rootfiles>\n\ \ \ \ <rootfile\ media-type=\"application/oebps-package+xml\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ full-path=\"\$E(opf,name)\"\ />\n\ \ </rootfiles>\n</container>\n\}\n\nset\ CONTENT_OPF\ \{<?xml\ version=\"1.0\"\ encoding=\"UTF-8\"?>\n<package\ xmlns=\"http://www.idpf.org/2007/opf\"\ version=\"3.0\"\ unique-identifier=\"uuid\">\n\ \ <metadata\ xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\ xmlns:opf=\"http://www.idpf.org/2007/opf\">\n\ \ \ \ <dc:title>\$E(title)</dc:title>\n\ \ \ \ <dc:creator>\$E(author)</dc:creator>\n\ \ \ \ <dc:identifier\ id=\"uuid\">\$E(guid)</dc:identifier>\n\ \ \ \ <dc:language>en</dc:language>\n\ \ \ \ <meta\ property=\"dcterms:modified\">\$E(date)</meta>\n\ \ \ \ <meta\ name=\"cover\"\ content=\"id_cover\"/>\n\ \ </metadata>\n\ \ <manifest>\n\ \ \ \ <item\ id=\"id_cover\"\ href=\"\$E(cover,name)\"\ media-type=\"\$E(cover,format)\"\ properties=\"cover-image\"/>\n\ \ \ \ <item\ id=\"id_html\"\ href=\"\$E(html,name)\"\ media-type=\"application/xhtml+xml\"/>\n\ \ \ \ <item\ id=\"nav\"\ href=\"nav.xhtml\"\ media-type=\"application/xhtml+xml\"\ properties=\"nav\"/>\n\ \ \ \ <!--\ other\ images\ go\ here\ -->\n\ \ </manifest>\n\ \ <spine>\n\ \ \ \ <itemref\ idref=\"id_html\"/>\n\ \ </spine>\n</package>\n\}\n\nset\ NAV_XHTML\ \{<?xml\ version=\"1.0\"\ encoding=\"UTF-8\"?>\n<html\ xmlns=\"http://www.w3.org/1999/xhtml\"\ xml:lang=\"en\"\ lang=\"en\"\n\ \ \ \ \ \ xmlns:epub=\"http://www.idpf.org/2007/ops\">\n\ \ <head>\n\ \ </head>\n\ \ <body>\n\ \ \ \ <nav\ epub:type=\"toc\"\ id=\"toc\">\n\ \ \ \ \ \ <ol>\n\ \ \ \ \ \ \ \ <li><a\ href=\"\$E(html,name)\">The\ Content</a></li>\n\ \ \ \ \ \ </ol>\n\ \ \ \ </nav>\n\ \ </body>\n</html>\n\}\n\n################################################################\n\nputs\ \"\\nepubCreator\ v0.3\\nby\ Keith\ Vetter\\n\"\nif\ \{\[llength\ \$argv\]\ <\ 3\}\ \{\n\ \ \ \ puts\ stderr\ \"usage:\ epubCreator\ <title>\ <author>\ <data\ file>\ ?<cover\ image>?\ ?<other\ images>...?\"\n\ \ \ \ puts\ stderr\ \"for\ example:\"\n\ \ \ \ puts\ stderr\ \"\ \ epubCreator\ \\\"Pride\ and\ Prejudice\\\"\ \\\"Jane\ Austen\\\"\ p_and_p.xhtml\ cover.jpg\ chapter1.jpg\"\n\ \ \ \ return\n\}\nset\ images\ \[lassign\ \$argv\ title\ author\ fname\ cover\]\n\nInit\ \$fname\ \$title\ \$author\ \$cover\ \$images\n\nMakeEpubFiles\nZipEpub\nCleanup\nputs\ \"created\ \$E(output,final)\"\nreturn\n\n======\n\n----\n'''\[ak\]\ -\ 2014-03-14\ 23:42:26'''\n\n\[Tcllib\]\ contains\ a\ package\n\[https://core.tcl.tk/tcllib/doc/trunk/embedded/www/tcllib/files/modules/zip/encode.html%|%\"zipfile::encode\ (doc)\"\]\nthat\ can\ obviate\ the\ need\ for\ 'exec\ zip'.\ It\ requires\ \[Trf\]\ and\ \[zlibtcl\]\ though.\ Note\ that\ while\ Tcl\ 8.6\ provides\ zip\ functions\ in-core,\ the\ \[Tcllib\]\ package\ currently\ makes\ no\ use\ of\ that.\n\n----\n'''\[clif\ flynt\]\ -\ 2014-07-14\ '''\n\nI\ modified\ and\ extended\ Keith's\ code\ a\ bit.\ \ After\ some\ tweaking,\ I've\ got\ it\ passing\ the\ epubcheck\ validator,\naccepting\ multiple\ files\ and\ a\ couple\ other\ tweaks.\n\nCheck\ the\ comments\ for\ the\ new,\ expanded\ command\ line.\ \n\n======\n\n############################################################################\n#\n#\ epubCreator.tcl\ --\ command\ line\ tool\ to\ create\ an\ epub\ version\ 3.0\n#\ file\ from\ a\ single\ text\ or\ xhmtml\ file,\ an\ optional\ cover\ image\ and\n#\ a\ list\ of\ 0\ or\ more\ images\n#\ by\ Keith\ Vetter\ 2014-03-14\n#\ Mods\ Clif\ Flynt,\ 2014-04-01\n#\ \ Support\ for\ multiple\ text/html\ files\ (multiple\ chapters)\n#\ \ Support\ for\ additional\ .css\ file\n#\ \ Support\ for\ filename.epub\ different\ from\ \"book\ title.epub\"\n#\ \ Support\ for\ toc.ncx\ as\ well\ as\ nav.html\n#\ \ Expanded\ command\ line\ processing\n#\n#\ usage:\ epubCreator\ \\\n#\ -title\ Title\ -author\ 'last,\ first'\ -data\ file1.txt\ file2.html\ file3.xhtml...\\\n#\ -cover\ Cover.jpg\ -images\ additional\ Images\ -css\ Style.css\ -html\ (1/0)\ \\\n#\ -name\ BookName\n#\n#\ \ -title\ \ \ \ \ \ \ Title\ for\ book\n#\ \ -author\ \ \ \ \ \ Name\ of\ author\ as\ last,\ first\n#\ \ -data\ \ \ \ \ \ \ \ List\ of\ data\ files\ to\ include\ in\ the\ text\n#\ \ -cover\ \ \ \ \ \ \ An\ image\ file\ for\ the\ cover\n#\ \ -images\ \ \ \ \ \ Additional\ images\ that\ might\ be\ reference\ by\ text\n#\ \ -css\ \ \ \ \ \ \ \ \ An\ optional\ css\ file\ if\ you\ want\ special\ formatting\n#\ \ -html\ \ \ \ \ \ \ \ 1\ or\ 0\ to\ define\ whether\ the\ input\ data\ is\ already\ in\ html\ format\n#\ \ -name\ \ \ \ \ \ \ \ The\ name\ for\ the\ .epub\ file,\ if\ different\ from\ title\n#\n\npackage\ require\ uuid\npackage\ require\ fileutil\n\narray\ set\ EXT\ \{\"\"\ \"\"\ .png\ image/png\ .gif\ image/gif\ .jpg\ image/jpeg\n\ \ \ \ .jpeg\ image/jpeg\ .svg\ image/svg+xml\}\n\n\n\nproc\ parseList\ \{list\ stateVarName\ \{throwError\ 1\}\}\ \{\n\ \ \ \ upvar\ \$stateVarName\ stateArray\n\n\ \ \ \ set\ errs\ \"\"\n\ \ \ \ \n\ \ \ \ foreach\ arg\ \$list\ \{\n\ \ \ \ \ \ \ \ if\ \{(\[string\ first\ \"-\"\ \$arg\]\ ==\ 0)\ &&\n\ \ \ \ \ \ \ \ \ \ \ \ \ (\[llength\ \$arg\]\ ==\ 1)\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ index\ \[string\ range\ \$arg\ 1\ end\]\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{!\[info\ exists\ stateArray(\$index)\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$throwError\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ error\ \"No\ default\ for\ \$\{stateVarName\}(\$index).\\nValid\ fields\ are\ \[lsort\ \[array\ names\ stateArray\]\]\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ lappend\ errs\ \"No\ default\ for\ \$\{stateVarName\}(\$index)\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ cmd\ set\n\ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\[info\ exists\ cmd\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$cmd\ stateArray(\$index)\ \$arg\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ cmd\ lappend\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\ \n\ \ \ \ \}\n\ \ \ \ return\ \$errs\n\}\n\nproc\ Init\ \{rawname\ title\ author\ cover\ images\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ guid\ \[::uuid::uuid\ generate\]\n\n\ \ \ \ set\ E(rawname)\ \$rawname\n\ \ \ \ set\ E(basename)\ \[file\ tail\ \[file\ rootname\ \$E(rawname)\]\]\n\ \ \ \ set\ E(dirname)\ \[file\ normalize\ \[file\ dirname\ \$E(rawname)\]\]\n\ \ \ \ set\ E(output,tempdir)\ \[file\ join\ \[::fileutil::tempdir\]\ \"epub_\$guid\"\]\n\ \ \ \ if\ \{\$E(name)\ eq\ \"\"\}\ \{\n\ \ \ \ \ \ set\ E(output,final)\ \[file\ join\ \$E(dirname)\ \"\$E(basename).epub\"\]\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ set\ E(output,final)\ \[file\ join\ \$E(dirname)\ \"\$E(name).epub\"\]\n\ \ \ \ \}\n\n\ \ \ \ set\ E(epub)\ EPUB\n\ \ \ \ set\ E(epub,tempdir)\ \[file\ join\ \$E(output,tempdir)\ \$E(epub)\]\n\ \ \ \ set\ E(html,name)\ \"\$E(basename).xhtml\"\n\ \ \ \ set\ E(html,tempname)\ \[file\ join\ \$E(epub,tempdir)\ \"\$E(html,name)\"\]\n\ \ \ \ set\ E(ncx,tempname)\ \[file\ join\ \$E(epub,tempdir)\ \"toc.ncx\"\]\n\ \ \ \ set\ E(opf,name)\ \ \[file\ join\ \$E(epub)\ package.opf\]\n\ \ \ \ set\ E(opf,tempname)\ \ \[file\ join\ \$E(output,tempdir)\ \$E(opf,name)\]\n\ \ \ \ set\ E(mimetype)\ mimetype\n\ \ \ \ set\ E(mimetype,tempname)\ \[file\ join\ \$E(output,tempdir)\ \$E(mimetype)\]\n\ \ \ \ set\ E(meta-inf)\ META-INF\n\ \ \ \ set\ E(meta-inf,tempdir)\ \[file\ join\ \$E(output,tempdir)\ \$E(meta-inf)\]\n\ \ \ \ set\ E(meta-inf,tempname)\ \[file\ join\ \$E(meta-inf,tempdir)\ container.xml\]\n\ \ \ \ set\ E(nav,name)\ nav.xhtml\n\ \ \ \ set\ E(nav,tempname)\ \[file\ join\ \$E(epub,tempdir)\ \$E(nav,name)\]\n\ \ \ \ set\ E(cover,source)\ \$cover\n\ \ \ \ set\ E(cover,name)\ \[file\ tail\ \$cover\]\n\ \ \ \ set\ E(cover,format)\ \$::EXT(\[file\ extension\ \$cover\])\n\ \ \ \ set\ E(images)\ \$images\n\ \ \ \ set\ E(date)\ \[clock\ format\ \[clock\ seconds\]\ -gmt\ 1\ -format\ \"%Y-%m-%dT%TZ\"\]\n\n\ \ \ \ file\ mkdir\ \$E(output,tempdir)\n\ \ \ \ file\ mkdir\ \$E(meta-inf,tempdir)\n\ \ \ \ file\ mkdir\ \$E(epub,tempdir)\n\n\ \ \ \ set\ E(guid)\ \"ebook:\$guid\"\n\ \ \ \ set\ E(title)\ \$title\n\ \ \ \ set\ E(author)\ \$author\n\ \ \ \ \n\ \ \ \ if\ \{\$E(css)\ ne\ \"\"\}\ \{\n\ \ \ \ \ \ set\ E(css,name)\ \$E(css)\n\ \ \ \ \ \ set\ E(css,tempname)\ \[file\ join\ \$E(epub,tempdir)\ stylesheet.css\]\n\ \ \ \ \ \ set\ E(opf,stylesheet)\ \{<item\ href=\"stylesheet.css\"\ id=\"css\"\ media-type=\"text/css\"/>\}\n\ \ \ \ \}\n\}\nproc\ MakeEpubFiles\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ i\ 0\n\ \ \ \ if\ \{\$E(cover,source)\ ne\ \"\"\}\ \{\n\ \ \ \ \ \ set\ E(rawname)\ \[list\ cover.xhtml\ \{*\}\$E(rawname)\]\n\ \ \ \ \ \ set\ of\ \[open\ cover.xhtml\ w\]\n\ \ \ \ \ \ puts\ \$of\ \[BodyToHtml\ \"<img\ src=\\\"\[file\ tail\ \$E(cover,source)\]\\\"></img>\"\]\n\ \ \ \ \ \ close\ \$of\n\ \ \ \ \}\n\ \ \ \ foreach\ rawname\ \$E(rawname)\ \{\n\ \ \ \ \ \ incr\ i\n\ \ \ \ \ \ set\ basename\ \[file\ tail\ \[file\ rootname\ \$rawname\]\]\n\ \ \ \ \ \ set\ E(html,name)\ \"\$basename.xhtml\"\n\ \ \ \ \ \ set\ E(html,tempname)\ \[file\ join\ \$E(epub,tempdir)\ \"\$E(html,name)\"\]\n\ \ \ \ \ \ append\ E(opf,html_items)\ \[subst\ \{\n\ \ \ \ <item\ id=\"id_html_\$i\"\ href=\"\$E(html,name)\"\ media-type=\"application/xhtml+xml\"/>\}\]\n\ \ \ \ \ \ append\ E(opf,ref_items)\ \[subst\ \{\n\ \ \ \ \ \ \ \ <itemref\ idref=\"id_html_\$i\"/>\}\]\n\ \ \ \ \ \ append\ navs\ \[subst\ \$::NAV_XHTML1\]\n\ \ \ \ \ \ append\ ncxs\ \[subst\ \$::CONTENT_NCX1\]\n\ \ \ \ \ \ if\ \{\$E(html)\}\ \{\n\ \ \ \ \ \ \ \ WriteAllData\ \$E(html,tempname)\ \$rawname\n\ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ WriteAllData\ \$E(html,tempname)\ \[TextToHtml\ \$rawname\]\n\ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \ \ WriteAllData\ \$E(mimetype,tempname)\ \"application/epub+zip\"\n\ \ \ \ WriteAllData\ \$E(meta-inf,tempname)\ \[subst\ \$::CONTAINER_XML\]\n\ \ \ \ WriteAllData\ \$E(opf,tempname)\ \[MakeOPF\]\n\ \ \ \ WriteAllData\ \$E(nav,tempname)\ \"\[subst\ \$::NAV_XHTML0\]\\n\$navs\\n\$::NAV_XHTML2\"\n\ \ \ \ WriteAllData\ \$E(ncx,tempname)\ \"\[subst\ \$::CONTENT_NCX0\]\\n\$ncxs\\n\$::CONTENT_NCX2\"\n\ \ \ \ if\ \{\[info\ exists\ E(css,tempname)\]\}\ \{\n\ \ \ \ \ \ WriteAllData\ \$E(css,tempname)\ \$E(css)\n\ \ \ \ \}\n\}\nproc\ TextToHtml\ \{rawname\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ fin\ \[open\ \$rawname\ r\]\n\ \ \ \ set\ data\ \[read\ \$fin\]\ \n\ \ \ \ close\ \$fin\n\n\ \ \ \ if\ \{\[string\ first\ \"<html\"\ \$data\]\ ==\ -1\}\ \{\n\ \ \ \ \ \ \ \ set\ data\ \[string\ map\ \{&\ &amp\;\ <\ &lt\;\ >\ &gt\;\ \\x22\ &quot\;\ '\ &apos\;\}\ \$data\]\ \;\ list\n\ \ \ \ \ \ \ \ regsub\ -all\ -line\ \{^\$\}\ \$data\ \{</p><p>\}\ data\n\n\ \ \ \ \ \ \ \ set\ data\ \"\[subst\ \$::HTML_TEMPLATE\]\"\ \;\ list\n\ \ \ \ \}\n\ \ \ \ return\ \$data\n\}\n\nproc\ BodyToHtml\ \{data\}\ \{\n\ \ \ \ global\ E\n\n\ \ \ \ set\ data\ \"\[subst\ \$::HTML_TEMPLATE\]\"\ \n\ \ \ \ return\ \$data\n\}\n\nproc\ MakeOPF\ \{\}\ \{\n\ \ \ \ global\ E\n\n\ \ \ \ set\ data\ \"\[subst\ \$::HTML_TEMPLATE\]\"\ \n\ \ \ \ return\ \$data\n\}\n\nproc\ MakeOPF\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ set\ html_items\ \{\}\n\ \ \ \ set\ image_items\ \{\}\n\ \ \ \ set\ ref_items\ \{\}\n\ \ \ \ set\ opf\ \[subst\ \$::CONTENT_OPF\]\n\ \ \ \ if\ \{\$E(cover,source)\ eq\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ regsub\ -all\ -line\ \{^.*id_cover.*\$\}\ \$opf\ \"\"\ opf\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ file\ copy\ \$E(cover,source)\ \$E(epub,tempdir)\n\ \ \ \ \}\n\n\ \ \ \ \;#\ Copy\ any\ additional\ images\n\ \ \ \ set\ image_items\ \"\"\n\ \ \ \ for\ \{set\ i\ 0\}\ \{\$i\ <\ \[llength\ \$E(images)\]\}\ \{incr\ i\}\ \{\n\ \ \ \ \ \ \ \ set\ iname\ \[lindex\ \$E(images)\ \$i\]\n\ \ \ \ \ \ \ \ file\ copy\ \$iname\ \$E(epub,tempdir)\n\ \ \ \ \ \ \ \ set\ tailname\ \[file\ tail\ \$iname\]\n\ \ \ \ \ \ \ \ set\ media\ \$::EXT(\[file\ extension\ \$iname\])\n\ \ \ \ \ \ \ \ set\ id\ \"id_image_\$i\"\n\ \ \ \ \ \ \ \ set\ line\ \"<item\ href=\\\"\$tailname\\\"\ id=\\\"\$id\\\"\ media-type=\\\"\$media\\\"/>\\n\"\n\ \ \ \ \ \ \ \ append\ image_items\ \$line\n\ \ \ \ \}\n\ \ \ \ if\ \{\$image_items\ ne\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ regsub\ -line\ \{^.*other\ images\ go\ here.*\$\}\ \$opf\ \$image_items\ opf\n\ \ \ \ \}\n\ \ \ \ return\ \$opf\n\}\nproc\ ZipEpub\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ cd\ \$E(output,tempdir)\n\n\ \ \ \ #\ Get\ rid\ of\ any\ previous\ epub\ else\ zip\ will\ append\ to\ the\n\ \ \ \ #\ existing\ file,\ leaving\ behind\ elements\ you\ thought\ had\ been\ removed\n\ \ \ \ catch\ \{file\ delete\ \$E(output,final)\}\n\ \ \ \ exec\ zip\ -rX\ \$E(output,final)\ \$E(mimetype)\ \$E(meta-inf)/\ \$E(epub)/\n\}\nproc\ WriteAllData\ \{fname\ data\}\ \{\n\ \ \ \ if\ \{\[file\ exists\ \$data\]\}\ \{\n\ \ \ \ \ \ set\ if\ \[open\ \$data\]\n\ \ \ \ \ \ set\ data\ \[read\ \$if\]\n\ \ \ \ \ \ close\ \$if\n\ \ \ \ \}\n\ \ \ \ set\ fout\ \[open\ \$fname\ w\]\;\ \n\ \ \ \ puts\ -nonewline\ \$fout\ \$data\;\ \n\ \ \ \ close\ \$fout\;\n\}\nproc\ Cleanup\ \{\}\ \{\n\ \ \ \ global\ E\n\ \ \ \ file\ delete\ -force\ --\ \$E(output,tempdir)\n\ \ \ \ file\ delete\ cover.xhtml\n\}\nset\ HTML_TEMPLATE\ \{<?xml\ version=\"1.0\"?>\n<html\ xmlns=\"http://www.w3.org/1999/xhtml\"\ xml:lang=\"en\"\ lang=\"en\"\n\ \ \ \ \ \ xmlns:epub=\"http://www.idpf.org/2007/ops\">\n\ \ <head>\n\ \ \ \ <title>\$E(title)</title>\n\ \ \ \ <link\ href=\"stylesheet.css\"\ type=\"text/css\"\ rel=\"stylesheet\"/>\n\ \ </head>\n\ \ <body>\n\ \ \ \ <p>\n\ \ \ \ \$data\n\ \ \ \ </p>\n\ \ </body>\n</html>\n\}\n\nset\ CONTAINER_XML\ \{<?xml\ version=\"1.0\"?>\n<container\ version=\"1.0\"\ xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\">\n\ \ <rootfiles>\n\ \ \ \ <rootfile\ media-type=\"application/oebps-package+xml\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ full-path=\"\$E(opf,name)\"\ />\n\ \ </rootfiles>\n</container>\n\}\n\n#\ NCX\ format\n#\ per:\ http://www.gbenthien.net/Kindle%20and%20EPUB/ncx.html\n\nset\ CONTENT_NCX0\ \{<?xml\ version=\"1.0\"\ encoding=\"UTF-8\"?>\n<ncx\ xmlns=\"http://www.daisy.org/z3986/2005/ncx/\"\ version=\"2005-1\"\ xml:lang=\"en\">\n<head>\n<meta\ name=\"dtb:uid\"\ content=\"\$::E(guid)\"/>\n<meta\ name=\"dtb:depth\"\ content=\"1\"/>\n<meta\ name=\"dtb:totalPageCount\"\ content=\"0\"/>\n<meta\ name=\"dtb:maxPageNumber\"\ content=\"0\"/>\n</head>\n\n\n<docTitle><text>\$::E(name)</text></docTitle>\n<docAuthor><text>\$::E(author)</text></docAuthor>\n\n\n\n<navMap>\n\n\}\nset\ CONTENT_NCX1\ \{\n<navPoint\ id=\"navpoint-\$i\"\ playOrder=\"\$i\">\n<navLabel><text>Chapter\ \$i</text></navLabel>\n<content\ src=\"\$::E(html,name)\"/>\n</navPoint>\n\}\n\nset\ CONTENT_NCX2\ \{\n</navMap>\n</ncx>\n\}\nset\ CONTENT_OPF\ \{<?xml\ version=\"1.0\"\ encoding=\"UTF-8\"?>\n<package\ xmlns=\"http://www.idpf.org/2007/opf\"\ version=\"3.0\"\ unique-identifier=\"uuid\">\n\ \ <metadata\ xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\ xmlns:opf=\"http://www.idpf.org/2007/opf\">\n\ \ \ \ <dc:title>\$E(title)</dc:title>\n\ \ \ \ <dc:creator>\$E(author)</dc:creator>\n\ \ \ \ <dc:identifier\ id=\"uuid\">\$E(guid)</dc:identifier>\n\ \ \ \ <dc:language>en</dc:language>\n\ \ \ \ <meta\ property=\"dcterms:modified\">\$E(date)</meta>\n\ \ \ \ <meta\ name=\"cover\"\ content=\"id_cover\"/>\n\ \ </metadata>\n\ \ <manifest>\n\ \ \ \ \$::E(opf,stylesheet)\n\ \ \ \ <item\ id=\"id_cover\"\ href=\"\$E(cover,name)\"\ media-type=\"\$E(cover,format)\"/>\n\ \ \ \ \$::E(opf,html_items)\n\ \ \ \ <item\ id=\"toc\"\ href=\"toc.ncx\"\ media-type=\"application/x-dtbncx+xml\"\ />\n\ \ \ \ \$image_items\n\ \ \ \ <item\ id=\"nav\"\ href=\"nav.xhtml\"\ media-type=\"application/xhtml+xml\"\ properties=\"nav\"/>\n\ \ </manifest>\n\ \ <spine\ toc=\"toc\">\n\ \ \ \ \$::E(opf,ref_items)\n\ \ </spine>\n</package>\n\}\n\nset\ NAV_XHTML0\ \{<?xml\ version=\"1.0\"\ encoding=\"UTF-8\"?>\n<html\ xmlns=\"http://www.w3.org/1999/xhtml\"\ xml:lang=\"en\"\ lang=\"en\"\n\ \ \ \ \ \ xmlns:epub=\"http://www.idpf.org/2007/ops\">\n\ \ <head>\n\ \ <title>\$::E(name)</title>\n\ \ </head>\n\ \ <body>\n\ \ <nav\ epub:type=\"toc\"\ id=\"toc\">\n\ \ <ol>\n\}\nset\ NAV_XHTML1\ \{\ \ \ \ \ \ <li><a\ href=\"\$E(html,name)\">Chapter\ \$i</a></li>\n\}\nset\ NAV_XHTML2\ \{\n\ \ \ \ </ol>\n\ \ </nav>\n</body>\n</html>\n\}\n\n\nputs\ \"\\nepubCreator\ v0.3\\nby\ Keith\ Vetter\\n\"\nif\ \{\[llength\ \$argv\]\ <\ 3\}\ \{\n\ \ \ \ puts\ stderr\ \"usage:\ epubCreator\ -title\ <title>\ -author\ <author>\ -data\ <data\ file1>\ <data\ file2>\ ...\ -cover\ ?<cover\ image>?\ -images\ ?<other\ images>\ ...?\"\n\ \ \ \ puts\ stderr\ \"for\ example:\"\n\ \ \ \ puts\ stderr\ \"\ \ epubCreator\ -title\ \\\"Pride\ and\ Prejudice\\\"\ -author\ \\\"Austen,\ Jane\\\"\ p_and_p.xhtml\ -cover\ cover.jpg\ chapter1.html\"\n\ \ \ \ return\n\}\n#\ set\ images\ \[lassign\ \$argv\ title\ author\ fname\ cover\]\n\narray\ set\ E\ \{\n\ \ title\ \{\}\n\ \ author\ \{\}\n\ \ data\ \{\}\n\ \ cover\ \{\}\n\ \ images\ \{\}\n\ \ css\ \{\}\n\ \ html\ \{0\}\n\ \ name\ \{\}\n\}\n\ parseList\ \$argv\ E\ 1\n\nInit\ \$E(data)\ \$E(title)\ \$E(author)\ \$E(cover)\ \$E(images)\n\nMakeEpubFiles\n#\ parray\ E\n#\ puts\ \"TMP:\ ..\$E(output,tempdir)..\"\nZipEpub\nCleanup\nputs\ \"created\ \$E(output,final)\"\nreturn\n\n\n<<categories>>Enter\ Category\ Here} CALL {my revision EpubCreator} CALL {::oo::Obj5550113 process revision/EpubCreator} CALL {::oo::Obj5550111 process}

-errorcode

NONE

-errorinfo

Unknow state transition: LINE -> END
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 56)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4