Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 07-14-2011, 03:27 PM   #1
frios
Junior Member
frios began at the beginning.
 
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.
frios is offline   Reply With Quote
Old 07-14-2011, 07: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
Old 07-15-2011, 03:50 AM   #3
Faster
Connoisseur
Faster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of light
 
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!
Faster is offline   Reply With Quote
Old 07-15-2011, 09:06 AM   #4
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,216
Karma: 109735549
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-300, PRS-T1
I think you're best of creating a CSS style for that.
Toxaris is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dingo source code Qwill enTourage eDGe 2 05-27-2011 12:07 PM
Let's create a source code repository for DR 800 related code? jraf iRex 3 03-11-2010 01:26 PM
Source code available AlfonsVH HanLin eBook 3 01-03-2009 03:30 PM
prflrf source code? daqi Sony Reader Dev Corner 5 04-22-2008 12:28 PM
source code?? joblack iRex 1 11-01-2006 01:16 PM


All times are GMT -4. The time now is 12:23 PM.


MobileRead.com is a privately owned, operated and funded community.