Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion se/commands/add_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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"

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion se/completions/bash/se
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion se/completions/fish/se.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion se/completions/zsh/_se
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions se/data/templates/chapter-template-add-file.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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/, se: https://standardebooks.org/vocab/1.0" xml:lang="LANG">
<head>
<title>TITLE</title>
<link href="../css/core.css" rel="stylesheet" type="text/css"/>
<link href="../css/local.css" rel="stylesheet" type="text/css"/>
</head>
<body epub:type="bodymatter z3998:fiction">
<section id="chapter-1" epub:type="chapter">
<h2 epub:type="title">TITLE</h2>
<p>TEXT</p>
</section>
</body>
</html>
16 changes: 16 additions & 0 deletions se/data/templates/part-template.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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/, se: https://standardebooks.org/vocab/1.0" xml:lang="LANG">
<head>
<title>Part I</title>
<link href="../css/core.css" rel="stylesheet" type="text/css"/>
<link href="../css/local.css" rel="stylesheet" type="text/css"/>
</head>
<body epub:type="bodymatter z3998:fiction">
<section id="part-1" epub:type="part">
<h3>
<span epub:type="se:label">Part</span>
<span epub:type="z3998:ordinal z3998:roman">I</span>
</h3>
</section>
</body>
</html>