View Single Post
Old 07-14-2011, 06:06 PM   #2
charleski
Wizard
charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.
 
Posts: 1,196
Karma: 1281258
Join Date: Sep 2009
Device: PRS-505
The obvious answer is to wrap the code in a <pre> tag. This will set the font to monospaced and preserve all the whitespace and line-breaks. You can set the text to wrap if a line is too long for the display by using the following css:
pre {
white-space: pre-wrap;
}
This will wrap the code in ADE at least (most ereaders), and should also do so on the iPad. The problem is it looks a bit ugly, as the code wraps from the left side of the following line.

If you want to do this is InDesign, then you're making a lot more work for yourself, since you'll have to assign each line the correct level of indent. On the plus side, this will allow you to give the lines hanging indents so long lines wrap under their parent. You will need to edit the css after export to add font-family: monospaced; to the relevant selectors.
charleski is offline   Reply With Quote