Skip to content

add-file: Add chapter, book and part options - #1007

Merged
acabal merged 1 commit into
standardebooks:masterfrom
erinendrei:add-file
Aug 18, 2026
Merged

add-file: Add chapter, book and part options#1007
acabal merged 1 commit into
standardebooks:masterfrom
erinendrei:add-file

Conversation

@erinendrei

Copy link
Copy Markdown
Contributor

After reviewing the manual, especially 7.1.5.1, it seemed to make most sense to add both book and part alongside chapter. I know that it varies quite a lot which epub:type is associated with book: it can be division, part, or even chapter; but the templates are always going to need to be edited further by the producer anyway, so I don't think this undermines the utility of being able to quickly generate the basic skeleton with the add-file command.

If you don't think all three of these options are useful, let me know which you want excluded.

Also, contrary to what I said in the issue, it does seem necessary to have a chapter template for this purpose that is distinct from the one used by split-file. Let me know if you disagree about that, or anything else here, and I'll make the necessary changes.

I also noticed a typo in a function name in add-file.py: _replace_languague should be _replace_language. It doesn't affect any functionality because the typo appears throughout. I'll wait until this is merged or closed to fix that in a separate PR.

resolves #1006

Comment thread se/commands/add_file.py Outdated
Comment on lines +153 to +167
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 "book":
dest_path = se_epub.content_path / "text/book-.xhtml"

_copy_file("book-template.xhtml", dest_path, args.force)

_replace_languague(dest_path, se_epub.language)

case "part":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the new options need to be added to the shell completions?

@acabal

acabal commented Aug 18, 2026

Copy link
Copy Markdown
Member

Thanks Erin! As Andrew noted, we also need to add shell completions.

I don't think it makes sense to add both book and part, because the structures are almost identical. Just part will do and the producer can tweak it to fit. I would also remove data-parent, that can be added by the producer if necessary.

The ID should just be part-1. In the chapter, its ID should also just be chapter-1 with no data-parent. Chapter Title must also be a placeholder.

@erinendrei
erinendrei force-pushed the add-file branch 4 times, most recently from b4a9ed5 to a78084b Compare August 18, 2026 20:11
@erinendrei

Copy link
Copy Markdown
Contributor Author

Thanks Andrew and Alex; sorry I missed that. All the changes mentioned should be there now, as well as two others: the xml:lang attribute in the chapter template is now LANG instead of en-US, and alphabetical order in add-file.py reinstated.

@acabal
acabal merged commit 70a5bcc into standardebooks:master Aug 18, 2026
1 check passed
@acabal

acabal commented Aug 18, 2026

Copy link
Copy Markdown
Member

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generic part file in se add-file

3 participants