02-10-2024, 05:15 AM | #1 |
Junior Member
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"> Code:
.span2 {color: #1f3864; font-family: 'Liberation Sans1'; font-size: 20.0000pt; font-weight: bold; } https://i.imgur.com/gRyqHBU.png Code:
//h:h2[re:test(@class, "span2", "i")] 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? |
02-10-2024, 01:41 PM | #2 |
Wizard
Posts: 1,132
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. |
Advert | |
|
02-11-2024, 03:57 AM | #3 | |
Junior Member
Posts: 9
Karma: 10
Join Date: Feb 2024
Device: none
|
Thank you very much for this detailed explanation. It worked very well.
Quote:
|
|
02-11-2024, 04:12 AM | #4 |
Junior Member
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? |
02-11-2024, 04:30 AM | #5 | ||
Wizard
Posts: 1,132
Karma: 4911876
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
Quote:
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:
Once you export from LO, the epub needs a bit of work, tidying up the tags, then I create the TOC once completed. Last edited by Karellen; 02-11-2024 at 01:30 PM. |
||
Advert | |
|
02-11-2024, 07:47 AM | #6 |
the rook, bossing Never.
Posts: 11,346
Karma: 85874895
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. |
|
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 |