Here's how I convert .chm to epub. Converting to other formats might work too.
- Use CHM Decoder to create a folder with all of the files in it.
- Find the contents file (often it's named contents.htm) and rename it toc.htm
- Open all of the html files in a text editor. I use Notepad++. Replace in all of the files the name of the contents file with toc.htm. e.g. replace contents.htm with toc.htm. Make sure you do this in all of the files.
- Create a .zip archive with the contents of all of the files and directories.
- Drag that into Calibre.
- Convert that file into epub.
I've only tried some simple chm files. I will try some more complex files and let you know how they turn out.