View Single Post
Old 10-12-2010, 08:58 PM   #14
sergio blum
Member
sergio blum began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Aug 2009
Device: SONY READER
epub <pre> brain drain </pre>

@jackie_w
(Word 2003 would not open XTML pages because it found "&nbsp" and wouldnt even after removal of "&nbsp". A friend told me Word 2007 will.)


Regardless the above, the solution seems indeed now straghforward enough:
(and can be later generalised for any number of files and CSS styles)

Convert CHM into EPUB in Calibre

In Sigil, fine tune fonts as desired

Open EPUB in the winrar program

Shift select the relevant html files

Drag (unrar) the files selected to an empty folder created in Windows Explorer

Change all html extensions to txt

Run Word macro that for each txt file (Word will open TXTs in any circumstances) will insert <br /> at the end of each sentence enclosed "between" <pre> and </pre> (to prevent individual paragraphs [programming lines of code in the book] from collapsing into sentences belonging to only one paragraph when substituting p for pre).

Macro will then replace all pre tags with p tags

In Sigil, tweak the CSS manually (a) removing any references to whitespace so lines of code will reflect (b) fine tuning line-height as desired, and create the styles that will define h1 {font-family: monospace;} and
h2 {font-family: sans-serif;}.

Change txt extensions back into html

Form Windows Explorer, drag modified set of html files back into the EPUB.

Visually check results in Sigil.

In Calibre, just Add File and download it to Reader.

Read the book!
= = =

Crucially, I have tested manually the insertion of <br /> tags and replacement of pre with p.

= = =
sergio blum is offline   Reply With Quote