View Single Post
Old 02-08-2021, 09:19 PM   #11
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by 413Michele View Post
First of all, thank you everyone for your help, I feel like I'll never learn how to properly use regex without a starting expression to edit, it's too broad and confusing for me

I found it odd that there wasn't a thread already of someone with this problem, so I'm trying to be detailed in case someone needs this in the future.

In the end I took the first idea by Davidfor and modified it a bit to keep as much of the original tagging as possible. Here's the string I used to find (I added the part to detect the ids of the tags):
Code:
<h2 id="sigil_toc_id_\d{1,2}">(.*?)</h2>\s*<h3 id="sigil_toc_id_\d{1,2}">(.*?)</h3>
And here's the string to replace with:
Code:
<h2 class="hidden">\1 \2</h2><h2 class="ChapterTitle">\1</h2><h3 class="ChapterSubtitle">\2</h3>
After this I used the ToC generation tool for multilevel elements with XPath:
  • h1 for the first level
  • h2 with class=hidden for the second level
and it worked like a charm!
Shouldn't the replace string have "p" instead the second "h2" and the "h3"? Or have you just copied the wrong version?

Edit:

The ToC generation is using a the h2 and the hidden class for the second level. It looks like it should work. Can you show use the generated NCX code? And the actual code at the top of the matching chapter. That might give a hint as to what is wrong.

And that is an interesting idea. What I do is easy if the chapter heading already use well defined classes. But, if they are bare heading tags, I have to add classes. With that, I could rely on the existing stylesheet a bit more.

Last edited by davidfor; 02-08-2021 at 09:25 PM.
davidfor is offline   Reply With Quote