diff --git a/se/commands/add_file.py b/se/commands/add_file.py index 8c5b810ed..35ba55c7b 100644 --- a/se/commands/add_file.py +++ b/se/commands/add_file.py @@ -49,7 +49,7 @@ def add_file(plain_output: bool) -> int: # pylint: disable=unused-argument Entry point for `se add-file`. """ - file_types = ["dedication", "dramatis-personae", "endnotes", "epigraph", "glossary", "halftitlepage", "ignore", "loi"] + file_types = ["chapter", "dedication", "dramatis-personae", "endnotes", "epigraph", "glossary", "halftitlepage", "ignore", "loi", "part"] parser = argparse.ArgumentParser(description="Add a Standard Ebooks template file and any accompanying CSS.", prog="[command]se[/] [subcommand]add-file[/]", formatter_class=SeHelpFormatter) parser.add_argument("-f", "--force", dest="force", action="store_true", help="Overwrite any existing files.") @@ -69,6 +69,13 @@ def add_file(plain_output: bool) -> int: # pylint: disable=unused-argument try: match args.file_type: + case "chapter": + dest_path = se_epub.content_path / "text/chapter-.xhtml" + + _copy_file("chapter-template-add-file.xhtml", dest_path, args.force) + + _replace_languague(dest_path, se_epub.language) + case "dedication": dest_path = se_epub.content_path / "text/dedication.xhtml" @@ -150,6 +157,13 @@ def add_file(plain_output: bool) -> int: # pylint: disable=unused-argument _replace_languague(dest_path, se_epub.language) + case "part": + dest_path = se_epub.content_path / "text/part-.xhtml" + + _copy_file("part-template.xhtml", dest_path, args.force) + + _replace_languague(dest_path, se_epub.language) + case _: # Unrecognized, do nothing. pass diff --git a/se/completions/bash/se b/se/completions/bash/se index 33959ebc2..eaa3e868c 100644 --- a/se/completions/bash/se +++ b/se/completions/bash/se @@ -111,7 +111,7 @@ _se(){ case "${COMP_WORDS[1]}" in add-file) _se_compgen_words "-f --force -h --help" "${cur}" - _se_compgen_words "dedication dramatis-personae endnotes epigraph glossary halftitlepage ignore loi" "${cur}" + _se_compgen_words "chapter dedication dramatis-personae endnotes epigraph glossary halftitlepage ignore loi part" "${cur}" _se_compgen_dirs ".*" "${cur}" ;; british2american) diff --git a/se/completions/fish/se.fish b/se/completions/fish/se.fish index 99d91749c..7a9af648d 100644 --- a/se/completions/fish/se.fish +++ b/se/completions/fish/se.fish @@ -31,7 +31,7 @@ complete -c se -n "__fish_se_no_subcommand" -s v -l version -x -d "Print version complete -c se -n "__fish_se_no_subcommand" -a add-file -d "Add a Standard Ebooks template file and any accompanying CSS." complete -c se -A -n "__fish_seen_subcommand_from add-file" -s f -l force -x -d "Overwrite any existing files." complete -c se -A -n "__fish_seen_subcommand_from add-file" -s h -l help -x -d "Show this help message and exit." -complete -c se -A -n "__fish_seen_subcommand_from add-file" -a "dedication dramatis-personae endnotes epigraph glossary halftitlepage ignore loi" -d "The type of file to add." +complete -c se -A -n "__fish_seen_subcommand_from add-file" -a "chapter dedication dramatis-personae endnotes epigraph glossary halftitlepage ignore loi part" -d "The type of file to add." complete -c se -n "__fish_se_no_subcommand" -a british2american -d "Try to convert British quote style to American quote style. Quotes must already be typogrified using `se` `typogrify`. This script isn’t perfect; proofreading is required, especially near closing quotes near to em-dashes." complete -c se -A -n "__fish_seen_subcommand_from british2american" -s f -l force -x -d "Force conversion of quote style." diff --git a/se/completions/zsh/_se b/se/completions/zsh/_se index 85942b6cd..4ceb6cb8d 100644 --- a/se/completions/zsh/_se +++ b/se/completions/zsh/_se @@ -78,7 +78,7 @@ case $state in _arguments -s \ {-f,--force}'[Overwrite any existing files.]' \ {-h,--help}'[Show this help message and exit.]' \ - '1:The type of file to add.:(dedication dramatis-personae endnotes epigraph glossary halftitlepage ignore loi)' \ + '1:The type of file to add.:(chapter dedication dramatis-personae endnotes epigraph glossary halftitlepage ignore loi part)' \ '*:A Standard Ebooks source directory.:_directories' ;; british2american) diff --git a/se/data/templates/chapter-template-add-file.xhtml b/se/data/templates/chapter-template-add-file.xhtml new file mode 100644 index 000000000..2313e6ee7 --- /dev/null +++ b/se/data/templates/chapter-template-add-file.xhtml @@ -0,0 +1,14 @@ + + + + TITLE + + + + +
+

TITLE

+

TEXT

+
+ + diff --git a/se/data/templates/part-template.xhtml b/se/data/templates/part-template.xhtml new file mode 100644 index 000000000..9e293acaa --- /dev/null +++ b/se/data/templates/part-template.xhtml @@ -0,0 +1,16 @@ + + + + Part I + + + + +
+

+ Part + I +

+
+ +