Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 02-24-2024, 05:32 AM   #1
cheonsangel
Junior Member
cheonsangel began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Feb 2024
Device: none
How to Detect and Format "Side Story" with Calibre

Hello all!

I convert several txt files to epubs via Calibre, and several of these txt files have chapters that I would like to be detected as "Side Story 1" or "Side Story 2-3" etc. etc. I'm going crazy trying to find a way for Calibre's struction detection to detect and consistently format these headers the same as regular chapters.

Taking Calibre's default:
Code:
//*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|section|part\s+', 'i')) or @class = 'chapter']
Changing it to any variation of following does not work as I'd hope:
Code:
//*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|side\s+story|section|part\s+', 'i')) or @class = 'chapter']
Code:
//*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|side\sstory|section|part\s+', 'i')) or @class = 'chapter']
What DOES work is if I change it to either:
Code:
//*[((name()='h1' or name()='h2') and re:test(., '\s*((chapter|book|section|part)\s+)|((prolog|prologue|epilogue)(\s+|$))', 'i')) or @class = 'chapter' or contains(., 'Side Story')]
Code:
//*[(re:test(., '\s*((chapter|book|section|part)\s+)|((prolog|prologue|epilogue)(\s+|$))', 'i')) or @class = 'chapter' or contains(., 'Side Story')]
That being said, while the conversion and detection works to split each Side Story into its own chapter in the TOC, it does not format consistently with the regular chapters.

For example, my regular chapters are auto-formatted to:
Code:
<h2 id="calibre_toc_2" class="calibre4">Chapter 2</h2>
But the Side Story chapters are auto-formatted to:
Code:
<p id="calibre_toc_21" class="calibre3">Side Story 3</p>
I tried Search and Replace to no avail, and don't want to have to change to Markdown for my txt files.

Is there any way to adjust settings so that I can consistently detect and format Side Story chapters to be the same as regularly detected chapters? Any help would be greatly appreciated!
cheonsangel is offline   Reply With Quote
Reply

Tags
calibre, formating title, structure detection, toc, txt conversion

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre "save to disk", "last_modified" field format bodiccea Calibre 20 09-01-2018 04:09 AM
Request: separate "Preferred output format" from "Save to Disk" format Katsunami Calibre 2 08-24-2014 11:23 AM
Free Short Story: "Hunter's Pond" (multi-format) tammycravit Self-Promotions by Authors and Publishers 0 10-29-2010 10:17 PM
converting to "same" format - any side effects? cybmole Calibre 17 09-20-2010 07:16 AM
Getting calibre to detect "Prologue" and "Epilogue" for TOC sherman Calibre 2 09-20-2010 02:21 AM


All times are GMT -4. The time now is 07:59 AM.


MobileRead.com is a privately owned, operated and funded community.