04-28-2007, 03:38 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 beta - Text to LRF with Easy TOC, autoflow, etc.
Out of beta, now officially released on the Reader Content forum. All new versions will be posted there, as well as questions answered and whatnot.
Announcing pielrf, a Python command line tool to convert text to Reader lrf format, utilizing Fallstaff's pylrs. I've only tested this using Python 2.5 on Mac OS X 10.4.9 (Intel). The main features are easy Table of Content creation, curly quotes, top-of-page header and paragraph autoflow. pielrf -i flatland.txt -o flatland.lrf -t "Flatland" -a "Edwin A. Abbott" Please feel free to give this a run. I've been using it primarily for Guteberg and OCR books. I've included a few short examples with the executable.Chapters. To create chapters, simply add "<chapter>" before the chapter name. <chapter>Chapter One This will add "Chapter One" to the main Table of Contents, along with a button on the Table of Contents page at the beginning of the book.Paragraphs There's several ways to delimit paragraphs. Gutenberg uses vertical whitespace (CRs), while other files use tabs on the first line of the paragraph, while still others use spaces. By default, the program automatically the actual method used. You can also force it using the "-b" flag: "-b tab" or "-b cr" for example. Features. + Curly (typographic) quotes. + Top-of-page header like those in books from the Sony Connect Store. + Paragraph auto-flow. + Table of Contents and Chapterization if you use the <chapter> tag. + Understands HTML tags <i></i>, <b></b>, <center></center>, <sub></sub>, <sup></sup>, <p></p>. + 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! Requirements Requires install of Python 2.5 from the Developer Tools / Tiger Install CD. Also requires pylrs-1.0.0, along with ElementTree 1.2.6. -Pie Versions provided here, see subsequent posts for discussion of changes. Last edited by EatingPie; 05-08-2007 at 07:59 AM. |
04-28-2007, 08:33 PM | #2 |
Enthusiast
Posts: 45
Karma: 16
Join Date: Mar 2004
Device: Palm Tungsten|TX, Sony Reader^H^H^H^H, iLiad, iPhone
|
Rats! having trouble with python
This looks like a great tool! I've run into a little trouble, though, and while I google around looking for an answer I figured I'd run it by you, too (I'm no Python expert).
When I run Code:
pielrf -h Code:
Traceback (most recent call last): File "/usr/local/bin/pielrf", line 43, in ? from pylrs.pylrs import * ImportError: No module named pylrs.pylrs It seems to be having trouble finding the pylrs library or module, right? Any suggestions? |
Advert | |
|
04-28-2007, 09:44 PM | #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
|
EDIT: Version 1.2 solves this issue, so no need for links/edits as suggested below.
This is probably not a good time to admit that I knew absolutely NO Python whatsoever a week ago (that's no exaggeration, I'd never even seen the syntax). I suspect that python.org's version went into the "wrong" place. Pielrf depends on python being installed in "/usr/bin/python." If you type "/usr/bin/python -V" that will tell you if 2.5.1 installed in the right place. I'm betting that's still Python 2.3. Next just type "python -V" to see if your default version of Python is 2.5. If it is, you can run pielrf by forcing it to use the right python: python pielrf -h (millions of options follow) At this point you have a couple of options. (1) Always run it by starting with python. python pielrf -i infile -o outfile [etc.] sudo mv /usr/bin/python /usr/bin/python2.3 sudo ln -s /path/to/python2.5 /usr/bin/python Finally, to see where pylrs actuall ended up, you can use the following (slow) command: sudo find / -name pylrs\* -Pie
Last edited by EatingPie; 05-06-2007 at 02:42 AM. |
04-29-2007, 12:40 AM | #4 |
Enthusiast
Posts: 45
Karma: 16
Join Date: Mar 2004
Device: Palm Tungsten|TX, Sony Reader^H^H^H^H, iLiad, iPhone
|
Quite Right -- that fixed it.
You know, I've got to put a post-it on my monitor reminding me to use "find" instead of "locate", too. Thanks! |
04-29-2007, 02:30 AM | #5 |
Enthusiast
Posts: 45
Karma: 16
Join Date: Mar 2004
Device: Palm Tungsten|TX, Sony Reader^H^H^H^H, iLiad, iPhone
|
Thanks for the help -- I'm using pielrf at manybooks.net now (look for "Sony (beta)" at the bottom of the download menu), and it seems to be working alright... but I no longer have a Reader to test with!
If anyone would care to try one or two I'd be very grateful. The "headerfontsize" switch is very good news -- will that work with <h1> type header tags? |
Advert | |
|
04-29-2007, 01:44 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
|
Pielrf Version 1.1
Quote:
New version, pielrf-1.1 (see first post in thread to download). +Added support for <h1>|<h2>|<h3> tags. These tags provide only one level of header size (same as chapter header). These are uncentered, but you can use them with the <center> tag. See "h1-test.txt" in the examples directory for usage. + Added "--without-toc" switch This switch keeps pielrf from generating the Table of Conents Menu for the Reader. The separate Table of Contents Page is still generated. EDIT: Issue discussed below is FIXED as of version 1.7, and now TOC Menus load INSTANTLY! I still left in the "--without-toc" flag. I added this flag because I had extremely slow performance with one book I generated using about ~30 TOC entries. Don't know why this happened, because I have several other books generated with at least the same amount of TOC entries, and they work fine. (I have a suspicion as to the cause, and it's not related to the lrf itself, but I need to explore this further.) Bugs There is an outstanding bug with Unicode in the input file. This causes pielrf to crash with a message like the following: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128) -Pie Last edited by EatingPie; 05-15-2007 at 11:46 AM. |
|
04-29-2007, 02:17 PM | #7 |
Resident Curmudgeon
Posts: 76,368
Karma: 136006198
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Very nice job!
|
05-05-2007, 04:59 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
|
Pielrf Version 1.2 -- Header Support!
New version, pielrf-1.2 -- "feature-complete" at this point, and my next release should be "official." I will, of course, still take feature requests. As always, see first post in thread to download.
Added Header Support ala the title that appears top/right in Sony Connect Books Book title is automatically taken as top-of-page header, but you can use Chapter Names or Book Title plus Chapter Name, or no header if you so choose. You can even specify the text from the command line via the "--headertext" switch. The List + ADDED HEADER AT TOP OF EACH PAGE + Added "--headerstyle" to set how to determine the header.
+ Added "--headertext" to force header to specified text When using this option, "--headerstyle" setting is ignored. These correctly identify options related to <chapter> Tagged font controls. These were originally called "headers", so the problem is pretty obvious there. + Added "--headerheight" to set header height + Updated page and margin defaults to fit a header + Now uses default python interpreter, which is more likel to be the "right one." Still not handling unicode in input files. -Pie |
05-11-2007, 06:42 AM | #9 | |
Junior Member
Posts: 9
Karma: 10
Join Date: Mar 2007
Device: Sony reader
|
Quote:
for my webbased conversion engine I use pylrs, too. Maybe you should try instead open an input file like f = open(infile, 'rb') with import codecs f = codecs.open(infile, 'wU', 'utf-8') |
|
05-11-2007, 11:51 PM | #10 |
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 utrost, I'll give that a shot!
I dabbled very briefly in the unicode string conversion, but it made everything else in my program totally fail. I was so busy with preparing a release version of the program, I just bailed. With your suggestion, I'll see if I can make some progress. -Pie |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
An Easy Way to Create Kindle-ready eBooks with working TOC. | Dr. Wily | Amazon Kindle | 3 | 01-27-2010 06:17 PM |
Making a TOC for LRFs? Issues with Calibre + LRF TOC editor not working | Magitek | LRF | 0 | 05-06-2009 02:25 PM |
What does formatting exactly do to lrf? Easy way to do Collection management? | lovemov | Sony Reader | 4 | 03-30-2009 03:56 PM |
Pielrf - Text to LRF with Easy TOC, Headers, Curly-Quotes, etc. (Mac!) | EatingPie | LRF | 104 | 01-12-2009 01:35 PM |
Quick/easy LIT to LRF converter? | OUTATIME | Sony Reader Dev Corner | 10 | 02-29-2008 10:44 AM |