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

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 04-21-2010, 09:28 PM   #1
NASCARaddicted
Addict
NASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and grace
 
Posts: 312
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch
Need help with XPath

Hello

I don't knpw if this is possible or not, so I hope you can help me.

Right now I am working on an ebook in html.

The chapter starts with roman numbers and the chapter name. The roman number is in h3, the chapter name in h4.

So it looks like

III

A new Beginning.


Now, I want to convert it to epub with Calibre. Under chapter recognition, I used //*[re:match(name(), 'h4')] . In the chapter list, I see it as "A new Beginning". Basically, that is exactly what I wanted - in the past.

But now I thought to myself: It would be better, if the roman number would be included.
In the chapter list, it should look like III - A new Beginning
Is that possible ? I thought, something like //*[re:match(name(),'h3' - 'h4')] should work, but so far, the preview in Calibre doesn't show roman numbers.

Can anyone tell me, how the correct expression should be ?

Thanks in advance
NASCARaddicted is offline   Reply With Quote
Old 04-22-2010, 02:31 AM   #2
paulpeer
Zealot
paulpeer is on a distinguished road
 
paulpeer's Avatar
 
Posts: 147
Karma: 56
Join Date: Dec 2009
Location: Antwerpen
Device: iPhone, Sony PRS-505, EPUBreader
You could try the following: in the HTML files instead of
Code:
<h4>A new beginning</h4>
you use
Code:
<h4 title="III. A new beginning">A new beginning</h4>
and see if it works.
I didn't try it in Calibre but in Sigil this is the way how to do it.

Last edited by paulpeer; 04-22-2010 at 02:51 AM. Reason: typos
paulpeer is offline   Reply With Quote
 
Advertisement
Old 04-22-2010, 06:35 AM   #3
NASCARaddicted
Addict
NASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and grace
 
Posts: 312
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch
I tried it, but either Calibre doesn't accept it (what I doubt) or my xpath is still wrong.

What Xpath expression do you use in Sigil?
NASCARaddicted is offline   Reply With Quote
Old 04-22-2010, 06:36 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: 26,808
Karma: 5456159
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You can't use XPath to insert content.
kovidgoyal is offline   Reply With Quote
Old 04-22-2010, 06:37 AM   #5
NASCARaddicted
Addict
NASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and grace
 
Posts: 312
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch
O.k. thanks Kovid.

And thanks Paulpeer
NASCARaddicted is offline   Reply With Quote
Old 04-22-2010, 07:06 AM   #6
paulpeer
Zealot
paulpeer is on a distinguished road
 
paulpeer's Avatar
 
Posts: 147
Karma: 56
Join Date: Dec 2009
Location: Antwerpen
Device: iPhone, Sony PRS-505, EPUBreader
Quote:
Originally Posted by NASCARaddicted View Post
What Xpath expression do you use in Sigil?
You don't need Xpath in Sigil. All h-headers (h1, h2 etc) automatically come into the table of contents, unless you explecitely tell Sigil not to do so.
paulpeer is offline   Reply With Quote
Old 04-22-2010, 12:16 PM   #7
DaleDe
Grand Sorcerer
DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.
 
DaleDe's Avatar
 
Posts: 9,923
Karma: 5235628
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2
Quote:
Originally Posted by NASCARaddicted View Post
I tried it, but either Calibre doesn't accept it (what I doubt) or my xpath is still wrong.
What I do is put both in a single h2 statement and separate them with a <br /> tag. They end up on one line in the toc and two lines in the text.

Something like <h2>III<br />Chapter</h2>

Dale
DaleDe is offline   Reply With Quote
Old 04-23-2010, 01:59 PM   #8
charleski
Wizard
charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.
 
Posts: 1,188
Karma: 727236
Join Date: Sep 2009
Device: PRS-505
There's another way that might work with calibre. Define a selector that hides the text:
Code:
.hidethis {
  visibility: hidden
}
Construct your heading as you'd like it to appear in the ToC, then hide the part you don't want to see in the flow of text.

Thus:
Code:
<h3>III<span class="hidethis"> - A New Beginning</span></h3>
<h4>A New Beginning</h4>
Then use the h3 tag as the source of your ToC name.
This would work if calibre simply strips out the css from text that's used for ToC names. I think it's worth a try.
charleski is offline   Reply With Quote
Old 04-24-2010, 04:35 AM   #9
NASCARaddicted
Addict
NASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and grace
 
Posts: 312
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch
Thank you Charleski

It works - but it gave me a new problem.

I tried it like you said, and the TOC really looks great, exactly like I wanted it to ...

... but in the flow text, the roman number is not centered anymore. Of course, that is just logic, because the hidden part is also inside the h3 tag.

So I tried to center just the roman number with a div tag, and this works, too. Now I am happy
NASCARaddicted is offline   Reply With Quote
Old 04-24-2010, 04:20 PM   #10
frabjous
Wizard
frabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
frabjous's Avatar
 
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
Instead of

Code:
.hidethis {
  visibility: hidden
}
Try
Code:
.hidethis {
  display: none;
}
frabjous is offline   Reply With Quote
Old 04-25-2010, 05:16 AM   #11
NASCARaddicted
Addict
NASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and grace
 
Posts: 312
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch
thanks frabjous, this seems to work even better.

The roman number is still centered, and in the TOC, everything shows up.

This is much easier then what I had planned. I wanted to center the roman numbers with div tags (since span tags don't center) but div tags within heading tags is not xhtml valid. I thought about getting rid of the heading tags at all and just use div tags, but with your way, it is much easiert.
NASCARaddicted is offline   Reply With Quote
Old 04-25-2010, 05:41 AM   #12
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,541
Karma: 5000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
When <div> tags are not allowed, you can use <span> with "display: block"
Jellby is offline   Reply With Quote
Old 04-25-2010, 06:20 AM   #13
NASCARaddicted
Addict
NASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and graceNASCARaddicted herds cats with both ease and grace
 
Posts: 312
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch
Quote:
Originally Posted by Jellby View Post
When <div> tags are not allowed, you can use <span> with "display: block"
Yeah, I also found that out through google, but luckily, I don't need the div tags right now due to the display: none code.

But thanks for pointing it out Jellby.
NASCARaddicted is offline   Reply With Quote
Old 02-20-2015, 07:04 AM   #14
doylejohn
The Leprechaun
doylejohn began at the beginning.
 
doylejohn's Avatar
 
Posts: 6
Karma: 10
Join Date: Feb 2015
Location: Chapel Hill, NC
Device: none
Another Calibre Problem

I write poems also Kovid. I have a e-book of one hundred and two of them called Picturesque many sites Scribd being one of them in the form of a PDF. In other formats the book is completely in jpeg pages of any other file format whether it is epub or mobi ect... My problem is to get it in the major book stores I need a working Table of Contents. When I try to put in the XPath Expression for Calibre to find the images and alt= "Name" in text the pages in the Table of Contents I cannot do a simple line of code which will work. Also after I get the pages into the Table of Contents I would like the name of the of the pages to become links. Can anyone that knows XPath code better than I do help?
doylejohn 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
Xpath TOC Expression Agama Calibre 2 07-12-2010 03:24 AM
XPath Expression wizard?? tonyx3 Calibre 1 01-26-2010 05:49 AM
XPath question krischik Calibre 0 01-16-2010 09:22 AM
XPath Help and Pagebreak emellaich Calibre 3 07-28-2009 03:17 PM
XPath query amjbrown Calibre 2 05-10-2009 07:04 PM


All times are GMT -4. The time now is 05:45 PM.


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