![]() |
#1 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 769
Karma: 1537886
Join Date: Sep 2013
Device: Kobo Forma
|
Need Help w/ Reformatting Chapter Headings
I'd appreciate any help in how to go about reformatting the chapter headings in this book. It's Glen Cook's "A Cruel Wind":
https://www.amazon.com/gp/product/B0...w_myk_ro_title This is a fresh download of the AZW3 from my Amazon library. What I'm showing here is from my Calibre converted epub, but I've checked the source AZW3 and KindleUnpack versions and they look pretty much the same. Here's an example of what all the chapter headers look like: Code:
<p class="calibre7"><br class="calibre1" id="filepos21832"/> </p> <p class="whitespace"></p> <p class="calibre7"><span class="calibre18">O</span></p> <p class="calibre7"><span class="calibre19">NE:</span></p> <p class="calibre7"><span class="calibre18">T</span></p> <p class="calibre7"><span class="calibre19">HE</span></p> <p class="calibre7"><span class="calibre18">Y</span></p> <p class="calibre7"><span class="calibre19">EARS 583-590 AFE</span></p> <p class="whitespace"></p> <p class="calibre7"><span class="calibre18">H</span></p> <p class="calibre7"><span class="calibre24">E</span></p> <p class="calibre7"><span class="calibre18">I</span></p> <p class="calibre7"><span class="calibre24">S</span></p> <p class="calibre7"><span class="calibre18">E</span></p> <p class="calibre7"><span class="calibre24">NTERED IN THE</span></p> <p class="calibre7"><span class="calibre18">L</span></p> <p class="calibre7"><span class="calibre24">ISTS OF THE</span></p> <p class="calibre7"><span class="calibre18">W</span></p> <p class="calibre7"><span class="calibre24">ORLD</span></p> <p class="calibre7"><br class="calibre1"/> </p> Last edited by enuddleyarbl; 01-30-2023 at 01:08 AM. |
![]() |
![]() |
![]() |
#2 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,104
Karma: 144284184
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Load the KF8 version into the editor and post the code from the chapter header so we can see what it looks like.
Here is what it's supposed to look like from the Baen website. http://www.baen.com/Chapters/1597800...800546___4.htm |
![]() |
![]() |
![]() |
#3 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,305
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Yeah, that’s ugly. The spans are a cludge to make something ‘appear’ to have small-caps for those older/deficient devices that don’t support the css.
It may be easier/faster to just manually type the headers yourself - assuming there are a reasonable number of chapters. If not, I would simply use a few regex passes. Exactly HOW you do that is up to you - there are multiple techniques. I would just use incremental steps to do the job. Some regex geniuses could probably do it in 3 passes... ![]() Code:
Pass 1: Find: <p class="calibre7"><br class="calibre1" id="filepos.*?"/>\s*</p>\s*<p class="whitespace"></p> Replace: leave blank Pass 2: Find: <p class="calibre7"><span class="calibre(24|19)">(.*?)</span></p> Replace: <h4>\L\2\E</h4> Pass 3: Find: <p class="calibre7"><span class="calibre18">(.*?)</span></p> Replace: <h3>\1</h3> Pass 4: Find: </h3>\s*<h4>(.*?)</h4> Replace: \1</h3> Pass 5: Find: </h3>\s*<h3> Replace: single space Pass 6: Find: </h3>\s*<p class="whitespace"></p>\s*<h3>(.*?)</h3> Replace: single space<span>\1</span></h3> Pass 7: Find: <p class="calibre7"><br class="calibre1"/>\s*</p> Replace: leave blank That should leave you with: Code:
<h3>One: The Years 583-590 afe <span>He Is Entered in the Lists of the World</span></h3> Code:
h3 { margin:0; font-weight:bold; font-family:serif; font-size:1.2em; font-variant:small-caps; text-align:center } h3 span { display:block; margin-top:1em; font-size:1em } ![]() Cheers! EDIT: Regex Confirmed - with only a small edit on pass 2. I've also attached a screenshot of how it would look. Last edited by Turtle91; 01-30-2023 at 09:03 AM. |
![]() |
![]() |
![]() |
#4 | ||
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 769
Karma: 1537886
Join Date: Sep 2013
Device: Kobo Forma
|
Quote:
Code:
<p><br class="calibre1" id="filepos21832"/></p> <p class="calibre9"></p> <p><span class="calibre3 bold">O</span></p> <p><span class="calibre4 bold">NE:</span></p> <p><span class="calibre3 bold">T</span></p> <p><span class="calibre4 bold">HE</span></p> <p><span class="calibre3 bold">Y</span></p> <p><span class="calibre4 bold">EARS 583-590 AFE</span></p> <p class="calibre2"></p> <p><span class="calibre3 bold">H</span></p> <p><span class="calibre10 bold">E</span></p> <p><span class="calibre3 bold">I</span></p> <p><span class="calibre10 bold">S</span></p> <p><span class="calibre3 bold">E</span></p> <p><span class="calibre10 bold">NTERED IN THE</span></p> <p><span class="calibre3 bold">L</span></p> <p><span class="calibre10 bold">ISTS OF THE</span></p> <p><span class="calibre3 bold">W</span></p> <p><span class="calibre10 bold">ORLD</span></p> <p><br class="calibre1"/></p> Quote:
|
||
![]() |
![]() |
![]() |
#5 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 769
Karma: 1537886
Join Date: Sep 2013
Device: Kobo Forma
|
Quote:
|
|
![]() |
![]() |
![]() |
#6 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,305
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
I woke up with crying/coughing babies... and was REALLY bored...
![]() |
![]() |
![]() |
![]() |
#7 | |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,305
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Quote:
![]() Code:
Pass 1: Find: <p><br class="calibre1" id="filepos.*?"/></p>\s*<p class="calibre9"></p> Replace: leave blank Pass 2: Find: <p><span class="calibre(4|10) bold">(.*?)</span></p> Replace: <h4>\L\2\E</h4> Pass 3: Find: <p><span class="calibre3 bold">(.*?)</span></p> Replace: <h3>\1</h3> Pass 4: Find: </h3>\s*<h4>(.*?)</h4> Replace: \1</h3> Pass 5: Find: </h3>\s*<h3> Replace: single space Pass 6: Find: </h3>\s*<p class="calibre2"></p>\s*<h3>(.*?)</h3> Replace: single space<span>\1</span></h3> Pass 7: Find: <p><br class="calibre1"/></p> Replace: leave blank |
|
![]() |
![]() |
![]() |
#8 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 769
Karma: 1537886
Join Date: Sep 2013
Device: Kobo Forma
|
I haven't worked with your regex yet. But, I just wanted to add that I think you're right about the intent being to smallcapify the heading. Unfortunately, they closed each "first letter" and word with an end paragraph mark. So, every chunk got its own line.
Why nobody caught that over the last decade or so, and fixed it, I don't know. It's not exactly a subtle type-setting result. |
![]() |
![]() |
![]() |
#9 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 769
Karma: 1537886
Join Date: Sep 2013
Device: Kobo Forma
|
I think I understand what you're doing with that regex. The only issue is that Calibre doesn't support lower-casing via \L\E. But, I worked around that with the Calibre Editor's Regex-Funtion "Lower-case text" mode. I've got to examine the document a bit more to double-check, but it looks good. Thanks.
|
![]() |
![]() |
![]() |
#10 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,305
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
yup - you got it!!
I used <h3> and <h4> just to differentiate a lowercase section of words from an uppercase. You could use any string of nonsense letters as long as it isn't used elsewhere in the book. I also pretty much end up using <h3> as my chapter headers most of the time, so that came to mind to use. The use of <h3> as a chapter designation is absolutely NOT required. You will find some people just use <h1> for every heading... I like the ability to use multi-level ToC, both visually (it looks cool and matches the organization in my brain) and functionally (being able to collapse/expand certain areas), and it is more semantically correct if you have a document with subsections to use the different levels of <h1-6> to denote the subsections. It also follows the standard for accessibility...which is a good thing. The actual <h> tag used is only a semantic indicator of the 'level' of the heading. You can style the heading to look however you wish. Code:
<h1> Cover <h2> Front matter <h2> Title <h3> Prologue <h3> Chapter ... <h3> Chapter <h3> Epilogue <h2> Back matter <h1> Back cover (if used) -- OR -- <h1> Cover <h2> Front matter <h2> Title <h3> Prologue <h3> Part or Book <h4> Chapter <h4> Chapter <h4> Chapter <h3> Part or Book <h4> Chapter <h4> Chapter <h4> Chapter <h3> Epilogue <h2> Back matter <h1> Back cover (if used) Last edited by Turtle91; 01-30-2023 at 11:37 AM. |
![]() |
![]() |
![]() |
#11 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,104
Karma: 144284184
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
I've borrowed the eBook from Amazon via Overdrive.
https://www.amazon.com/gp/product/B0...ef=kinw_myk_ro Here is the code from the KF8 version. Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="UTF-8"/> <title>A Cruel Wind: A Chronicle of the Dread Empire</title> <link href="../styles/0001.css" rel="stylesheet" type="text/css"/> <style type="text/css"> /*<![CDATA[*/ @page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; } /*]]>*/ </style> </head><body class="calibre" id="5N3C0-11644f3118e64bc193ce2ca166b24ddb"> <p><br class="calibre1" id="filepos21832"/></p> <p class="calibre9"></p> <p><span class="calibre3 bold">O</span><span class="calibre4 bold">NE:</span> <span class="calibre3 bold">T</span><span class="calibre4 bold">HE</span> <span class="calibre3 bold">Y</span><span class="calibre4 bold">EARS 583-590 AFE</span></p> <p class="calibre2"></p> <p><span class="calibre3 bold">H</span><span class="calibre10 bold">E</span> <span class="calibre3 bold">I</span><span class="calibre10 bold">S</span> <span class="calibre3 bold">E</span><span class="calibre10 bold">NTERED IN THE</span> <span class="calibre3 bold">L</span><span class="calibre10 bold">ISTS OF THE</span> <span class="calibre3 bold">W</span><span class="calibre10 bold">ORLD</span></p> <p><br class="calibre1"/></p> Now to return the eBook and delete it. |
![]() |
![]() |
![]() |
#12 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 769
Karma: 1537886
Join Date: Sep 2013
Device: Kobo Forma
|
Well, that's really weird. I went to my Amazon library where the book is sitting without any kind of update available. I downloaded it once again, just in case it changed overnight. Added it to Calibre and the chapter headings are still messed up.
I was under the impression that Amazon keeps our purchased books up-to-date. But, either they don't or the version that they let people borrow via Overdrive is different from whatever I bought more than a decade ago. |
![]() |
![]() |
![]() |
#13 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,605
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#14 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,026
Karma: 90000009
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
Quote:
Only in rare cases when the publisher convinces Amazon that an update is critical will it be made available to past purchasers to accept optionally. |
|
![]() |
![]() |
![]() |
#15 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 769
Karma: 1537886
Join Date: Sep 2013
Device: Kobo Forma
|
I didn't have "Automatic" book updates on, but it's been prompting me that an update is available in my library if there is one. I always tell it to update to the latest version. But, that's really not going to make any difference since I don't actually have anything on a Kindle any more to be updated.
I AM downloading to my old Kindle Touch (to transfer via USB). That could be the difference. Maybe they stopped updating the older formats that would go to those older devices and only update the latest and greatest copy-protectedness versions. And, I'd assume the ones they lend via Overdrive would be locked down the hardest. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help with Chapter seperators (lines underneath chapter headings) | indieauthor83 | Sigil | 9 | 06-23-2017 06:01 AM |
Invisible chapter headings? | bcamp47 | Sigil | 6 | 03-24-2013 12:38 AM |
Chapter Headings | Paxman53 | Conversion | 3 | 10-12-2011 12:31 PM |
Chapter Headings on their own page? Help! | Lee5150 | Calibre | 3 | 10-06-2011 08:12 AM |
Why H1 and H2 Chapter Headings? | Ransom | Calibre | 11 | 08-10-2011 04:29 PM |