Re-wrapping text files for the Amazon Kindle.

Please be aware there other e-book devices available. 🙂

While I’m between jobs I have found myself re-visiting some classic video games, and using game guides and walk-throughs to refresh my memory. Many of these guides are in the “old-skool” 40 column pre-wrapped text format. Here’s an example. It’s a very comprehensive guide too, but that’s by-the-by.

When I copied it to my Kindle, I found the text was being re-wrapped in an untidy way. It is because the file contains Line Feed characters, which the Kindle correctly uses to start a new line. Reaching back in to the dim and distant corners of my memory, I remembered having to solve this problem in the past.

As someone who used a RISC OS machine a lot more in the past, compared to the past 10 years or so, I turned to the Iyonix which sits on my desk next to my Linux box and started up !Zap. In a lot of ways, I still feel that !Zap has features which have not been bettered on other platforms, well not in free software anyway. The RISC OS developers sorted out USB a long time ago, so I could plug my Kindle directly in to the Iyonix and have it behave as a Mass Storage device.

The strategy is to search for any line which contains a non-zero number of characters, which is immediately followed by another line which contains a non-zero number of characters. I seem to recall that Darren Salt, one of the lead !Zap developers had suggested this years ago. (Apologies if I have that wrong).

Anyway, if you set up the search-and-replace (Shift-F4 within !Zap) with these options enabled: Raw, ‘\’ commands, Macros on.

&1 &2

Remember this will not work correctly for tables of contents, so start the search from the first line of the first paragraph, and remember to use the Forwards Replace, so it starts at the current cursor position. The relevant chapter on search and replace is here.

If any RISC OS users want to step in and improve this process, please comment.
If there is a Linux-based route to solve this problem, please let me know too.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: