Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 07-21-2023, 09:02 AM   #1
stumped
Wizard
stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.
 
Posts: 3,305
Karma: 10259306
Join Date: May 2016
Device: kobo forma, Kobo Libra, Huawei media Tab, fire HD10, PW3 HDX8.9,
is there an elegant solution to add hidden chapter numbers

i have a Wilbyyr Smith novel, which like many of his books has no actual chapters. the whole story is one big section...
but every so often there is a nifty egyptian heiroglyph image that starts each new " chapter".
but its the same nifty image every time
code starts like this

<p class="textbreak"><img src="../images/00003.jpeg" alt=""
or
<p class="textfirst"><img src="../images/00003.jpeg" alt=""

what I'd like to do within my own reading copy is have a hidden number at each of these locations which would appear in a generated toc as 1, 2, 3 ... like chapter numbers

so if i select "chapter" 3 in the toc i get taken to the 3rd nifty heiroglyph..

i think sigil has some relevant tools but would welcome hints or even a full solution
stumped is offline   Reply With Quote
Old 07-21-2023, 10:50 AM   #2
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 692
Karma: 2180740
Join Date: Jan 2017
Location: Poland
Device: Misc
Your problem is relatively easy to fix. It all depends on the book code (i.e., that further part after alt="").

Here's the solution, which you may have to adapt to your actual code.

1. [Very important] Make yourself a copy of the EPUB file, just in case.
2. [Just in case] Check the file with the EpubCheck plugin.
3. Run the Access-Aide plugin, where all your Egyptian hieroglyphics + all other images in the book will be displayed.
Yes, where there are hieroglyphs on the right insert manually numbering 1, 2, 3 etc. This will change the alt attribute (specifies an alternate text for an image).
4. Now just do the replacement

Code:
<p class="(.+?)"><img src="../images/00003.jpeg" alt="(\d+)"/>
to
Code:
<h1 title="\2"></h1><p class="\1"><img src="../images/00003.jpeg" alt="\2"/>
5. Generate a table of contents.
6. [Optional] Generate HTML table of contents.

Check your image code and adapt it to your book, as my solution is more educational (maybe useful to someone) than definitive.
BeckyEbook is online now   Reply With Quote
Advert
Old 07-24-2023, 07:55 AM   #3
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,166
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Dune and many Discworld novels have no named chapters. At a minimum you can simply add a bookmark at each "logical" chapter mark. Maybe even the start of the first paragraph as TOC text. A global edit can do that too.
Quoth is offline   Reply With Quote
Old 07-24-2023, 09:00 AM   #4
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,095
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
I use the same basic procedure as BeckyEbook. However, I use the ReworkChapterHeads plug-in. That will automatically insert incremental IDs into a header tag.

Then, run a regex to incorporate the image into the header:

Code:
With:
<h3>1 (2, 3, 4, etc)</h3>
<p class="textbreak"><img src="../images/00003.jpeg" alt="" /></p>


Find: <h3>(\d+)</h3>\s*<p class="textbreak"><img src="../images/00003.jpeg" alt="" /></p>

Replace: <h3 title="\1"><img src="../images/00003.jpeg" alt="" /></h3>
I’d even rename the image file to something I could understand just by reading it eg. img_ChHd.jpg or something.

If your reading device is at all modern, and supports CSS, then you could even trim that down with:

Code:
Replace: <h3 title="\1"></h3>
and add css to incorporate the image as a background of the header tag; or even insert the image before the header tag. That is certainly not necessary, but it cleans up your code a little bit.

For example:
Code:
h3 {
display: block; 
background-image: url("../Images/img_ChHd.jpg"); 
background-size:2em 1em; 
width:2em; 
height:1em; 
margin:1em auto; 
content:""}

* set sizes as needed for the image
EDIT: added css example code

Last edited by Turtle91; 07-24-2023 at 10:04 AM.
Turtle91 is online now   Reply With Quote
Old 07-25-2023, 01:26 AM   #5
stumped
Wizard
stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.
 
