Repository navigation
Added
- CLI:
--epub-versionselects the EPUB version (3.0or2.0), and--no-coverleaves the default cover page out. Both were only available throughBUPE.Config.
Fixed
- Parser: load the content of items whose
hrefcontains./or../, such as../images/cover.png. They used to come back with an emptycontent. A path that climbs above the root of the archive names no entry. - Parser: raise an exception that says what is wrong when the input is not an EPUB. A file that is not a ZIP archive raises
ArgumentError, a directory or an unreadable file raisesFile.Error, and a container pointing at a package document missing from the archive raisesRuntimeError. These used to surface asUndefinedFunctionError,MatchError, or anArgumentErroraboutraise/1. - Parser: find a package document whose path is percent-encoded in
META-INF/container.xml, such asmy%20dir/package.opf. - Parser: read the text around a child element of a metadata element.
<dc:title>Foo <b>bar</b> baz</dc:title>was cut toFoo bar. - Parser: ignore
metaelements carryingrefineswhen readingsourceandmodified. They describe another element, and one placed beforedc:sourceused to replace its value. - Parser: use the NCX of an EPUB 2 package whose spine does not name it, when the manifest holds exactly one.
tocused to be empty. - Parser: treat only
version="3"andversion="3.x"as EPUB 3. - Parser: read package documents that bind the OPF or the Dublin Core namespace to another prefix, such as
<opf:package>. They used to parse to an empty result without an error. - Builder: percent-encode the
hrefof every file in the package document, the navigation document, the NCX, and the title page. A page namedmy page.xhtml,chapter#1.xhtmlor100%.xhtmlused to produce an EPUB that EPUBCheck rejects. Non-ASCII characters are left as they are, and the entries of the archive keep their names. - Builder: infer the media type of
.webpand.bmpimages; the manifest carried an emptymedia-typefor them. - Builder: raise
ArgumentErrorfor two files whose base names differ only by letter case, such asIndex.xhtmlandindex.xhtml, and for an image that shares its base name with a different logo file. The first pair collided once the EPUB was unpacked on a case-insensitive file system, and the image was silently left out. - Builder: raise
ArgumentErrorfor a file name the container format does not allow: one that contains" * : < > ? \ |, a control or private use character, or ends with a full stop. Such a file was copied into the archive, which EPUBCheck rejects (PKG-009). - Builder: raise
ArgumentErrorwhen anidwould appear twice in the package document or the NCX: two items with the sameid, or an item whoseidis one BUPE writes itself, such asnav,coverorcreator. The EPUB was built with the duplicate, which is not valid. AnidBUPE does not use in a given EPUB stays available, such ascoverwithcover: false. - Builder: return the reason the file system gave, such as
{:error, :eacces}, when the output cannot be written, instead of the crash report of:zip. - CLI: print usage errors to the standard error. They went to the standard output, unlike builder failures.
- CLI: report an output file that cannot be written as
could not write book.epub: permission deniedinstead of printing the reason as an Elixir term.
Changed
- BUPE.parse/2 raises
ArgumentErrorwhen:contentis not a boolean. Any value other thanfalse, includingnil, used to load the content. - BUPE.parse/2 leaves
languageandversionasnilwhen the package document does not declare them. They used to come back as"en"and"3.0", the defaultsBUPE.Confighas for building. - Parser: extract the items through a set of names instead of a list. The time to parse a book grew with the square of its number of files; one with 8,000 files now takes about 0.2 s instead of 0.5 s.
- Builder: compress text files whatever the case of their extension (
PAGE.XHTML), and.mjsscripts. They used to be stored uncompressed. bench/build_parse.exsruns on Elixir 1.17 again.
Full Changelog: v0.9.0...v0.10.0