View Single Post
Old 03-01-2018, 08:06 PM   #4
sjfan
Addict
sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.
 
Posts: 281
Karma: 7724454
Join Date: Sep 2017
Location: Bethesda, MD, USA
Device: Kobo Aura H20, Kobo Clara HD
Quote:
Originally Posted by teresatenured View Post
My Kindle (Paperwhite, 4th Gen) has broken . Half of the screen is 'blurred' with vertical lines, and is totally unresponsive. Tried to hard reset, no luck. Luckily, the top half of the screen (6.5 cm) works.

I am trying to make some use of it before I finally chuck it. I looked into swapping out the Kindle screen, but after some research it doesnt seem feasible. Rather, id like to format my Ebooks to make them readable on my defunct Kindle. I can see about 600 contiguous characters of text on the screen. Then the letters start to blur.

So id like to make it so that each kindle page only shows 600 characters. After 600 characters, I would like to insert a page break. Then after 600 more characters, another page break. I would like to do this for all my books, so that they will be readable on my broken Kindle.

Any Ideas on how to add page breaks, either in Calibre or Word or Acrobat? I've had some success adding page breaks on a short document in Word, but I had to literally count 600 characters and then click 'Insert Page Break'. The document was readable on my Kindle, but it would not be feasible to do this for a whole book.

TLDR; Kindle broke; want to add page breaks to my books after each 600 characters of text.

Thanks!
For a proper solution you'd want a true parser, but you can do something quick and dirty with regexes. If all your body paragraphs are class="para", for instance:

In Calibre's editor, regex search for:
Code:
(?ms)(.{600}.*?)<p class="para">
Replace with:
Code:
\1<p class="para break">
And make sure the "break" style has "page-break-before: always" set.

This will search for 600 characters (but includes code characters as well as displayed text), and then find the next <p class="para"> and turn it into a para/break tag. The ? here is to make the prior expression non-greedy, so you find the shortest possible distance to the next tag (regexes default to longest possible).

If things are heavily marked up it won't be very accurate, and you may want to dial it down to 500 or so because it looks ahead for the next paragraph after the 600 characters are up (rather than creating a new paragraph break mid-paragraph).

Or you could use "\. " instead of the '<p class="para">' search (untested, but something like that) and do a replace of
Code:
\1. <div class="break"></div>
if you want to insert hard breaks mid paragraph. You have to be kind of careful selecting the search regex here so you don't break in the middle of an HTML tag.
sjfan is offline   Reply With Quote