07-14-2011, 02:27 PM | #1 |
Junior Member
Posts: 1
Karma: 10
Join Date: Jul 2011
Device: none
|
Help formatting Source Code
I am hoping that someone can point me to resources and how to's on how best to format computer source code for pub. Basically I have several programming books which have embedded blocks of source code that I wish to keep the formatting for. Is there a "best practice" for this? The original material is in MSWord and the book layout is being done in InDesign CS5.5 if that helps.
|
07-14-2011, 06:06 PM | #2 |
Wizard
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. |
Advert | |
|
07-15-2011, 02:50 AM | #3 |
Connoisseur
Posts: 61
Karma: 12096
Join Date: Sep 2010
Location: Tasmania
Device: Sony PRS 650
|
"how best to format computer source code for pub."
I'll drink to that! |
07-15-2011, 08:06 AM | #4 |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
I think you're best of creating a CSS style for that.
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dingo source code | Qwill | enTourage eDGe | 2 | 05-27-2011 11:07 AM |
Let's create a source code repository for DR 800 related code? | jraf | iRex | 3 | 03-11-2010 12:26 PM |
Source code available | AlfonsVH | HanLin eBook | 3 | 01-03-2009 02:30 PM |
prflrf source code? | daqi | Sony Reader Dev Corner | 5 | 04-22-2008 11:28 AM |
source code?? | joblack | iRex | 1 | 11-01-2006 12:16 PM |