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-23-2023, 11:40 AM   #1
hihohahi
Junior Member
hihohahi began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Feb 2023
Device: none
Concat 2 xpath results

Hello,

My start of my chapter looks like this. This I cannot change.
<p class="Chapter">Chapter 1 </p>
<p class="ChapterName">ABCDEF</p>

And when I make the TOC, I can only match one of them and have to fill the other by hand.
This has bugged me for a long time. Is there a way to concatenate the results from 2 xpath?

I want something like this
concat(//*[contains(@class, 'Chapter')], //*[contains(@class, 'ChapterName')])
would return No items found: No items were found that could be added to the Table of Contents.

Thanks so much for reading.
hihohahi is offline   Reply With Quote
Old 02-23-2023, 12:00 PM   #2
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 36,798
Karma: 147879470
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
For the most part when I see chapter headers using p tags, I would create a hidden header item using regex and then create the ToC from the header tags.

source: <p class="chapter">(.*?)</p> <p class="ChapterName">(.*?)</p>

dest: <h3 class="hidden" title="\1: \2">\1: \2</h3> <p class="chapter">\1</p> <p class="ChapterName">\2</p>

<h3 class="hidden" title="Chapter 1: ABCDEF">Chapter 1: ABCDEF</h3>
<p class="Chapter">Chapter 1 </p>
<p class="ChapterName">ABCDEF</p>
DNSB is offline   Reply With Quote
Advert
Old 02-23-2023, 01:00 PM   #3
hihohahi
Junior Member
hihohahi began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Feb 2023
Device: none
Quote:
Originally Posted by DNSB View Post
For the most part when I see chapter headers using p tags, I would create a hidden header item using regex and then create the ToC from the header tags.

source: <p class="chapter">(.*?)</p> <p class="ChapterName">(.*?)</p>

dest: <h3 class="hidden" title="\1: \2">\1: \2</h3> <p class="chapter">\1</p> <p class="ChapterName">\2</p>

<h3 class="hidden" title="Chapter 1: ABCDEF">Chapter 1: ABCDEF</h3>
<p class="Chapter">Chapter 1 </p>
<p class="ChapterName">ABCDEF</p>
Thank you! this works!
hihohahi is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search results only show first result. How can I view successive results? lovedj1 Calibre 2 05-07-2021 07:53 AM
"all results" search results no longer working? 4691mls Kobo Reader 2 11-03-2020 10:59 AM
Forma Search-in-book results sometimes ends on page17, even if there's more (hidden)results droopy Kobo Reader 9 06-30-2020 11:05 AM
Need help with XPath NASCARaddicted ePub 13 02-20-2015 06:04 AM
Can't concat strings: NoClassDefFoundError indeed Kindle Developer's Corner 6 09-03-2013 02:03 PM


All times are GMT -4. The time now is 11:20 AM.


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