Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 02-10-2024, 05:15 AM   #1
TTY15
Junior Member
TTY15 began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2024
Device: none
TOC level 2 from span class = span2

I've imported from LO Writer where I had styling for H1 and H2. But in Calibre editor I see only H1 in TOC. How can I add H2 level?

My H2 in Calibre editor is seen as:

Code:
<span class="span2">
and has css:
Code:
.span2 {color: #1f3864; font-family: 'Liberation Sans1'; font-size: 20.0000pt; font-weight: bold; }
I read about XPath but when I use these options:

https://i.imgur.com/gRyqHBU.png

Code:
//h:h2[re:test(@class, "span2", "i")]
it doesn't find any elements that could be included in TOC.

By the way, is it possible to do find and replace in Calibre editor for all xhtml files at once? Or somehow unpack epub, edit and pack to epub again?
TTY15 is offline   Reply With Quote
Old 02-10-2024, 01:41 PM   #2
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,104
Karma: 4911876
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Span is not a header, so there is no reason for a conversion to automatically add a span as a TOC level.

Auto-genereated TOC's are created from the <h[1-3]> headers by default.

Forget xpath. Convert your header tags to the correct header tags.

Using a Regex S&R and selecting "all files"
Find... <span class="span2">(.*?)</span>
Replace... <h2>\1</h2>
Best to step through the changes one at a time until you are confident the replace works correctly, then you can Replace All and check the "see what changed" screen to make sure nothing else was picked up in error.

Then style your h2 tag in the CSS.

Then run the TOC generator again after you have deleted all the existing TOC entries so they are not duplicated.

Strange that you ended up with <span> from LO, as I always end up with the correct <h..> tags.
Karellen is offline   Reply With Quote
Advert
Old 02-11-2024, 03:57 AM   #3
TTY15
Junior Member
TTY15 began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2024
Device: none
Thank you very much for this detailed explanation. It worked very well.

Quote:
Originally Posted by Karellen View Post
Strange that you ended up with <span> from LO, as I always end up with the correct <h..> tags.
Do you use default LO Writer export to epub option or writer2epub extention?
TTY15 is offline   Reply With Quote
Old 02-11-2024, 04:12 AM   #4
TTY15
Junior Member
TTY15 began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2024
Device: none
I can't edit so I need to add next comment.

Do you create TOC in Writer so that epub can use it or only create it in epub editor?
TTY15 is offline   Reply With Quote
Old 02-11-2024, 04:30 AM   #5
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,104
Karma: 4911876
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by TTY15 View Post
Thank you very much for this detailed explanation. It worked very well.

Do you use default LO Writer export to epub option or writer2epub extention?
Glad it worked.
Make it a habit to use the correct tags, rather than fake tags.
ie, use <i></i> for italic, instead of <span class="italic"></span>
All these tags are available for a reason. You can find a list of tags here... https://developer.mozilla.org/en-US/...HTML/Element/i. Remember epubs use a small subset of those html tags, so not all will work, but the more common ones will.

As for LO, check the image for my setup. I haven't heard of writer2epub. I just use the "Export as > Export as epub" option in LO Writer.

Hope that helps.

Quote:
Originally Posted by TTY15 View Post
Do you create TOC in Writer so that epub can use it or only create it in epub editor?
I create it in the Calibre editor.
Once you export from LO, the epub needs a bit of work, tidying up the tags, then I create the TOC once completed.
Attached Thumbnails
Click image for larger version

Name:	headings.jpg
Views:	36
Size:	184.2 KB
ID:	206304  

Last edited by Karellen; 02-11-2024 at 01:30 PM.
Karellen is offline   Reply With Quote
Advert
Old 02-11-2024, 07:47 AM   #6
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
I've tested Writer2epub extension on older programs and epub export on currrent LO Writer. Both poor compared with a Save As also in docx and Calibre. The direct ODT isn't as good. Also messes up the docx to edit it in LO.

Correct LO Writer or MS Word style usage is important.

OTOH, for POD, the PDF export is fine. The Epub export is really poor and not much different to Writer2Epub.
Quoth is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Span Span Span Sigil cleaning up indesign blackest Sigil 31 12-06-2017 10:16 AM
Trouble removing span class mufc Recipes 3 03-18-2011 03:29 PM
'Heading color' and 'p class span' mufc Recipes 7 12-22-2010 09:02 PM
Multi-Level TOC edbro Calibre 4 09-16-2010 06:54 PM
Multi level TOC PAQUITO Bookeen 1 12-23-2009 03:57 AM


All times are GMT -4. The time now is 01:14 AM.


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