From f7ef917e588f2705f32258fc8e2210ef68a42fc0 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Sun, 23 Jun 2024 12:59:12 -0400 Subject: [PATCH] Add build-loi command for updating an LoI file from
s Text from the
, if any, is preferred over that from the 's alt attribute, though this can be controlled on a per-ID basis. If the resulting text is empty, default_link_text is used. --- se/commands/build_loi.py | 33 +++++ se/completions/bash/se | 6 +- se/completions/fish/se.fish | 7 +- se/completions/zsh/_se | 8 ++ se/se_epub.py | 49 ++++++- .../build-loi/test-1/build-loi-command | 1 + .../test-1/golden/src/epub/content.opf | 125 ++++++++++++++++++ .../golden/src/epub/text/chapter-1.xhtml | 48 +++++++ .../golden/src/epub/text/chapter-2.xhtml | 16 +++ .../golden/src/epub/text/chapter-3.xhtml | 14 ++ .../test-1/golden/src/epub/text/loi.xhtml | 55 ++++++++ .../test-1/golden/src/epub/toc.xhtml | 24 ++++ .../build-loi/test-1/in/src/epub/content.opf | 125 ++++++++++++++++++ .../test-1/in/src/epub/text/chapter-1.xhtml | 48 +++++++ .../test-1/in/src/epub/text/chapter-2.xhtml | 16 +++ .../test-1/in/src/epub/text/chapter-3.xhtml | 14 ++ .../test-1/in/src/epub/text/loi.xhtml | 16 +++ .../build-loi/test-1/in/src/epub/toc.xhtml | 24 ++++ .../help/test-1/golden/help-test-1-out.txt | 1 + .../help/test-2/golden/help-test-2-out.txt | 6 +- 20 files changed, 630 insertions(+), 6 deletions(-) create mode 100644 se/commands/build_loi.py create mode 100644 tests/draft_commands/build-loi/test-1/build-loi-command create mode 100644 tests/draft_commands/build-loi/test-1/golden/src/epub/content.opf create mode 100644 tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-1.xhtml create mode 100644 tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-2.xhtml create mode 100644 tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-3.xhtml create mode 100644 tests/draft_commands/build-loi/test-1/golden/src/epub/text/loi.xhtml create mode 100644 tests/draft_commands/build-loi/test-1/golden/src/epub/toc.xhtml create mode 100644 tests/draft_commands/build-loi/test-1/in/src/epub/content.opf create mode 100644 tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-1.xhtml create mode 100644 tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-2.xhtml create mode 100644 tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-3.xhtml create mode 100644 tests/draft_commands/build-loi/test-1/in/src/epub/text/loi.xhtml create mode 100644 tests/draft_commands/build-loi/test-1/in/src/epub/toc.xhtml diff --git a/se/commands/build_loi.py b/se/commands/build_loi.py new file mode 100644 index 00000000..c0560b14 --- /dev/null +++ b/se/commands/build_loi.py @@ -0,0 +1,33 @@ +""" +This module implements the `se build-loi` command. +""" + +import argparse + +import se +from se.se_epub import SeEpub + + +def build_loi(plain_output: bool) -> int: + """ + Entry point for `se build-loi` + """ + + parser = argparse.ArgumentParser(description="Update the LoI file based on all
elements that contain an .") + parser.add_argument("-a", "--prefer-alt-text", dest="prefer_alt_text", nargs="+", help="prefer alt text over
for these
IDs") + parser.add_argument("-d", "--default-link-text", dest="default_link_text", metavar="DEFAULT-LINK-TEXT", type=str, default="TODO", help="link text to use if
or alt text is absent or empty") + parser.add_argument("directory", metavar="DIRECTORY", help="a Standard Ebooks source directory") + args = parser.parse_args() + + return_code = 0 + + try: + se_epub = SeEpub(args.directory) + prefer_alt_text = set(args.prefer_alt_text or []) + se_epub.generate_loi(prefer_alt_text=prefer_alt_text, default_link_text=args.default_link_text) + + except se.SeException as ex: + se.print_error(ex, plain_output=plain_output) + return_code = ex.code + + return return_code diff --git a/se/completions/bash/se b/se/completions/bash/se index 728df688..1c42b2a4 100644 --- a/se/completions/bash/se +++ b/se/completions/bash/se @@ -2,7 +2,7 @@ _se(){ COMPREPLY=() local cur="${COMP_WORDS[COMP_CWORD]}" local prev="${COMP_WORDS[COMP_CWORD-1]}" - local commands="--help --plain --version british2american build build-ids build-images build-manifest build-spine build-title build-toc clean compare-versions create-draft css-select dec2roman extract-ebook find-mismatched-dashes find-mismatched-diacritics find-unusual-characters help hyphenate interactive-replace lint make-url-safe modernize-spelling prepare-release recompose-epub renumber-endnotes roman2dec semanticate shift-endnotes shift-illustrations split-file titlecase typogrify unicode-names version word-count xpath" + local commands="--help --plain --version british2american build build-ids build-images build-loi build-manifest build-spine build-title build-toc clean compare-versions create-draft css-select dec2roman extract-ebook find-mismatched-dashes find-mismatched-diacritics find-unusual-characters help hyphenate interactive-replace lint make-url-safe modernize-spelling prepare-release recompose-epub renumber-endnotes roman2dec semanticate shift-endnotes shift-illustrations split-file titlecase typogrify unicode-names version word-count xpath" if [[ $COMP_CWORD -gt 1 ]]; then case "${COMP_WORDS[1]}" in british2american) @@ -27,6 +27,10 @@ _se(){ COMPREPLY+=($(compgen -W "-h --help -v --verbose" -- "${cur}")) COMPREPLY+=($(compgen -d -X ".*" -- "${cur}")) ;; + build-loi) + COMPREPLY+=($(compgen -W "-a -d --default-link-text -h --help --prefer-alt-text" -- "${cur}")) + COMPREPLY+=($(compgen -d -X ".*" -- "${cur}")) + ;; build-manifest) COMPREPLY+=($(compgen -W "-h --help -s --stdout" -- "${cur}")) COMPREPLY+=($(compgen -d -X ".*" -- "${cur}")) diff --git a/se/completions/fish/se.fish b/se/completions/fish/se.fish index b0c2a11e..dbe7c95f 100644 --- a/se/completions/fish/se.fish +++ b/se/completions/fish/se.fish @@ -1,6 +1,6 @@ function __fish_se_no_subcommand --description "Test if se has yet to be given the subcommand" for i in (commandline -opc) - if contains -- $i british2american build build-ids build-images build-manifest build-spine build-title build-toc clean compare-versions create-draft css-select dec2roman extract-ebook find-mismatched-dashes find-mismatched-diacritics find-unusual-characters help hyphenate interactive-replace lint make-url-safe modernize-spelling prepare-release recompose-epub renumber-endnotes roman2dec semanticate shift-endnotes shift-illustrations split-file titlecase typogrify unicode-names version word-count xpath + if contains -- $i british2american build build-ids build-images build-loi build-manifest build-spine build-title build-toc clean compare-versions create-draft css-select dec2roman extract-ebook find-mismatched-dashes find-mismatched-diacritics find-unusual-characters help hyphenate interactive-replace lint make-url-safe modernize-spelling prepare-release recompose-epub renumber-endnotes roman2dec semanticate shift-endnotes shift-illustrations split-file titlecase typogrify unicode-names version word-count xpath return 1 end end @@ -114,6 +114,11 @@ complete -c se -A -n "__fish_seen_subcommand_from prepare-release" -s r -l no-re complete -c se -A -n "__fish_seen_subcommand_from prepare-release" -s w -l no-word-count -d "don’t calculate word count" complete -c se -A -n "__fish_seen_subcommand_from prepare-release" -s v -l verbose -d "increase output verbosity" +complete -c se -n "__fish_se_no_subcommand" -a build-loi -d "Update the LoI file based on all
elements that contain an ." +complete -c se -A -n "__fish_seen_subcommand_from build-loi" -s a -l prefer-alt-text -d "prefer alt text over
for these
IDs" +complete -c se -A -n "__fish_seen_subcommand_from build-loi" -s d -l default-link-text -d "link text to use if
or alt text is absent or empty" +complete -c se -A -n "__fish_seen_subcommand_from build-loi" -s h -l help -x -d "show this help message and exit" + complete -c se -n "__fish_se_no_subcommand" -a build-manifest -d "Generate the element for the given Standard Ebooks source directory and write it to the ebook’s metadata file." complete -c se -A -n "__fish_seen_subcommand_from build-manifest" -s h -l help -x -d "show this help message and exit" complete -c se -A -n "__fish_seen_subcommand_from build-manifest" -s s -l stdout -d "print to stdout instead of writing to the metadata file" diff --git a/se/completions/zsh/_se b/se/completions/zsh/_se index 59f9533c..c1973249 100644 --- a/se/completions/zsh/_se +++ b/se/completions/zsh/_se @@ -16,6 +16,7 @@ case $state in "build[Build an ebook from a Standard Ebook source directory.]" \ "build-ids[Change ID attributes for non-sectioning content to their expected values across the entire ebook. IDs must be globally unique and correctly referenced, and the ebook spine must be complete.]" \ "build-images[Build ebook cover and titlepage images in a Standard Ebook source directory.]" \ + "build-loi[Update the LoI file based on all
elements that contain an .]" \ "build-manifest[Generate the element for the given Standard Ebooks source directory and write it to the ebook’s metadata file.]" \ "build-spine[Generate the element for the given Standard Ebooks source directory and write it to the ebook’s metadata file.]" \ "build-title[Generate the title of an XHTML file based on its headings and update the file’s element.]" \ @@ -83,6 +84,13 @@ case $state in {-v,--verbose}'[increase output verbosity]' \ '*: :_directories' ;; + build-loi) + _arguments -s \ + {-a,--prefer-alt-text}'[prefer alt text over <figcaption> for these <figure> IDs]' \ + {-d,--default-link-text}'[link text to use if <figcaption> or alt text is absent or empty]' \ + {-h,--help}'[show a help message and exit]' \ + '*: :_directories' + ;; build-manifest) _arguments -s \ {-h,--help}'[show a help message and exit]' \ diff --git a/se/se_epub.py b/se/se_epub.py index 06857dce..aa4d8b80 100644 --- a/se/se_epub.py +++ b/se/se_epub.py @@ -8,7 +8,7 @@ import datetime import os from pathlib import Path -from typing import Dict, List, Optional, Tuple, Union +from typing import Dict, List, Optional, Tuple, Union, Set import git from lxml import etree @@ -913,6 +913,53 @@ def shift_illustrations(self, target_illustration_number: int, step: int = 1) -> with open(file_path, "w", encoding="utf-8") as file: file.write(dom.to_string()) + def generate_loi(self, prefer_alt_text: Set[str], default_link_text: str) -> None: + """ + Updates the LoI file based on all <figure> elements that contain an + <img>. Text from the <figcaption>, if any, is preferred over that from + the <img>'s alt attribute, unless prefer_alt_text contains the + <figure>'s ID. If the resulting text is empty, default_link_text is used. + """ + + figures = [] + for file_path in self.spine_file_paths: + dom = self.get_dom(file_path) + + for node in dom.xpath("/html/body//figure[@id and img]"): + figcaption = node.xpath("./figcaption") + figure_id = node.get_attr('id') + text = "" + if figcaption and figure_id not in prefer_alt_text: + text = figcaption[0].inner_text() + else: + text = node.xpath("./img")[0].get_attr("alt") + + figures.append((f"{file_path.name}#{figure_id}", text)) + + dom = self.get_dom(self.loi_path) + + ols = dom.xpath("/html/body/nav/ol") + if len(ols) != 1: + raise se.InvalidSeEbookException(f"LoI file contains unexpected number of [html]<ol/>[/]: [path][link=file://{self.loi_path}]{self.loi_path}[/][/].") + + etree.strip_elements(ols[0].lxml_element, "li") + + for (href, text) in figures: + a = se.easy_xml.EasyXmlElement("<a/>") + a.set_text(text or default_link_text) + a.set_attr("href", href) + p = se.easy_xml.EasyXmlElement("<p/>") + p.append(a) + li = se.easy_xml.EasyXmlElement("<li/>") + li.append(p) + ols[0].append(li) + + try: + with open(self.loi_path, "w", encoding="utf-8") as file: + file.write(se.formatting.format_xhtml(dom.to_string())) + except Exception as ex: + raise se.InvalidSeEbookException(f"Couldn’t open LoI file: [path][link=file://{self.loi_path}]{self.loi_path}[/][/].") from ex + def set_release_timestamp(self) -> None: """ If this ebook has not yet been released, set the first release timestamp in the metadata file. diff --git a/tests/draft_commands/build-loi/test-1/build-loi-command b/tests/draft_commands/build-loi/test-1/build-loi-command new file mode 100644 index 00000000..d85398bd --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/build-loi-command @@ -0,0 +1 @@ +build-loi -a 'f-8' -d 'placeholder text' diff --git a/tests/draft_commands/build-loi/test-1/golden/src/epub/content.opf b/tests/draft_commands/build-loi/test-1/golden/src/epub/content.opf new file mode 100644 index 00000000..65934188 --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/golden/src/epub/content.opf @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="utf-8"?> +<package xmlns="http://www.idpf.org/2007/opf" dir="ltr" prefix="se: https://standardebooks.org/vocab/1.0" unique-identifier="uid" version="3.0" xml:lang="en-US"> + <metadata xmlns:dc="http://purl.org/dc/elements/1.1/"> + <dc:identifier id="uid">url:https://standardebooks.org/ebooks/samuel-pepys/the-diary</dc:identifier> + <dc:date>2019-08-21T18:40:45Z</dc:date> + <meta property="dcterms:modified">2019-08-21T18:40:45Z</meta> + <dc:rights>The source text and artwork in this ebook are believed to be in the United States public domain; that is, they are believed to be free of copyright restrictions in the United States. They may still be copyrighted in other countries, so users located outside of the United States must check their local laws before using this ebook. The creators of, and contributors to, this ebook dedicate their contributions to the worldwide public domain via the terms in the [CC0 1.0 Universal Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/).</dc:rights> + <dc:publisher id="publisher">Standard Ebooks</dc:publisher> + <meta property="file-as" refines="#publisher">Standard Ebooks</meta> + <meta property="se:url.homepage" refines="#publisher">https://standardebooks.org</meta> + <meta property="role" refines="#publisher" scheme="marc:relators">bkd</meta> + <meta property="role" refines="#publisher" scheme="marc:relators">mdc</meta> + <meta property="role" refines="#publisher" scheme="marc:relators">pbl</meta> + <dc:contributor id="type-designer">The League of Moveable Type</dc:contributor> + <meta property="file-as" refines="#type-designer">League of Moveable Type, The</meta> + <meta property="se:url.homepage" refines="#type-designer">https://www.theleagueofmoveabletype.com</meta> + <meta property="role" refines="#type-designer" scheme="marc:relators">tyd</meta> + <link href="http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa" rel="dcterms:conformsTo"/> + <meta property="a11y:certifiedBy">Standard Ebooks</meta> + <meta property="schema:accessMode">textual</meta> + <meta property="schema:accessModeSufficient">textual</meta> + <meta property="schema:accessibilityFeature">readingOrder</meta> + <meta property="schema:accessibilityFeature">structuralNavigation</meta> + <meta property="schema:accessibilityFeature">tableOfContents</meta> + <meta property="schema:accessibilityHazard">none</meta> + <meta property="schema:accessibilitySummary">This publication conforms to WCAG 2.2 Level AA.</meta> + <link href="onix.xml" media-type="application/xml" properties="onix" rel="record"/> + <dc:title id="title">The Diary</dc:title> + <meta property="file-as" refines="#title">Diary, The</meta> + <dc:subject id="subject-1">Pepys, Samuel, 1633-1703 -- Diaries</dc:subject> + <dc:subject id="subject-2">Cabinet officers -- Great Britain -- Diaries</dc:subject> + <dc:subject id="subject-3">Diarists -- Great Britain -- Diaries</dc:subject> + <dc:subject id="subject-4">Great Britain -- Social life and customs -- 17th century -- Sources</dc:subject> + <dc:subject id="subject-5">Great Britain -- History -- Charles II, 1660-1685 -- Sources</dc:subject> + <meta property="authority" refines="#subject-1">LCSH</meta> + <meta property="term" refines="#subject-1">Unknown</meta> + <meta property="authority" refines="#subject-2">LCSH</meta> + <meta property="term" refines="#subject-2">sh2008100004</meta> + <meta property="authority" refines="#subject-3">LCSH</meta> + <meta property="term" refines="#subject-3">Unknown</meta> + <meta property="authority" refines="#subject-4">LCSH</meta> + <meta property="term" refines="#subject-4">sh2007100274</meta> + <meta property="authority" refines="#subject-5">LCSH</meta> + <meta property="term" refines="#subject-5">sh2008115250</meta> + <meta property="se:subject">Autobiography</meta> + <meta property="se:subject">Nonfiction</meta> + <dc:description id="description">The diary of a man living in London in the 17th century.</dc:description> + <meta id="long-description" property="se:long-description" refines="#description"> + <p>Pepys’ <i>Diary</i> is an incredibly frank decade-long snapshot of the life of an up and coming naval administrator in mid-17th century London. In it he describes everything from battles against the Dutch and the intrigues of court, down to the plays he saw, his marital infidelities, and the quality of the meat provided for his supper. His observations have proved invaluable in establishing an accurate record of the daily life of the people of London of that period.</p> + <p>Pepys eventually stopped writing his diary due to progressively worse eyesight, a condition he feared. He did consider employing an amanuensis to transcribe future entries for him, but worried that the content he wanted written would be too personal. Luckily for Pepys, his eyesight difficulties never progressed to blindness and he was able to go on to become both a Member of Parliament and the President of the Royal Society.</p> + <p>After Pepys’ death he left his large library of books and manuscripts first to his nephew, which was then passed on to Magdalene College, Cambridge, where it survives to this day. The diary, originally written in a shorthand, was included in this trove and was eventually deciphered in the early 19th century, and published by Lord Baybrooke in 1825. This early release censored large amounts of the text, and it was only in the 1970s that an uncensored version was published. Presented here is the 1893 edition, which restores the majority of the originally censored content but omits “a few passages which cannot possibly be printed.” The rich collection of endnotes serve to further illustrate the lives of the people Pepys meets and the state of England’s internal politics and international relations at the time.</p> + </meta> + <dc:language>en-GB</dc:language> + <dc:source>https://www.gutenberg.org/ebooks/4200</dc:source> + <dc:source>https://archive.org/details/diaryofsamuelpep01pepy</dc:source> + <meta property="se:production-notes"> + • Volumes 9 and 10 (appendix and Pepysiana) of the original series have been omitted from the production due to time constraints. + • Each diary entry has a time element to start. The datetime attribute is ISO8601 compliant (Gregorian), but the actual dates Pepys uses are Julian, so they don’t appear to match. This is correct. + • This date is copied into the `entry-x` id attribute for each diary entry. Unfortunately, this causes linting to fail with leading 0 errors, so we remove those for the id. + </meta> + <meta property="se:word-count">1209949</meta> + <meta property="se:reading-ease.flesch">70.57</meta> + <meta property="se:url.encyclopedia.wikipedia">https://en.wikipedia.org/wiki/Samuel_Pepys#The_diary</meta> + <meta property="se:url.vcs.github">https://github.com/standardebooks/samuel-pepys_the-diary</meta> + <dc:creator id="author">Samuel Pepys</dc:creator> + <meta property="file-as" refines="#author">Pepys, Samuel</meta> + <meta property="se:url.encyclopedia.wikipedia" refines="#author">https://en.wikipedia.org/wiki/Samuel_Pepys</meta> + <meta property="se:url.authority.nacoaf" refines="#author">http://id.loc.gov/authorities/names/n79018796</meta> + <meta property="role" refines="#author" scheme="marc:relators">aut</meta> + <dc:contributor id="artist">John Hayls</dc:contributor> + <meta property="file-as" refines="#artist">Hayls, John</meta> + <meta property="se:url.encyclopedia.wikipedia" refines="#artist">https://en.wikipedia.org/wiki/John_Hayls</meta> + <meta property="se:url.authority.nacoaf" refines="#artist">http://id.loc.gov/authorities/names/nr94041870</meta> + <meta property="role" refines="#artist" scheme="marc:relators">art</meta> + <dc:contributor id="editor-1">Henry B. Wheatley</dc:contributor> + <meta property="file-as" refines="#editor-1">Wheatley, Henry B.</meta> + <meta property="se:name.person.full-name" refines="#editor-1">Henry Benjamin Wheatley</meta> + <meta property="se:url.encyclopedia.wikipedia" refines="#editor-1">https://en.wikipedia.org/wiki/Henry_B._Wheatley</meta> + <meta property="se:url.authority.nacoaf" refines="#editor-1">http://id.loc.gov/authorities/names/n87860971</meta> + <meta property="role" refines="#editor-1" scheme="marc:relators">aft</meta> + <meta property="role" refines="#editor-1" scheme="marc:relators">ann</meta> + <meta property="role" refines="#editor-1" scheme="marc:relators">aui</meta> + <meta property="role" refines="#editor-1" scheme="marc:relators">edt</meta> + <meta property="role" refines="#editor-1" scheme="marc:relators">trc</meta> + <dc:contributor id="annotator-1">Richard Griffin</dc:contributor> + <meta property="display-seq" refines="#annotator-1">0</meta> + <meta property="file-as" refines="#annotator-1">Griffin, Richard</meta> + <meta property="se:url.encyclopedia.wikipedia" refines="#annotator-1">https://en.wikipedia.org/wiki/Richard_Griffin,_3rd_Baron_Braybrooke</meta> + <meta property="se:url.authority.nacoaf" refines="#annotator-1">http://id.loc.gov/authorities/names/n50014973</meta> + <meta property="role" refines="#annotator-1" scheme="marc:relators">ann</meta> + <meta property="role" refines="#annotator-1" scheme="marc:relators">cns</meta> + <meta property="role" refines="#annotator-1" scheme="marc:relators">ill</meta> + <dc:contributor id="transcriber-1">David Widger</dc:contributor> + <meta property="file-as" refines="#transcriber-1">Widger, David</meta> + <meta property="se:url.authority.nacoaf" refines="#transcriber-1">http://id.loc.gov/authorities/names/no2011017869</meta> + <meta property="role" refines="#transcriber-1" scheme="marc:relators">trc</meta> + <dc:contributor id="producer-1">Robin Whittleton</dc:contributor> + <meta property="file-as" refines="#producer-1">Whittleton, Robin</meta> + <meta property="se:url.homepage" refines="#producer-1">https://www.robinwhittleton.com</meta> + <meta property="role" refines="#producer-1" scheme="marc:relators">bkp</meta> + <meta property="role" refines="#producer-1" scheme="marc:relators">blw</meta> + <meta property="role" refines="#producer-1" scheme="marc:relators">cov</meta> + <meta property="role" refines="#producer-1" scheme="marc:relators">mrk</meta> + <meta property="role" refines="#producer-1" scheme="marc:relators">pfr</meta> + <meta property="role" refines="#producer-1" scheme="marc:relators">trc</meta> + <meta property="role" refines="#producer-1" scheme="marc:relators">tyg</meta> + <dc:contributor id="producer-2">David Grigg</dc:contributor> + <meta property="file-as" refines="#producer-2">Grigg, David</meta> + <meta property="se:url.homepage" refines="#producer-2">https://rightword.com.au/david.php</meta> + <meta property="role" refines="#producer-2" scheme="marc:relators">pfr</meta> + </metadata> + <manifest> + <item href="text/chapter-1.xhtml" id="chapter-1.xhtml" media-type="application/xhtml+xml"/> + <item href="text/chapter-2.xhtml" id="chapter-2.xhtml" media-type="application/xhtml+xml"/> + <item href="text/chapter-3.xhtml" id="chapter-3.xhtml" media-type="application/xhtml+xml"/> + <item href="text/loi.xhtml" id="loi.xhtml" media-type="application/xhtml+xml"/> + <item href="toc.xhtml" id="toc.xhtml" media-type="application/xhtml+xml" properties="nav"/> + </manifest> + <spine> + <itemref idref="chapter-1.xhtml"/> + <itemref idref="chapter-2.xhtml"/> + <itemref idref="chapter-3.xhtml"/> + <itemref idref="loi.xhtml"/> + </spine> +</package> diff --git a/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-1.xhtml b/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-1.xhtml new file mode 100644 index 00000000..fbe417d2 --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-1.xhtml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" epub:prefix="z3998: http://www.daisy.org/z3998/2012/vocab/structure/" xml:lang="en-GB"> + <head> + <title>I + + + + +
+

