04-21-2010, 08:28 PM | #1 |
Addict
Posts: 340
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch, Pocketbook Touch HD
|
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 |
04-22-2010, 01:31 AM | #2 |
Zealot
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> Code:
<h4 title="III. A new beginning">A new beginning</h4> 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 01:51 AM. Reason: typos |
Advert | |
|
04-22-2010, 05:35 AM | #3 |
Addict
Posts: 340
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch, Pocketbook Touch HD
|
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? |
04-22-2010, 05:36 AM | #4 |
creator of calibre
Posts: 43,850
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You can't use XPath to insert content.
|
04-22-2010, 05:37 AM | #5 |
Addict
Posts: 340
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch, Pocketbook Touch HD
|
O.k. thanks Kovid.
And thanks Paulpeer |
Advert | |
|
04-22-2010, 06:06 AM | #6 |
Zealot
Posts: 147
Karma: 56
Join Date: Dec 2009
Location: Antwerpen
Device: iPhone, Sony PRS-505, EPUBreader
|
|
04-22-2010, 11:16 AM | #7 | |
Grand Sorcerer
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
|
Quote:
Something like <h2>III<br />Chapter</h2> Dale |
|
04-23-2010, 12:59 PM | #8 |
Wizard
Posts: 1,196
Karma: 1281258
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 } Thus: Code:
<h3>III<span class="hidethis"> - A New Beginning</span></h3> <h4>A New Beginning</h4> 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. |
04-24-2010, 03:35 AM | #9 |
Addict
Posts: 340
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch, Pocketbook Touch HD
|
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 |
04-24-2010, 03:20 PM | #10 |
Wizard
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
|
Instead of
Code:
.hidethis { visibility: hidden } Code:
.hidethis { display: none; } |
04-25-2010, 04:16 AM | #11 |
Addict
Posts: 340
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch, Pocketbook Touch HD
|
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. |
04-25-2010, 04:41 AM | #12 |
frumious Bandersnatch
Posts: 7,516
Karma: 18512745
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"
|
04-25-2010, 05:20 AM | #13 |
Addict
Posts: 340
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch, Pocketbook Touch HD
|
|
02-20-2015, 06:04 AM | #14 |
The Leprechaun
Posts: 8
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?
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Xpath TOC Expression | Agama | Calibre | 2 | 07-12-2010 02:24 AM |
XPath Expression wizard?? | tonyx3 | Calibre | 1 | 01-26-2010 04:49 AM |
XPath question | krischik | Calibre | 0 | 01-16-2010 08:22 AM |
XPath Help and Pagebreak | emellaich | Calibre | 3 | 07-28-2009 02:17 PM |
XPath query | amjbrown | Calibre | 2 | 05-10-2009 06:04 PM |