|
|
Thread Tools | Search this Thread |
05-08-2007, 12:22 AM | #1 |
Blueberry!
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
|
Pielrf - Text to LRF with Easy TOC, Headers, Curly-Quotes, etc. (Mac!)
Announcing pielrf, a Python command line tool to convert text to Reader LRF format -- provides more features than Sony Connect eBooks! Designed primarily for Mac OS X users, it works under Windows and Linux as well.
Current Version: 2.1.3 Added Preferences File, Verse and Justified Formatting, Extra ConvertLit formatting, Etc., Etc.! Mac OS X GUI also available, thanks to simmepimme! Features very easy Table of Content creation, top-of-page headers (ala Connect Store eBooks), curly quotes and paragraph autoflow, just to name a few. pielrf -i flatland.txt -o flatland.lrf -t "Flatland" -a "Abbott, Edwin A." This will create a book with chapters added to the Reader's Table of Contents Menu, a header at the top/right of every page with the book's title, all quotes converted to curly quotes, paragraphs indented and flowed, em-dashes, italics, boldface, etc., etc., etc.Chapters / Table of Contents To create chapters, simply add "<chapter>" before the chapter name. <chapter>Chapter One -- The Beginning This will add "Chapter One -- The Beginning" to the main Table of Contents Menu, along with an entry on the Table of Contents page at the beginning of the book.Headers The header displays the book title at the top-right of each page, just like Sony Connect EBooks. Pielrf can also use the current chapter name, the book title and chapter name, or no header at all. You can even specify a header from the command line! Paragraphs By default, pielrf automatically detects paragraphs. If it guesses wrong, you can force it to use the correct method. Additional Features + Table of Contents Menu and Page via the <chapter> tag. + Top-of-Page headers + Curly (typographic) quotes. + Paragraph auto-flow. + Can make whole book Bold to increase contrast. + Understands HTML tags <i></i>, <b></b>, <center></center>, <sub></sub>, <sup></sup>, <p></p>, <h1></h1>-<h3></h3>. + Understands ALL HTML Ampersand tags - &, £, üat, etc. + Paragraphs can be delimited by tabs, spaces, vertical whitespace. + Font size / weight (bold) can be controlled from command line. + Ability to control almost everything else from the command line too! Installation Requires install of Python 2.5.The pielrf distribution includes -- and automatically installs -- required python modules Pylrs and ElementTree. Simply download and unzip, then go to the "pielrf-1.x" directory in the Terminal and type the following: python setup.py install Then to get a list of options...pielrf -h -Pie
or python pielrf -h Last edited by EatingPie; 10-09-2007 at 08:43 PM. Reason: Version 1.7 and Beyond - FAST TOC!! |
05-08-2007, 04:16 AM | #2 |
eBook Enthusiast
Posts: 85,544
Karma: 93383043
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
Sounds good, Pie.
I notice you say "Can make whole book Bold to increase contrast". Do you find that specifying "bold" actually makes any difference? I use "Book Designer" to create my books and, in that, although "Bold" shows up fine in BD itself, it has absolutely no visual effect whatsoever on the Reader! Does your tool support hyperlinks within a document? Those are very useful for things like footnotes, multiple-level TOCs in "anthologies", and so on. |
Advert | |
|
05-08-2007, 07:16 AM | #3 |
Blueberry!
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
|
If you specify the option
--fontweight=800 You do indeed get boldface on the Reader.EDIT: Version 1.6 adds a new flag to create a boldface book, so it's a bit easier --bold I also recommend increasing font size, since that seems to help a bit too.--fontsize=100 It doesn't support hyperlinks, unfortunately. The tool is mainly for quick-and-easy generation of lrfs. Just add the <chapter> tags, and you're off and running.-Pie Last edited by EatingPie; 05-10-2007 at 05:04 PM. |
05-08-2007, 11:47 AM | #4 | |
creator of calibre
Posts: 44,555
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
If you need support for links and bold I would suggest html2lrf. You can just add a little HTML markup to the txt source and be good to go.
Quote:
|
|
05-08-2007, 07:09 PM | #5 |
Blueberry!
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
|
Examples of Usage
The following posts give examples to the ease-of-use of pielrf.
First, Thomas More's Utopia. I moved the Gutenberg license to the end, and added <chapter> tags. All in all, less than 5 minutes of preparation! pielrf -i utopia.txt -o utopia.lrf -t Utopia -a "Thomas More" Note that the paragraphs are REALLY LONG in Utopia (and so are the sentences).-Pie Last edited by EatingPie; 05-15-2007 at 12:30 AM. Reason: Deleted Long Command Line Parameters Post in lieu of Examples |
Advert | |
|
05-10-2007, 04:17 PM | #6 |
Blueberry!
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
|
War of the Worlds
Another Gutenberg title, The War of the Worlds, this time the HTML version. All the headers where changed to <chapter> tags, and I had to remove the extraneous brief CSS definitions and html body tags. I think this one took about 10-15 minutes.
pielrf -i waroftheworlds.htm -o waroftheworlds.lrf -t "War of the Worlds" -a "H.G. Wells" -b html --headerstyle=titlechapter Note the "-b html" to force html <p> paragraphs.Also, the "--headerstyle=titlechapter" tag, which gives you a bit more "where am I?" info when you're reading. -Pie Last edited by EatingPie; 05-15-2007 at 12:37 AM. |
05-10-2007, 04:43 PM | #7 |
Blueberry!
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
|
Short Story Collection
Here is a collection of short stories from the Story Bytes web site (they provide me with an e-mail address and some disk space). This illustrates the use of the <chapter> and <toctext> tags, as well as minor <center>, <br> and <i> formatting tags.
My favorite stories are A Moment of Indecision and The Bolsheviks were Ruthless. It was generated with the following command: pielrf -i wwi.txt -o wwi.lrf -t "StoryBytes Collected Stories: World War I" -a "M. Stanley Bubien" --headerstyle=chapter Each header is the title of the current story you're reading.-Pie Last edited by EatingPie; 05-15-2007 at 12:38 AM. |
05-10-2007, 05:11 PM | #8 |
Blueberry!
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
|
New version pielrf 1.6.
See the first post to download. - Fixed DOS linebreak issue The "--bold" flag is simply a shortcut to the previously recommended "--fontweight=800" -- this sets all text to bold.- Added --bold command line switch to make whole book bold - Added <toctext> flag for Table of Content The new <toctext> places the given line of text at the current position in the table of contents page. It does not effect the Table of Contents Menu. <toctext>Book I <chapter>Chapter 1 Text for chapter 1... <chapter>Chapter 2 Dadada... <toctext> <toctext>Book II <chapter>Chapter 1 Book I <--Text Chapter 1 <--Button Chapter 2 <--Button Book II <--Text Chapter 1 <--Button -Pie Last edited by EatingPie; 05-10-2007 at 05:14 PM. |
05-15-2007, 12:54 AM | #9 |
Blueberry!
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
|
Pielrf 1.7 - Major Optimization Update
New version pielrf 1.7.
This is a major optimization update! See the first post to download. - Table of Content Menu Loads Instantly! No Waiting!! The Reader TOC Menu now loads instantly, and I mean... INSTANTLY! The fastest TOC previously was about 5 seconds, and now even my worse book (originally about 40 seconds!) loads right when you hit the TOC Menu (Button 5).- LRF Files are much smaller. As an added benefit, the LRFs are about half the size as previous versions produced. -Pie |
05-15-2007, 07:47 PM | #10 | |
Enthusiast
Posts: 31
Karma: 60
Join Date: Mar 2007
Device: Sony Reader
|
pielrf 1.7 nice stuff
Quote:
baselineskip=120 is beautiful.... It did cough up and error on one of my files. I guess there was a quote at either the very end of a line, or the very begining of one, and the index-1 (or +1) wasn't valid. I made this little change and all was well: Code:
--- pielrf 2007-05-15 00:36:01.000000000 -0230 +++ /usr/bin/pielrf 2007-05-15 17:11:38.000000000 -0230 @@ -632,7 +632,7 @@ def convert_curly_quotes(line): # just an apostrophe # index = line.find("'",i+1) - if index > -1 : + if (index > 0) and (index < (len(line) - 1)): if line[index-1].isalnum() and line[index+1].isspace() : do_open = True else : Thanks much, Lee |
|
05-15-2007, 10:58 PM | #11 |
Blueberry!
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
|
Thanks for the bug fix Lee. I'll add it and post it later tonight. Off to sushi right now.
-Pie |
05-16-2007, 02:08 PM | #12 | |
Enthusiast
Posts: 31
Karma: 60
Join Date: Mar 2007
Device: Sony Reader
|
Quote:
I was thinking about this at work today, and I don't think my fix was very good... You'ld probably want to check if the quote is at the beginning or end of the line and handle appropriately rather than ignoring it like I did. Code:
if index == 0: #what to do if it starts the line elif index == len(line)-1: #what to do if it ends the line elif index > 0: #the code you already have for when it's #floating around in the middle of the line Just thought I'ld quickly mention that before I forgot about it, now I go back to work. Cheers, Lee |
|
05-16-2007, 03:41 PM | #13 |
Blueberry!
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
|
Hi Lee.
Thanks for the comments. Actually, your fix was dead-on. Turns out the default case for the single-quotes will handle what you're talking about above. Even your questions about "boundary conditions" (end-of-line -- technically, end of paragraph -- and whatnot) would be handled correctly. The part that caused the crash is a check for the NEXT single-quote, not the one the algorithm is currently changing into curly-open/close. Why I do this involves typographic conventions for contractions ("tell 'im to go to away") vs. quotations ('go away') -- they're different. The algorithm is trying to decide the "right thing" by looking ahead. Avoiding the crash is what matters at that point, and then the default case will be correct (if next quote's at end-of-line, the current one is an open-quote). I just have to post your fix as promised... and I don't have "too much sushi!" as an excuse this morning. -Pie |
05-16-2007, 04:43 PM | #14 |
Blueberry!
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
|
Pielrf 1.7.1
Pielrf 1.7.1
Maintenance fix for crash with a single quote residing at the end-of-paragraph. Thanks to Lee. -Pie |
05-17-2007, 03:27 AM | #15 |
eBook Enthusiast
Posts: 85,544
Karma: 93383043
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
Pie,
Would you like to write a short note about your tool in the "Book Creation Tutorials" thread in the "Book Uploads" forum section? That way it will be easy for people to find. I'm sure it would greatly interest many people. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
convert straight quotes to curly quotes | alansplace | Calibre | 3 | 09-25-2010 04:51 PM |
curly quotes | DaleDe | Sigil | 6 | 06-26-2010 11:33 PM |
A tool for converting to curly quotes | Snowman | Workshop | 7 | 02-08-2009 01:22 PM |
Austen, Jane: Emma HTML (PDA and iPhone-friendly) with curly quotes etc | andym | Other Books | 6 | 09-11-2007 03:00 PM |
PRS-500 pielrf beta - Text to LRF with Easy TOC, autoflow, etc. | EatingPie | Sony Reader Dev Corner | 9 | 05-11-2007 11:51 PM |