I

+ + +
+ +
+ + +
+ +
+
+ +
+
+ +
+
+
+ a b +
+
+ +
C D
+
+
+ e +
F
+
+ +
+
+ g +
H
+
+
+
+ + diff --git a/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-2.xhtml b/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-2.xhtml new file mode 100644 index 00000000..4224085d --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-2.xhtml @@ -0,0 +1,16 @@ + + + + II + + + + +
+

II

+
+ +
+
+ + diff --git a/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-3.xhtml b/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-3.xhtml new file mode 100644 index 00000000..d320972b --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-3.xhtml @@ -0,0 +1,14 @@ + + + + III + + + + +
+

III

+ +
+ + diff --git a/tests/draft_commands/build-loi/test-1/golden/src/epub/text/loi.xhtml b/tests/draft_commands/build-loi/test-1/golden/src/epub/text/loi.xhtml new file mode 100644 index 00000000..c85e114b --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/golden/src/epub/text/loi.xhtml @@ -0,0 +1,55 @@ + + + + List of Illustrations + + + + + + + diff --git a/tests/draft_commands/build-loi/test-1/golden/src/epub/toc.xhtml b/tests/draft_commands/build-loi/test-1/golden/src/epub/toc.xhtml new file mode 100644 index 00000000..7f47198a --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/golden/src/epub/toc.xhtml @@ -0,0 +1,24 @@ + + + + Table of Contents + + + + + + diff --git a/tests/draft_commands/build-loi/test-1/in/src/epub/content.opf b/tests/draft_commands/build-loi/test-1/in/src/epub/content.opf new file mode 100644 index 00000000..65934188 --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/in/src/epub/content.opf @@ -0,0 +1,125 @@ + + + + url:https://standardebooks.org/ebooks/samuel-pepys/the-diary + 2019-08-21T18:40:45Z + 2019-08-21T18:40:45Z + The source text and artwork in this ebook are believed to be in the United States public domain; that is, they are believed to be free of copyright restrictions in the United States. They may still be copyrighted in other countries, so users located outside of the United States must check their local laws before using this ebook. The creators of, and contributors to, this ebook dedicate their contributions to the worldwide public domain via the terms in the [CC0 1.0 Universal Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/). + Standard Ebooks + Standard Ebooks + https://standardebooks.org + bkd + mdc + pbl + The League of Moveable Type + League of Moveable Type, The + https://www.theleagueofmoveabletype.com + tyd + + Standard Ebooks + textual + textual + readingOrder + structuralNavigation + tableOfContents + none + This publication conforms to WCAG 2.2 Level AA. + + The Diary + Diary, The + Pepys, Samuel, 1633-1703 -- Diaries + Cabinet officers -- Great Britain -- Diaries + Diarists -- Great Britain -- Diaries + Great Britain -- Social life and customs -- 17th century -- Sources + Great Britain -- History -- Charles II, 1660-1685 -- Sources + LCSH + Unknown + LCSH + sh2008100004 + LCSH + Unknown + LCSH + sh2007100274 + LCSH + sh2008115250 + Autobiography + Nonfiction + The diary of a man living in London in the 17th century. + + <p>Pepys’ <i>Diary</i> is an incredibly frank decade-long snapshot of the life of an up and coming naval administrator in mid-17th century London. In it he describes everything from battles against the Dutch and the intrigues of court, down to the plays he saw, his marital infidelities, and the quality of the meat provided for his supper. His observations have proved invaluable in establishing an accurate record of the daily life of the people of London of that period.</p> + <p>Pepys eventually stopped writing his diary due to progressively worse eyesight, a condition he feared. He did consider employing an amanuensis to transcribe future entries for him, but worried that the content he wanted written would be too personal. Luckily for Pepys, his eyesight difficulties never progressed to blindness and he was able to go on to become both a Member of Parliament and the President of the Royal Society.</p> + <p>After Pepys’ death he left his large library of books and manuscripts first to his nephew, which was then passed on to Magdalene College, Cambridge, where it survives to this day. The diary, originally written in a shorthand, was included in this trove and was eventually deciphered in the early 19th century, and published by Lord Baybrooke in 1825. This early release censored large amounts of the text, and it was only in the 1970s that an uncensored version was published. Presented here is the 1893 edition, which restores the majority of the originally censored content but omits “a few passages which cannot possibly be printed.” The rich collection of endnotes serve to further illustrate the lives of the people Pepys meets and the state of England’s internal politics and international relations at the time.</p> + + en-GB + https://www.gutenberg.org/ebooks/4200 + https://archive.org/details/diaryofsamuelpep01pepy + + • Volumes 9 and 10 (appendix and Pepysiana) of the original series have been omitted from the production due to time constraints. + • Each diary entry has a time element to start. The datetime attribute is ISO8601 compliant (Gregorian), but the actual dates Pepys uses are Julian, so they don’t appear to match. This is correct. + • This date is copied into the `entry-x` id attribute for each diary entry. Unfortunately, this causes linting to fail with leading 0 errors, so we remove those for the id. + + 1209949 + 70.57 + https://en.wikipedia.org/wiki/Samuel_Pepys#The_diary + https://github.com/standardebooks/samuel-pepys_the-diary + Samuel Pepys + Pepys, Samuel + https://en.wikipedia.org/wiki/Samuel_Pepys + http://id.loc.gov/authorities/names/n79018796 + aut + John Hayls + Hayls, John + https://en.wikipedia.org/wiki/John_Hayls + http://id.loc.gov/authorities/names/nr94041870 + art + Henry B. Wheatley + Wheatley, Henry B. + Henry Benjamin Wheatley + https://en.wikipedia.org/wiki/Henry_B._Wheatley + http://id.loc.gov/authorities/names/n87860971 + aft + ann + aui + edt + trc + Richard Griffin + 0 + Griffin, Richard + https://en.wikipedia.org/wiki/Richard_Griffin,_3rd_Baron_Braybrooke + http://id.loc.gov/authorities/names/n50014973 + ann + cns + ill + David Widger + Widger, David + http://id.loc.gov/authorities/names/no2011017869 + trc + Robin Whittleton + Whittleton, Robin + https://www.robinwhittleton.com + bkp + blw + cov + mrk + pfr + trc + tyg + David Grigg + Grigg, David + https://rightword.com.au/david.php + pfr + + + + + + + + + + + + + + + diff --git a/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-1.xhtml b/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-1.xhtml new file mode 100644 index 00000000..fbe417d2 --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-1.xhtml @@ -0,0 +1,48 @@ + + + + I + + + + +
+

