View Single Post
Old 11-26-2010, 02:58 PM   #7
janvanmaar
Addict
janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.
 
Posts: 219
Karma: 404
Join Date: Nov 2010
Device: Kindle 3G, Samsung SIII
Quote:
Originally Posted by tram View Post
I'm converting a few books to go on my kindle, and I'm trying to get the chapters set up the way I want. One thing I'm noticing is that Calibre seems to use a slightly different flavor of xpath than what I'm used to. Where I would write
Code:
//p[matches(., '^[A-Z ]+$')]
, Calibre seems to respond to things in the form
Code:
//h:p[re:test(., '[A-Z]+')]
Yes, I was also surprised by the XPath syntax. I believe it is Calibre specific thing, Kovid may correct me if I am wrong. But it was very simple to get used to it.

Quote:
Originally Posted by tram View Post
re:test seems to behave differently than matches. Is there any documentation on re:test, or anything anyone can tell me that might enhance my googling abilities?

The regular espression I'm trying to use that works with matches but not with re:test follows:

Code:
/h:p[re:test(., '^[A-Z]+ [A-Z ]+$')]
This should work fine (with two slashes at the beginning of course). I am using regexps like this regularly in Calibre. Are you sure the text is in the p tag and not for instance wrapped in div or some other tag or is not divided between more tags AFTER calibre html processing? You can find out by checking the debug option and looking to the chosen debug directory with HTML file Calibre is really processing.
janvanmaar is offline   Reply With Quote