crowdagger / crowbook

Converts books written in Markdown to HTML, LaTeX/PDF and EPUB
GNU Lesser General Public License v2.1
745 stars 38 forks source link

Chapter names are not respected by rendered EPUB. #128

Open risograph opened 1 month ago

risograph commented 1 month ago

Hello. I am converting old books into EPUBs and many of them use Roman numerals to number their chapters. I want to respect this decision, so when creating multiple files for multiple chapters, I precede them with a chapter title (ex. # VIII #). It seems to work fine, but when it renders, crowbook automatically adds a "Chapter [number]" before the Roman number. How can I disable this behavior?

crowdagger commented 2 weeks ago

You can set an option in your .book file, either:

rendering.chapter.template: "{{chapter_title}}"

to disable automatic numbering entirely and do it manually, or

rendering.chapter.roman_numerals: true

To use automatic numbering with roman numbers.

Hope this helps!

risograph commented 1 week ago

Thank you for the support! This issue is still happening with your changes, though. I'll be more specific.

This is my first chapter's source file:

# I #
---

In my younger and more vulnerable years...

and with your change in my config file:

# ...

rendering.chapter.template: "{{{chapter_title}}}"

- src/1-Preface.md
+ src/2-I.md
+ src/3-II.md

# ...

the rendered epub appears like this:

Screenshot 2024-11-20 at 8 59 13 AM

When removing my source header altogether, the chapter simply disappears. I'm sure there is some way around this behavior but this change isn't working for me. After playing around, it seems like rendering.chapter.template simply changes how the chapter's name appears in the table of contents, and not the page itself. For example, setting the value to "FOOBAR" gives me this result:

Screenshot 2024-11-20 at 9 03 34 AM

Is there another template setting I can add that might remove the auto-generated chapter title?

risograph commented 1 week ago
# #
---

In my younger and more vulnerable years

Removing the text within the title does the trick for now.

risograph commented 1 week ago

I got it.

rendering.chapter.roman_numerals: true
rendering.chapter: " "

and

# #
---

In my younger and more vulnerable years...

did the trick.

Screenshot 2024-11-20 at 9 24 57 AM
crowdagger commented 3 hours ago

It's nice that you got it to worked but it's not exactly how it's supposed to work, so it makes more sense to reopen it :sweat_smile: