Skip to content

v0.10.0

Latest

Choose a tag to compare

@milmazz milmazz released this 30 Nov 00:14

Added

  • CLI: --epub-version selects the EPUB version (3.0 or 2.0), and --no-cover leaves the default cover page out. Both were only available through BUPE.Config.

Fixed

  • Parser: load the content of items whose href contains ./ or ../, such as ../images/cover.png. They used to come back with an empty content. 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 raises File.Error, and a container pointing at a package document missing from the archive raises RuntimeError. These used to surface as UndefinedFunctionError, MatchError, or an ArgumentError about raise/1.
  • Parser: find a package document whose path is percent-encoded in META-INF/container.xml, such as my%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 to Foo bar.
  • Parser: ignore meta elements carrying refines when reading source and modified. They describe another element, and one placed before dc:source used 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. toc used to be empty.
  • Parser: treat only version="3" and version="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 href of every file in the package document, the navigation document, the NCX, and the title page. A page named my page.xhtml, chapter#1.xhtml or 100%.xhtml used 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 .webp and .bmp images; the manifest carried an empty media-type for them.
  • Builder: raise ArgumentError for two files whose base names differ only by letter case, such as Index.xhtml and index.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 ArgumentError for 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 ArgumentError when an id would appear twice in the package document or the NCX: two items with the same id, or an item whose id is one BUPE writes itself, such as nav, cover or creator. The EPUB was built with the duplicate, which is not valid. An id BUPE does not use in a given EPUB stays available, such as cover with cover: 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 denied instead of printing the reason as an Elixir term.

Changed

  • BUPE.parse/2 raises ArgumentError when :content is not a boolean. Any value other than false, including nil, used to load the content.
  • BUPE.parse/2 leaves language and version as nil when the package document does not declare them. They used to come back as "en" and "3.0", the defaults BUPE.Config has 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 .mjs scripts. They used to be stored uncompressed.
  • bench/build_parse.exs runs on Elixir 1.17 again.

Full Changelog: v0.9.0...v0.10.0