6

I have a book in .chm format and I had to convert it into .epub format so I used Calibre for Windows for this operation. I am satisfied with the result except for a hyperlink problem. There are some words in the book that you click to jump to another page where the word's definition is found. So in .epub format when I click to one of those words the link takes me to the beginning of the page where the word is found. By saying beginning of the page, I mean the page group that is linked to one of content title on the left in .chm formatted documents.

In broad explanation, in .chm books you have contents tab on the left and there are titles and when you click one of them the page can be very long or short so when I click a word in a text (in the .epub book) to go to its definition page I am being sent to the top of the page then I have to find the definition by myself on that long page.

What can be the problem? I am not very familiar with the file formats so I cannot identify the problem to find the solution. Are these kind of hyperlinks directly linked to word (like searching) or to a page number?

Thanks

Update One: Here is how one of the links appears in .chm

mk:@MSITStore:C:\Users\XXXX\Desktop\Mybook.chm::/7859final/LiB0052.html#8960

And this is .epub version of the same link source

file:///C:/Users/XXXX/Desktop/Mybook/LiB0052_split_001.html#8960

This is html code

<a href="LiB0052_split_001.html#8960" target="_parent" class="pcalibre2 pcalibre3">GARP</a>
1
  • It sounds as if you are saying that the glossary for your chm contains all the definitions, and the problem is that every defined word goes to the top of the page (instead of going to the right part of the page). That sounds like a problem with hyperlink anchors not working. Aug 8, 2016 at 1:53

1 Answer 1

1

CHM and epub are based on html files, but generally the production method for chm determines how simple the code is. Often the HTML files in the CHM files are made of complicated code which confuse calibre.

The first question to ask is: why do you want to convert it to epub? 1)Because you have one special file you wish to read in that format or 2)eventually you want to republish (i.e., "repurpose") the content so that others can read it in an epub reader? or 3)you have many different chm files you wish to convert.

If you need it just for your reference, I would try skipping the step of converting to epub and just look for a chm reader on your device. Android and Ios have decent apps which can read chm files natively. That is always the best option.

I tried converting a simple chm to epub using calibre. Guess what? All the hyperlinks work for me. It sounds as if you are saying that the glossary for your chm contains all the definitions, and the problem is that every defined word goes to the top of the page (instead of going to the right part of the page). My test files don't have anchors, so I cannot see what you are talking about.

To diagnose the problem, you need to view the source of the chm and epub.

The first step is renaming the epub to zip and then unzipping everything so you can see the html. Then open one of the files in a text editor (or open it in a browser, right click and select VIEW SOURCE).

You can also view source in a chm file on Windows. Just right click on the topic with a defective hyperlink, view the hyperlink and see what is supposed to happen.

From doing these two steps (and especially the first), you can see why the hyperlinks in the epub are not working. Perhaps epub stripped the part of the hyperlink that would put the target hyperlink to the middle of the page. Normally it should look like this <a href="first.html#elephant"> where "elephant" refers to the anchor in the middle of the page.

Another possible cause of the problem is that the chm file might be doing weird stuff. Perhaps, depending on the authoring tool which produced the chm file, javascript is making the anchor (I'm guessing randomly here).

Another possibility is that when producing the epub file from chm, for some reason calibre removed the anchor references. If the glossary page does not have something like:

<h2 id="elephant"> or <a id="elephant">

it will be impossible for the hyperlink to find the anchor on that file.

Calibre gives you powerful tools (like regular expressions) to rewrite certain code when converting. (although it may take you a while to learn how). If you are motivated, you can probably just re-edit the html files and make sure the references work and then rezip it again and rename the file extension to epub.

Again, without seeing the HTML source, it's hard to know where the problem lies. But again, finding an chm reader to read the file natively would probably be the easiest thing to do.

2
  • Okay, I have checked the html pages inside epub file indivually using a browser (chrome) and everything is working okay. I am directed to the correct page every time I click hyperlinked words. I face the above mentioned problem when I try to read created epub file (by calibre) on my NST (nook). Nook does not support *chm files so that is why I converted it to epub. I guessing that nook's paging properties cause this. You may know that in 6 inch e-book readers 4 pages equal to 1 page or something like that. Is there anything I can do? I appreciate your time. Aug 8, 2016 at 19:36
  • I know a lot about Nook Simple Touch, and I have never had problems like that. The hyperlink code looks ok; perhaps try to open in another ebook reader and see if the problem still occurs. Try Google Play Books or Adobe Digital Editions. Another thing thing. try to find an example where the target html file is different from the source html. Aug 9, 2016 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.