05-10-2020, 10:00 PM | #1 |
Wizard
Posts: 1,071
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
TitleCase shortcut and TOC
I had a epub with all the headings in UPPER CASE (drives me nuts)
Q1. Is there a way to convert all words in a <Hx> to Title Case using some kind of Find and Replace? The few LC exceptions ('the', 'a', etc. I can do manually) Q2. I have Title Case on a shortcut key, but if I highlight text that has a tag in it, nothing happens. E.g. TOM<br/>DICK<br/>HARRY. Q3. In a heading like TOM<br/>DICK<br/>HARRY, the tags are ignored when making a TOC, so that the TOC entry looks like TOMDICKHARRY As a work-around, if I use TOM <br/>DICK <br/>HARRY (add space after) then the TOC is at least readable TOM DICK HARRY Any workarounds? I did try text-transform, but that didn't seem to do anything Code:
h1 { font-family: sans-serif; page-break-before: always; page-break-after: avoid; text-indent: 0; text-align: center; margin-top: 2em; margin-bottom: 1em; font-size: 1.5em; font-weight: bold; font-style: normal; text-transform: capitalize; } |
05-10-2020, 11:33 PM | #2 |
Running with scissors
Posts: 1,552
Karma: 14325282
Join Date: Nov 2019
Device: none
|
Q3: I use a space before the br. Although in my case it's a space before a span; in my CSS I have a selector/combinator that puts what's in the span on a separate line when it's in a header.
Q1: Yes, look in the thread on regex / regular expressions. Or search on the web. |
Advert | |
|
05-10-2020, 11:58 PM | #3 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
05-11-2020, 09:01 AM | #4 |
Wizard
Posts: 1,071
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
Well, that was embarrassing --
Not only was it in the manual, but I had saved it as a Search a long time ago |
05-11-2020, 09:04 AM | #5 |
Resident Curmudgeon
Posts: 73,998
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
Advert | |
|
05-11-2020, 11:28 AM | #6 | |
Bibliophagist
Posts: 35,461
Karma: 145525534
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
Automatically fixing the case of headings in the document Here, we will leverage one of the builtin functions in the editor to automatically change the case of all text inside heading tags to title case: Find expression: <([Hh][1-6])[^>]*>.+?</\1> For the function, simply choose the Title-case text (ignore tags) builtin function. The will change titles that look like: <h1>some TITLE</h1> to <h1>Some Title</h1>. It will work even if there are other HTML tags inside the heading tags. |
|
05-11-2020, 02:17 PM | #7 | |
Wizard
Posts: 1,071
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
Quote:
https://manual.calibre-ebook.com/function_mode.html |
|
05-13-2020, 09:46 AM | #8 | |
Wizard
Posts: 1,071
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
Quote:
Any chance of having Q2. the TitleCase shortcut key work even if there are some tags in the selected text by just ignoring the tags? Q3. the TOC 'honor' any tags in the headings, normally <br/>? |
|
05-13-2020, 11:49 AM | #9 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Not sure what you mean by (1) and for (2) no toc entries are always single line of plain text
|
05-13-2020, 01:51 PM | #10 |
Wizard
Posts: 1,071
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
(1) if I highlight text that has a tag in it, and select the text and choose TitleCase, nothing happens. E.g. TOM<br/>DICK<br/>HARRY doesn't get turned into Tom<br/>Dick<br/>Harry<br/>
(2) In a heading like TOM<br/>DICK<br/>HARRY, the tags are ignored when making a TOC, so that the TOC entry looks like TOMDICKHARRY I don't understand how your TitleCase works for (1), but it would seem to me (obviously just my opinion) that (2) requiring all TOC entries to be a single line can be limiting. Maybe just transforming tags in a space? Last edited by phossler; 05-13-2020 at 01:55 PM. Reason: Forgot pictures :-( |
05-13-2020, 01:55 PM | #11 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
(1) has nothing to do with tags, but rather that all upper case words are assumed to be acronyms. lower case them first then titlecase them. And you should insert spaces before each <br> as well, which will take care of (2) for you as well.
|
05-13-2020, 03:19 PM | #12 |
Wizard
Posts: 1,071
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
Ahh --
1. I didn't realize the acronyms part 2. I had just assumed that tags, etc. would be treated as white space and I wouldn't have to force the extraneous space in to get the formatting to work Thanks for the explanation |
05-13-2020, 04:19 PM | #13 |
Well trained by Cats
Posts: 29,809
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
I always put a space BEFORE the <br /> for a clean looking TOC entry whe I use H# tags to generate from multi-line headings
I never knew WHY all case tools I have ever used (inc DOS apps), would never mix case an upper only word (I knew I had to first lower). Kovid makes perfect sense. |
05-13-2020, 09:04 PM | #14 |
Wizard
Posts: 1,071
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
Hmmm - it seems that putting a space AFTER each <br/> is more reliable
Doing it that way, if you make UPPER CASE with br/'s into lower case and then into Title Case, it works and you end with TitleCase. The TOC is also correct. Sort of appears to me that it treats UPPER+<br/>+space as a word but not space+<br/>+UPPER as a word |
05-13-2020, 09:11 PM | #15 |
Well trained by Cats
Posts: 29,809
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Space After
Staggers the Viewed text Line One Line Two (exaggerated)
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
keyboard shortcut for TOC in viewer? | calibre4evar | Calibre | 8 | 01-05-2015 12:28 AM |
Multiple HTML files w/ TOC to MOBI, not added in order listed in TOC | dysfunction | Conversion | 3 | 01-03-2014 12:40 AM |
Ho do I create a TOC for ePub which does convert to an active TOC in Kindle Previewer | K-Thom | Calibre | 1 | 09-24-2013 06:32 PM |
TOC Shortcut? | runtmms | Amazon Kindle | 12 | 11-14-2010 05:36 PM |
Making a TOC for LRFs? Issues with Calibre + LRF TOC editor not working | Magitek | LRF | 0 | 05-06-2009 01:25 PM |