I just downloaded the latest Calibre update released today. And I have tried converting some programming books in PDF format with this new version as well the previous version before this. The problem I have is that the sample code listings are mangled or re-flown during conversion to epub.

I even downloaded Sigil to see if it was something I could fix manually. But it seems like Calibre is outputting the code in a <p> tag with "calibre2" style applied just like the rest of the book. Meaning it is too late for Sigil to do anything.

I also noticed that the page headers are not being removed correctly so I have unnecessary page breaks (and page numbers and text). However, there are options in Calibre to specify a regex. So it's only a matter of (!) learning the right regex and putting it in there. But if there is no way to fix the code listing problem then I'd rather not waste my time on this.

I noticed that every listing in the PDF begins with a header with text "Listing 1.1". I am not sure if there is a way to specify the regex for inserting a <Pre> tag at these places.

Save for these two issues with PDF's, the tool works like a charm. So a grateful thanks to the author kovid. I used it to convert a .CHM with code listings and all to epub. So if it understood that, there's gotta be a way to make it understand this.

Interesting... I just found pdfonline.com and gave it my PDF. It butchered the TOC and did some slightly funky formatting but kept the code samples intact. The conversion timed out so it only gave me a partial document back. I did not bother to check the length as I was more interested in the formatting anyway.

I then gave the rtf to Calibre and it kept the code formatted correctly!

The funky formatting got funkier and headers were shown as text too. Overall, its unusable, but the code was transferred correctly.