Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 03-01-2017, 06:28 PM   #61
Rob557
Zealot
Rob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-books
 
Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
Thanks for cleaning up the posting BetterRed. -Rob557
Rob557 is offline   Reply With Quote
Old 03-01-2017, 09:29 PM   #62
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,334
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Simply change the surrounding quotes from " to ' then you can include " inside
kovidgoyal is online now   Reply With Quote
Advert
Old 03-02-2017, 06:12 AM   #63
Rob557
Zealot
Rob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-books
 
Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
Quote:
Originally Posted by kovidgoyal View Post
Simply change the surrounding quotes from " to ' then you can include " inside
Good idea, however I'm not sure why, but that alternative approach does not seem to work either.

I tried to modify the second set of coding noted earlier (which otherwise runs okay) by replacing one of the occurrences of [\.\!\?] with ['"'\.\!\?], where the three inserted characters are a double quote surrounded by single quotes, but that change resulted in an error message that the xpath expression was invalid.

Similarly, in the first (simpler) set of coding I tried replacing [a-z] with [a-z'"'] but the same error message results as when I try using " or \" or """ or "" .

If the usual "escape" approaches don't work, a guess would be that maybe the Edit ToC xpath process itself currently assumes that double quotes are used exclusively for the purpose of demarcating the start and end of the RegEx expression, and the occurrence of a double quote anywhere within the RegEx expression is considered invalid ?
Rob557 is offline   Reply With Quote
Old 03-02-2017, 06:18 AM   #64
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,334
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Single quotes work for me.
kovidgoyal is online now   Reply With Quote
Old 03-02-2017, 07:35 AM   #65
Rob557
Zealot
Rob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-books
 
Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
Quote:
Originally Posted by kovidgoyal View Post
Single quotes work for me.
Hmmm. I'm misunderstanding something. Maybe the problem is that there are different versions of quotes depending on what "keyboard" is being used? Could you include a copy of the xpath expression that you are using?

Alternatively, if you copy the following xpath expression, could you confirm if it works for you? I get an 'invalid' error message.
Code:
//*[re:test(., "'"'", "i")]
Rob557 is offline   Reply With Quote
Advert
Old 03-02-2017, 07:40 AM   #66
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,334
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Code:
//*[re:test(., '"', "i")]
kovidgoyal is online now   Reply With Quote
Old 03-02-2017, 08:06 AM   #67
Rob557
Zealot
Rob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-books
 
Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
Thanks Kovid. I now understand.

You were not referring to my putting single quotes around the double quote within the RegEx expression but instead using the double quote BY ITSELF (with no escape code or single quote enclosures) within the RegEx expression, and at the same time using single quotes to replace the double quotes (as normally generated by the xpath process) that enclose the ENTIRE RegEx expression.

That work-around does the trick. Thank you.

One ancillary question is that I now realize that I should simultaneously be looking for potential ToC entries that could end in either a single quote or a double quote. In that case, I was wondering if there is another character that could be used to enclose the entire RegEx expression within the xpath instruction if both a single quote and double quote were used within the RegEx expression?
Rob557 is offline   Reply With Quote
Old 03-02-2017, 09:14 AM   #68
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,334
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
xpath 1.0 has no way of escaping inside string literals, you'd need to use a trick with concat() for example see https://stackoverflow.com/questions/...ium-for-python
kovidgoyal is online now   Reply With Quote
Old 03-02-2017, 09:35 AM   #69
Rob557
Zealot
Rob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-booksRob557 has learned how to read e-books
 
Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
Thanks for identifying that xpath limitation and a potential workaround.

I guess it is unlikely that a single ePub would use both single and double quotes for ToC entries, so the other work-around on that ancillary question would be to interchange the role of the single and double quotes (i.e. within the RegEx expression and enclosing the RegEx expression) if it was determined that one type of quote mark was being used in a particular ePub ToC rather than the other type.

Kovid, thanks again for identifying approaches for the xpath coding.
Rob557 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Introducing New tool: "Polish" Books kovidgoyal Calibre 134 10-12-2024 03:02 AM
New Edit ToC tool library addict Calibre 2 03-15-2013 04:49 AM
Release : New Tool to Edit ePubs TOC, Edit with Sigil and keep you TOC Nigol ePub 105 10-29-2012 11:40 AM
Getting calibre to detect "Prologue" and "Epilogue" for TOC sherman Calibre 2 09-20-2010 02:21 AM


All times are GMT -4. The time now is 11:26 PM.


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