Answers.Body: <p>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.  </p>
  
  <p>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. </p>
  
  <p>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. </p>
  
  <p>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. </p>
  
  <p>To diagnose the problem, you need to view the source of the chm and epub. </p>
  
  <p>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). </p>
  
  <p>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. </p>
  
  <p>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 <code>&lt;a href="first.html#elephant"&gt;</code> where "elephant" refers to the anchor in the middle of the page. </p>
  
  <p>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). </p>
  
  <p>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: </p>
  
  <pre><code>&lt;h2 id="elephant"&gt; or &lt;a id="elephant"&gt;
  </code></pre>
  
  <p>it will be impossible for the hyperlink to find the anchor on that file. </p>
  
  <p>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.  </p>
  
  <p>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. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-08T19:36:08.320Z
Answers.Text: 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.
Answers.UserDisplayName: Karel Capek
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-09T19:58:30.460Z
Answers.Text: 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.
Answers.UserDisplayName: idiotprogrammer
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-08T02:22:58.060Z
Answers.LastActivityDate: 2016-08-08T02:22:58.060Z
Answers.UserDisplayName: idiotprogrammer
Body: <p>I have a book in <code>.chm</code> format and I had to convert it into <code>.epub</code> 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 <code>.epub</code> 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 <code>.chm</code> formatted documents.</p>
  
  <p>In broad explanation, in <code>.chm</code> 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 <code>.epub</code> 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.</p>
  
  <p>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?</p>
  
  <p>Thanks</p>
  
  <p><strong>Update One:</strong>
  Here is how one of the links appears in <code>.chm</code></p>
  
  <pre><code>mk:@MSITStore:C:\Users\XXXX\Desktop\Mybook.chm::/7859final/LiB0052.html#8960
  </code></pre>
  
  <p>And this is <code>.epub</code> version of the same link source</p>
  
  <pre><code>file:///C:/Users/XXXX/Desktop/Mybook/LiB0052_split_001.html#8960
  </code></pre>
  
  <p>This is html code</p>
  
  <pre><code>&lt;a href="LiB0052_split_001.html#8960" target="_parent" class="pcalibre2 pcalibre3"&gt;GARP&lt;/a&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-08T01:53:26.123Z
Comments.Text: 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.
Comments.UserDisplayName: idiotprogrammer
Tags: <epub><calibre><conversion>
Title: Problem with hyperlinks after converting chm to epub with calibre
UserDisplayName: Karel Capek
ThreadText: # Problem with hyperlinks after converting chm to epub with calibre
  
  (Asked by: username_0 on 2016-08-03)
  
  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
  GARP
  
  **Tags:** epub, calibre, conversion
  
  > **Comments:**
  > **username_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.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-08-08. Score: 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  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: 
   or 
  
  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.
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_1**: 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.  
  
  ---
  
  