![]() |
#61 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
|
Thanks for cleaning up the posting BetterRed. -Rob557
|
![]() |
![]() |
![]() |
#62 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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
|
![]() |
![]() |
Advert | |
|
![]() |
#63 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
|
Quote:
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 ? |
|
![]() |
![]() |
![]() |
#64 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,334
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Single quotes work for me.
|
![]() |
![]() |
![]() |
#65 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
|
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")] |
![]() |
![]() |
Advert | |
|
![]() |
#66 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,334
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Code:
//*[re:test(., '"', "i")] |
![]() |
![]() |
![]() |
#67 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() 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? |
![]() |
![]() |
![]() |
#68 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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
|
![]() |
![]() |
![]() |
#69 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
![]() |
![]() |
![]() |
|
![]() |
||||
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 |