View Single Post
Old 07-12-2020, 07:25 PM   #7
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by playful View Post
A bit of a Sigil-noobie question.

Working with 1000+ html files.
Each has a proper title tag such as <title>1 - it all began here</title> but no h1, h2 etc. tags.

Out of the box, when generating the TOC, is there a way to make Sigil take the <title> tags into account?
You could do this with 2 Find/Replaces. One to insert the <title> as <h1>, and one to remove the <h1>.

Note: Make sure you turn Sigil into Regex mode, and make sure you check the box for Dot All.

* * *

Step 1: Convert <title> into an <h1>:

Find: <title>(.+?)</title>(.+)<body>
Replace: <title>\1</title>\2<body><h1>\1</h1>

Step 2: Press Tools > Table of Contents > Generate Table of Contents, then create your TOC.

Step 3: Do the opposite. Remove the <h1> we just created:

Find: <body><h1>(.+?)</h1>
Replace: <body>

If you do this often, you can even create a Saved Search for both of those fixes.

Quote:
Originally Posted by JSWolf View Post
The title tags would normally have the book's title and not the chapter title.
No. For more extensive discussion on best practices for <title>, see discussion in the 2018 thread "Two questions", especially my Post #2.

Last edited by Tex2002ans; 07-12-2020 at 07:31 PM.
Tex2002ans is offline   Reply With Quote