Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 03-16-2026, 12:31 PM   #1
Aromatisse
Junior Member
Aromatisse began at the beginning.
 
Aromatisse's Avatar
 
Posts: 8
Karma: 10
Join Date: Nov 2020
Device: Pocketbook
title tag to h1

I have multiple epubs where the chapter titles are only inside the head title tag and nowhere else. Is there an "easy" way to convert or duplicate each title tag into a h1 tag at the beginning of a chapter?
Aromatisse is offline   Reply With Quote
Old 03-16-2026, 12:45 PM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 9,446
Karma: 6734148
Join Date: Nov 2009
Device: many
Yes, use Sigil's Find and Replace in Regex mode.

Have you ever searched using regular expressions before?

The idea is to find all the text between the opening title tag (while capturing the title tag contents) to the end of the opening body tag, then creating a replacement using the full capture with the addition of h1 tag with the captured title value appended.

This is also something you can easily do in a Sigil plugin if you know python, too.

Last edited by KevinH; 03-16-2026 at 01:20 PM.
KevinH is offline   Reply With Quote
Advert
Old 03-16-2026, 02:54 PM   #3
Aromatisse
Junior Member
Aromatisse began at the beginning.
 
Aromatisse's Avatar
 
Posts: 8
Karma: 10
Join Date: Nov 2020
Device: Pocketbook
I have not used the regex mode before, but I will give it a try.
Aromatisse is offline   Reply With Quote
Old 03-16-2026, 04:16 PM   #4
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 9,446
Karma: 6734148
Join Date: Nov 2009
Device: many
To help get you started here are some tips:

Mode: Regex

Options: Regex Options:
Dot All checked
Unicode Property checked

Find:
Code:
<title>([^<]*)</title>(.*<body[^>]*>)
Replace:
Code:
<title>\1</title>\2\n  <h1>\1</h1>\n
The Find field above tells it to select everything from the starting title tag to the end of starting body tag, while capturing the contents of the title tag into the first capture field and everything else into the second capture field.

The Replace field tells it to use a title tag whose contents are capture 1 and then after the opening body tag, add a new line and a couple spaces and then create the h1 tag with the proper contents (capture 1).

I tested this on the following html code:

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
   <title>This should be heading 1</title>
</head>

<body>
  <p>*</p>
</body>
</html>
And after doing a find and replace you end up with the following:

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
    <title>This should be heading 1</title>
</head>

<body>
  <h1>This should be heading 1</h1>

  <p>*</p>
</body>
</html>
So this or something much like it should do the trick.

I hope this helps.

KevinH

Last edited by KevinH; 03-16-2026 at 04:19 PM.
KevinH is offline   Reply With Quote
Old Yesterday, 05:22 AM   #5
Aromatisse
Junior Member
Aromatisse began at the beginning.
 
Aromatisse's Avatar
 
Posts: 8
Karma: 10
Join Date: Nov 2020
Device: Pocketbook
This worked like a charm, you really helped me out! Thank you!
Aromatisse is offline   Reply With Quote
Advert
Old Yesterday, 11:15 AM   #6
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 9,446
Karma: 6734148
Join Date: Nov 2009
Device: many
If you edit epubs often, then taking the time to learn to use regular expressions is well worth it. It is very powerful.

And for things that can't be done by regular expressions, if you know a smattering of python, you can use Python Function Replacement or create your own python Plugin for Sigil.


Glad it helped.
KevinH is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
<title> tag in the index_split_XXX.html files meghane_e Conversion 3 03-25-2019 01:28 PM
Title node in Tag Browser shinyplastic Library Management 6 02-24-2018 11:53 AM
What goes in HTML head <title> tag? jcsalomon ePub 5 07-12-2016 02:47 PM
Metadata tag dc:title overwritten on transfer to Kobo Touch Npnth Devices 3 08-31-2012 12:38 PM
<Title> Tag fcoulter ePub 5 07-30-2010 07:48 PM


All times are GMT -4. The time now is 04:19 AM.


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