View Single Post
Old 01-18-2011, 12:01 PM   #1
yelloguy
Enthusiast
yelloguy is fluent in JavaScript as well as Klingon.yelloguy is fluent in JavaScript as well as Klingon.yelloguy is fluent in JavaScript as well as Klingon.yelloguy is fluent in JavaScript as well as Klingon.yelloguy is fluent in JavaScript as well as Klingon.yelloguy is fluent in JavaScript as well as Klingon.yelloguy is fluent in JavaScript as well as Klingon.yelloguy is fluent in JavaScript as well as Klingon.yelloguy is fluent in JavaScript as well as Klingon.yelloguy is fluent in JavaScript as well as Klingon.yelloguy is fluent in JavaScript as well as Klingon.
 
Posts: 30
Karma: 4698
Join Date: Jan 2011
Device: none
Converting PDF with code samples - losing battle?

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.
yelloguy is offline   Reply With Quote