Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 09-01-2018, 11:46 AM   #1
PenguinCEO
Junior Member
PenguinCEO began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Sep 2018
Device: a lot
Editor - feature request

In some areas of the editor there's the option to use xpath to perform searches. But xpath is cumbersome and doesn't work in calibre quite completely.

It would be a lot easier and productive to use a regex in the place of xpath.

For example, in the place of
Code:
//meta[@name="mainsection"]/@content
that it doesn't work, one could use as well
Code:
<meta name="mainsection" content="(.*?)"/>
that is a lot more readable. Moreover, regex are fully tested and functional in calibre.
PenguinCEO is offline   Reply With Quote
Old 09-01-2018, 11:30 PM   #2
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: 33,496
Karma: 10205098
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
XPath is fully function as well, not to mention that you can use regex inside XPath expressions. Your XPath expression should be

//h:meta[@name="mainsection"]
kovidgoyal is offline   Reply With Quote
Old 09-02-2018, 04:59 AM   #3
PenguinCEO
Junior Member
PenguinCEO began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Sep 2018
Device: a lot
Quote:
Originally Posted by kovidgoyal View Post
XPath is fully function as well...
Your XPath expression should be...
Hi Kovid, nice to meet you.

My xpath expression is for returning the value of the attribute "content" of all the tags "meta" whose "name" attribute is "mainsection", and it seems to work.

Now try this: open an epub with the editor, add the following lines into an html file:

Code:
<meta name="notoc" content="Nulla"/>
<meta name="toc" content="L'uccello padulo"/>
and try to add the value "L'uccello padulo" to the toc ("Generate ToC with XPath") with one of the following expressions

Code:
//meta[@name="toc"]/@content

//h:meta[@name="toc"]/@content
the result in both the cases is:

Code:
calibre, version 3.30.0
ERROR: No items found: No items were found that could be added to the Table of Contents.
Maybe it's an an error of myne, but it seems to not work.

Surely I could use a workaround like this:

Code:
<meta class="toc">L'uccello padulo</meta>
//h:meta[re:test(@class, "toc", "i")]
but the point remains unchanged: the preceding normal version of the xpath expression seems not to be understood by calibre.

Regards.
PenguinCEO is offline   Reply With Quote
Old 09-02-2018, 05:31 AM   #4
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: 33,496
Karma: 10205098
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you want to generate a ToC with an XPath expression, your XPath expression has to end with a tag the toc entries will point to the matched tags. ToC entries cannot point to attributes.
kovidgoyal is offline   Reply With Quote
Old 09-02-2018, 05:32 AM   #5
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: 33,496
Karma: 10205098
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
And for that matter, toc entries must point to tags in the body not tags inside the <head> like <meta>
kovidgoyal is offline   Reply With Quote
Old 09-02-2018, 05:49 AM   #6
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 15,284
Karma: 24761108
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo: Touch, Glo, Aura H2O, Glo HD, Aura ONE, Clara HD
@Kovid: I think in this case they want to generate the text to be used in the ToC entry when pointing to the file. There might not be something near the start of the file that is suitable. I know that I sometimes add a heading with a "hidden" class to achieve this. But, if there was something suitable in the <head> section, I would use it. For example, using the contents of the <title> tag would make sense.

In the OPs case, it looks like they wants to use the <meta> to specify which files have a ToC entry, and what the entry text is. I can see the point, but I'm not sure if would be a common use case. Especially as I tend to the opinion that all the files should have a ToC entry.
davidfor is offline   Reply With Quote
Old 09-02-2018, 06:10 AM   #7
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: 33,496
Karma: 10205098
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The way the ToC wizard works is that it generates both the text and the link for each toc entry, you cannot use it just to generate text. So therefore it requires a tag in the body with text included. If for some reason you dont want that text displayed, the way to do it, as davidfor mentioned is to simply hide it with CSS, the the ToC wizard will read it and link to it, but it wont be visible when the book is read.
kovidgoyal is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Feature Request: Non-modal Metadata Editor Window Katsunami Calibre 3 03-20-2018 06:19 PM
Feature Request for Editor therealjoeblow Calibre 3 05-13-2016 04:12 PM
WriteItNow 5 - now has a StoryLine Editor (a timeline feature) Dr. Drib Writers' Corner 2 07-06-2015 07:10 AM
yet another feature request arslonga Marvin 0 11-15-2014 01:41 AM
Feature request iridius Library Management 1 02-22-2011 09:57 PM


All times are GMT -4. The time now is 04:51 PM.


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