|07-14-2011, 02:27 PM||#1|
Join Date: Jul 2011
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|
Join Date: Sep 2009
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:
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.
|Thread Tools||Search this Thread|
|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|