I

+ + +
+ +
+ + +
+ +
+
+ +
+
+ +
+
+
+ a b +
+
+ +
C D
+
+
+ e +
F
+
+ +
+
+ g +
H
+
+
+
+ + diff --git a/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-2.xhtml b/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-2.xhtml new file mode 100644 index 00000000..4224085d --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-2.xhtml @@ -0,0 +1,16 @@ + + + + II + + + + +
+

II

+
+ +
+
+ + diff --git a/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-3.xhtml b/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-3.xhtml new file mode 100644 index 00000000..d320972b --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-3.xhtml @@ -0,0 +1,14 @@ + + + + III + + + + +
+

III

+ +
+ + diff --git a/tests/draft_commands/build-loi/test-1/in/src/epub/text/loi.xhtml b/tests/draft_commands/build-loi/test-1/in/src/epub/text/loi.xhtml new file mode 100644 index 00000000..68a3b6cc --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/in/src/epub/text/loi.xhtml @@ -0,0 +1,16 @@ + + + + List of Illustrations + + + + + + + diff --git a/tests/draft_commands/build-loi/test-1/in/src/epub/toc.xhtml b/tests/draft_commands/build-loi/test-1/in/src/epub/toc.xhtml new file mode 100644 index 00000000..7f47198a --- /dev/null +++ b/tests/draft_commands/build-loi/test-1/in/src/epub/toc.xhtml @@ -0,0 +1,24 @@ + + + + Table of Contents + + + + + + diff --git a/tests/stdout_commands/help/test-1/golden/help-test-1-out.txt b/tests/stdout_commands/help/test-1/golden/help-test-1-out.txt index 99d4b879..bdda74c9 100644 --- a/tests/stdout_commands/help/test-1/golden/help-test-1-out.txt +++ b/tests/stdout_commands/help/test-1/golden/help-test-1-out.txt @@ -3,6 +3,7 @@ british2american build build-ids build-images +build-loi build-manifest build-spine build-title diff --git a/tests/stdout_commands/help/test-2/golden/help-test-2-out.txt b/tests/stdout_commands/help/test-2/golden/help-test-2-out.txt index c6db58a5..cd8ca109 100644 --- a/tests/stdout_commands/help/test-2/golden/help-test-2-out.txt +++ b/tests/stdout_commands/help/test-2/golden/help-test-2-out.txt @@ -4,9 +4,9 @@ The entry point for the Standard Ebooks toolset. positional arguments: COMMAND one of: british2american build build-ids build-images build- - manifest build-spine build-title build-toc clean compare- - versions create-draft css-select dec2roman extract-ebook - find-mismatched-dashes find-mismatched-diacritics find- + loi build-manifest build-spine build-title build-toc clean + compare-versions create-draft css-select dec2roman extract- + ebook find-mismatched-dashes find-mismatched-diacritics find- unusual-characters help hyphenate interactive-replace lint make-url-safe modernize-spelling prepare-release recompose- epub renumber-endnotes roman2dec semanticate shift-endnotes