View Single Post
Old 04-01-2011, 06:11 PM   #1
zaph0d
Junior Member
zaph0d began at the beginning.
 
Posts: 3
Karma: 20
Join Date: Apr 2011
Device: Kindle
Preserving Indentation

To Whom it may concern!
I've been trying to convert "The C Programming Language Ritchie & kernighan" from PDF to mobi and all the time I get the code blocks stripped of the indentation - really ugly.
Finaly I came up with some sort of solution

Settings->Conversion->Common Options->Search and replace

Search: [\s]{2}
Replace:   

It may not be very elegant but it works ))

Now this:
Code:
main()
21
{
int c, nl;
nl = 0;
while ((c = getchar()) != EOF)
if (c == '\n')
++nl;
printf("%d\n", nl);
}
became this:

Code:
    main()
21
    {
        int c, nl;
        nl = 0;
        while ((c = getchar()) != EOF)
            if (c == '\n')
                ++nl;
        printf("%d\n", nl);
    }
Another trick

Table of contents in pdf files turns to something like this:
1.5.2 Character Counting.......................................... ........................................19
1.5.3 Line Counting.......................................... .......................................20
1.5.4 Word Counting.......................................... ..................................21

which gets carried over 2 lines.. very ugly
So, put another replacement:
Search: \.\.\.\.\.\.\.\.\.\.\.\.\.\.\.
Repace: <EMPTY>

Cheerz
zaph0d
zaph0d is offline   Reply With Quote