Posts: 3,305
Karma: 10259306
Join Date: May 2016
Device: kobo forma, Kobo Libra, Huawei media Tab, fire HD10, PW3 HDX8.9,
thanks all
after much searching, i mostly did it manually folliowng this 2014 post. use regex to get numbers from ID tags...
( i skipped trying to hide chapter numbers behind a picture and instead i replaced the pictures with numbers
[QUOTE=Doitsu;2933379]Unfortunately, Sigil only adds ids to heading tags, if there are multiple heading tags in a file.

@Keeth: You'll have to outsmart Sigil and make it add sequential ids to each heading tag. Assuming that each chapter is a separate .html file and contains only one heading tag at the beginning of the file, for example <h3>Chapter</h3> do the following:

1. Replace all <h3>Chapter</h3> with <h3>Chapter</h3><h4>Chapter</h4>.

2. Regenerate the TOC. You should end up with: <h3>Chapter</h3><h4 id="sigil_toc_id_1">Chapter</h4> for the first chapter.

3. Replace all <h3>Chapter</h3> with nothing. I.e. delete them.
stumped is offline   Reply With Quote
Advert
Old 07-25-2023, 01:42 AM   #6
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,103
Karma: 4911876
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
So if you delete <h3>Chapter</h3>, then doesn't that still leave you with <h4 id="sigil_toc_id_1">Chapter</h4> at the start of each chapter? I thought you only wanted to see the icon/hieroglyph?

How does that then achieve what you first asked for?...

Quote:
Originally Posted by stumped View Post
so if i select "chapter" 3 in the toc i get taken to the 3rd nifty heiroglyph..
Edit:
When I read the Dune series, the chapters numbers from most books were omitted. I simply added them and I didn't worry about keeping them hidden.

Last edited by Karellen; 07-25-2023 at 01:46 AM.
Karellen is online now   Reply With Quote
Old 07-25-2023, 02:51 AM   #7
stumped
Wizard
stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.
 
Posts: 3,305
Karma: 10259306
Join Date: May 2016
Device: kobo forma, Kobo Libra, Huawei media Tab, fire HD10, PW3 HDX8.9,
if you locate the full post from 2014 it explains how to do it. when you regen the toc, each h4 gets an incremental toc-Id. so the toc ids now correspond to chapter numbers. regex does the rest.
you creat all the H4, generate the toc, delete all the H3, use regex to copy from incremental toc IDs in H4 to make chapter numbers
i decided the picture was superfluous as it was same for each section - added no value.
so I dropped the how to hide a number behind a citure ( the elegant bit) , as no one proffered an elegant (non manual ) way to do it

now that the plug in has been mentioned, I could have probably done it with that. may try to in other wilbur smith books.
pretty sure I had that plug in years ago, but lost it when changing computers, tehn failed to find it again.
stumped is offline   Reply With Quote
Old 07-25-2023, 03:29 AM   #8
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,103
Karma: 4911876
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
I don't know what post from 2014 you are referring to, so I have no chance of finding it.

I thought @BeckyEbook gave you the solution to hide chapter titles. You don't need to hide it behind an image, it just remains invisible. The title="" makes the chapter number available to the TOC generator, but the empty value between the opening and closing h2 tags means nothing is displayed.

<h2 title="Chapter 1"></h2>

FWIW, when I come across a book with missing chapter numbers I add them using...

Find: <body>
Replace: <body>\n\n <h2>mm</h2>

The above adds the header tags. Of course you need to be careful that you select the correct xhtml pages.

Next I run a Regex-Function (in Calibre) to replace the mm with incrementing numbers.
Karellen is online now   Reply With Quote
Old 07-25-2023, 04:28 AM   #9
stumped
Wizard
stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.
 
Posts: 3,305
Karma: 10259306
Join Date: May 2016
Device: kobo forma, Kobo Libra, Huawei media Tab, fire HD10, PW3 HDX8.9,
ok
here's the sigil find replace steps i used
after choosing NOT to preserve the picture. could be tweaked to preserve it

i will try the title="" idea when i do another book

replace the code for picture with H2 tags, carefully negotiating the neste spans

find
<p class="textbreak"><span class="dropcap"><span><img src="../images/00003.jpeg" alt="" class="calibre7"/>
replace
<h2>xchapter</h2><p class="calibre8"><span><span>

find
/h2>
replace
/h2><h3>xChapter </h3>
..
then regenerate TOC
then remove H2
..
find
<h2 class="calibre7">xchapter</h2>
replace blank

the book code will now have incremental sigil id tags, one per chapter
stumped is offline   Reply With Quote
Old 07-25-2023, 05:24 AM   #10
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,103
Karma: 4911876
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by stumped View Post
find
/h2>
replace
/h2><h3>xChapter </h3>
..
then regenerate TOC
then remove H2
..
find
<h2 class="calibre7">xchapter</h2>
replace blank

the book code will now have incremental sigil id tags, one per chapter
I have to admit that I don't really understand what is happening here.
You add a h2 tag, then you add a h3 tag, then you delete the h2 tag.
What is the reason for adding <h2> and <h3> tags together? Why don't you add the h3 tag at step 1 if that is what you are wanting?
Karellen is online now   Reply With Quote
Old 07-25-2023, 07:20 AM   #11
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,095
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Quote:
Originally Posted by stumped View Post

so I dropped the how to hide a number behind a citure ( the elegant bit) , as no one proffered an elegant (non manual ) way to do it
...
Hello? Hello?? Can anyone hear me??? I’m right here…
Turtle91 is online now   Reply With Quote
Old 07-25-2023, 08:25 AM   #12
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,095
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
If anyone else out there can see my posts...

As Karellen mentioned the title="" is the trick. Sigil will normally create a TOC using whatever is in the header tags...unless you put a title="{something}" into the header tag itself. Then Sigil uses that when creating the TOC.

Super easy steps that take only a few seconds:

Quote:
1. Select the chapter file(s) in the book browser.

2. Run the ReworkChapterHeads plugin
- Skip Option 1 to delete headers
- Set Option 2 settings how you desire
- select 'OK'
Click image for larger version

Name:	Screenshot 2023-07-25 073727.png
Views:	36
Size:	19.8 KB
ID:	202814


3. This adds the sequentially numbered header tags to each of the files.
Click image for larger version

Name:	Screenshot 2023-07-25 075308.png
Views:	35
Size:	239.0 KB
ID:	202815


4. Use Regex to replace the header and the image with a header that includes the image (in stumped's example)
- find: <h3>(\d+)</h3>\s*<p class="textbreak"><span class="dropcap"><span><img src="../images/00003.jpeg" alt="" class="calibre7"/></span></span></p>
- replace: <h3 title="\1"><img src="../images/00003.jpeg" alt=""/></h3>
Click image for larger version

Name:	Screenshot 2023-07-25 075511.png
Views:	35
Size:	254.5 KB
ID:	202816


5. Run Sigil's 'Generate Table of Contents' tool.
Name:  Screenshot 2023-07-25 082008.png
Views: 244
Size:  1.5 KB
Done!
Turtle91 is online now   Reply With Quote
Old 07-25-2023, 04:25 PM   #13
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,103
Karma: 4911876
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
I wonder if @Turtle91 would like to comment. Haven't seen him around for a while...

Karellen is online now   Reply With Quote
Old 07-25-2023, 04:32 PM   #14
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by stumped View Post
Unfortunately, Sigil only adds ids to heading tags, if there are multiple heading tags in a file.
This confuses me terribly.

There are very few situations where Sigil itself will add ids to any tag. And none of those situations are predicated on there being more than one heading tag in a file.

Last edited by DiapDealer; 07-25-2023 at 04:38 PM.
DiapDealer is offline   Reply With Quote
Old 07-25-2023, 04:47 PM   #15
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 692
Karma: 2180740
Join Date: Jan 2017
Location: Poland
Device: Misc
@DiapDealer.

Surely this is the situation:

Code:
  <h1>Chapter 1</h1>
  <p>Blah, blah, blah</p>
  <h2>Subchapter A</h2>
  <p>Blah, blah, blah</p>
  <h2>Subchapter B</h2>
  <p>Blah, blah, blah</p>
  <h2>Subchapter C</h2>
  <p>Blah, blah, blah</p>
After creating TOC/NCX:

Code:
  <h1>Chapter 1</h1>
  <p>Blah, blah, blah</p>
  <h2 id="sigil_toc_id_1">Subchapter A</h2>
  <p>Blah, blah, blah</p>
  <h2 id="sigil_toc_id_2">Subchapter B</h2>
  <p>Blah, blah, blah</p>
  <h2 id="sigil_toc_id_3">Subchapter C</h2>
  <p>Blah, blah, blah</p>
Identifiers are added only to those headers that are in the same file. And that's a very good thing.
BeckyEbook is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating hidden or invisible page numbers jmurphy Workshop 9 03-10-2023 02:49 PM
Remove Chapter Numbers Rahm Conversion 3 11-04-2021 01:39 PM
Free (nook/Kindle/iTunes/ePub) Elegant Solution [Xtian 1720s Mathematical Thriller] ATDrake Deals and Resources (No Self-Promotion or Affiliate Links) 1 01-27-2015 10:43 AM
Regex Solution to hidden href search? MizSuz Sigil 16 09-29-2012 07:40 PM
chapter numbers are graphical alansplace Sigil 6 07-04-2011 10:10 AM


All times are GMT -4. The time now is 04:41 PM.


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