View Full Version : Pielrf - Text to LRF with Easy TOC, Headers, Curly-Quotes, etc. (Mac!)


EatingPie
05-07-2007, 11:22 PM
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! (http://www.mobileread.com/forums/showthread.php?t=11696)

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 - &amp;, &pound, &uumlat, 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.

http://www.python.org/download

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
or
python pielrf -h

-Pie

HarryT
05-08-2007, 03:16 AM
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.

EatingPie
05-08-2007, 06:16 AM
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

kovidgoyal
05-08-2007, 10:47 AM
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.

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.

EatingPie
05-08-2007, 06:09 PM
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

EatingPie
05-10-2007, 03:17 PM
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

EatingPie
05-10-2007, 03:43 PM
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

EatingPie
05-10-2007, 04:11 PM
New version pielrf 1.6.

See the first post to download.

- Fixed DOS linebreak issue
- Added --bold command line switch to make whole book bold
- Added <toctext> flag for Table of Content


The "--bold" flag is simply a shortcut to the previously recommended "--fontweight=800" -- this sets all text to bold.

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


Creates a TOC Page...

Book I <--Text
Chapter 1 <--Button
Chapter 2 <--Button

Book II <--Text
Chapter 1 <--Button


The <chapter> tags create buttons, the <toctext> tags create plain text. A <toctext> alone on a line creates a vertical line break (blank line) in the Table of Contents -- as you can see in the example above, the break between "Chapter 2" and "Book II."

-Pie

EatingPie
05-14-2007, 11:54 PM
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!! :)
- LRF Files are much smaller.


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).

As an added benefit, the LRFs are about half the size as previous versions produced.

-Pie

yargoflick
05-15-2007, 06:47 PM
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!! :)
- LRF Files are much smaller.


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).

As an added benefit, the LRFs are about half the size as previous versions produced.

-Pie

Oh, dear. I like it, I do.

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:

--- 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 :


I'm not really sure where to post bugs for this prog?

Thanks much,
Lee

EatingPie
05-15-2007, 09:58 PM
Thanks for the bug fix Lee. I'll add it and post it later tonight. Off to sushi right now. :)

-Pie

yargoflick
05-16-2007, 01:08 PM
Thanks for the bug fix Lee. I'll add it and post it later tonight. Off to sushi right now. :)

-Pie

Hello,

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.


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


or something like that.
Just thought I'ld quickly mention that before I forgot about it, now I go back to work.

Cheers,
Lee

EatingPie
05-16-2007, 02:41 PM
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

EatingPie
05-16-2007, 03:43 PM
Pielrf 1.7.1

Maintenance fix for crash with a single quote residing at the end-of-paragraph.

Thanks to Lee.

-Pie

HarryT
05-17-2007, 02:27 AM
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.

EatingPie
05-17-2007, 01:46 PM
Thanks for the pointer Harry! I'll whip something up.

-Pie

EatingPie
05-19-2007, 11:34 PM
New version pielrf 2.0.

See the first post to download.

- Use new pielrf python library.
- Support for Unicode (thanks to Lee Bigelow).
- Added HTML ampersand support in Title.
- Added 'textchapter' for headerstyle, which uses specified text on cmdline plus the chapter name


In terms of code, this is a huge revision. I created new book class, and broke most functions out into a new library. This actually gave me a slight optimization in the final LRF.

I had to make a slight change to pylrs, which will be installed automatically when you run "python setup.py install" (or will give you instructions on Windows).

Added an "--headerstyle=textchapter" option. If you provided the header text from the command line (--headertext="Some Text"), this new option will combine that text with the chapter name -- similar to the "titlechapter" option.

Thanks to Lee Bigelow
Unicode is now supported and automatically detected. This contribution is great, and handles books with different unicode types! Check Jane Eyre and Ten Days that Shook the World from Gutenberg.

http://www.gutenberg.org/files/16235/16235-8.zip

and

http://www.gutenberg.org/etext/3076

-Pie

kovidgoyal
05-20-2007, 09:22 PM
Pie, you may find this useful
http://docs.python.org/lib/module-htmlentitydefs.html

EatingPie
05-21-2007, 11:18 AM
Thanks Kovid! I'll try some code today and see if it might work for me.

-Pie

EatingPie
05-21-2007, 12:50 PM
New version pielrf 2.0.1.

See the first post to download.

- Minor bug fix in unicode encoding choice.
- Use regex to detect HTML tags.


That's about it. :-)

-Pie

EatingPie
05-26-2007, 02:48 PM
New version pielrf 2.0.2.

See the first post to download.

This is for users of ConvertLit.

I now inlude the "--strip-html" option to strip all unknown HTML tags from the input text file (known tags, like <i></i> are preserved).

I also provide a separate utility striphtml to produce a pre-stripped output file. ConvertLit tends to generate fairly complex HTML, so taking the unknown HTML out ahead of time makes it a lot easier to add "<chapter>" tags in the right place.

- Added "--strip-html" to remove unknown HTML.
- striphtml utility pre-strips unknown HTML for easier editing.
- Fixed explanation of "--baselineskip" option.


-Pie

kovidgoyal
05-26-2007, 03:44 PM
Umm while I applaud your efforts, you can just pass the output html files through html2lrf and it will automatically detect metadata, chapters and create the LRF.

EatingPie
05-27-2007, 01:44 AM
Oh, no doubt html2lrf is appropriate for use with ConvertLit. However, I often add features to pielrf that I personally find a need for -- this one came after I downlaoded a book from Fictionwise, and I ran ConvertLit on it. If the feature is uselful for me, I figure other users might want it too.

html2lrf and libprs500, are very well-represented on the forum, so I'm betting most people here know about them -- ConvertLit users in particular.

But variety is the spice of life, and there may be some users out there who would benefit from this feature in pielrf -- I sure did! -- so here it is. :)

-Pie

Alexander Turcic
05-28-2007, 02:44 PM
I agree with Pie... it's always nice to have alternatives, especially when both are being actively developed.

kovidgoyal
05-28-2007, 03:44 PM
Yeah but only if an alternative provides some different functionality. Otherwise it's just duplicated effort. Effort that would be more useful if directed into a single project.

EatingPie
05-28-2007, 11:05 PM
I do not entirely agree with this sentiment, however I think further deliberation along these lines would be better served in the Developers' Forum, as it treads in to philosophies of development. My primary intent here is to announce and discuss features of pielrf as well as field potential feature requests for future versions.

-Pie

EatingPie
05-31-2007, 06:40 PM
New version pielrf 2.0.3.

See the first post to download.

Support for indented text.

- Added indented text via the HTML <blockquote></blockquote> tags.
- Added "--quoteoffset" flag to control indent (default 40).


Note that the "--quoteoffset" is added to the side margin to create the indent. If you use "--quoteoffset=0" there will be no additional indentation (it will match non-indented text).

-Pie

Lime2K
06-07-2007, 12:57 AM
Hey EatingPie,

The multiple "&lt;"s issue is still broken in 2.0.3. Here's the snippet from my textfile that is the problem


<tabchar>&lt;&lt;THAT MAN MUST DIE.&gt;&gt;
<tabchar>&lt;NO NO STOP STOP STOP!!&gt; she screamed.
<tabchar>&lt;&lt;LEAVE ME!!&gt;&gt;

(replace <tabchar> with tabs, as they don't show up in HTML)

and here's the command used to compile it:

pielrf -i /Users/lime2k/Documents/textfile.txt -o textfile.lrf -t "BookNameChanged" -a "AuthorNameChanged" --headertext "The Book Name" -b tab --without-toc

Also, I'd like to thank you for giving me a way to left-indent lines (--quoteoffset=0 + <blockquote>) even though I haven't had a chance to play with it yet ^_^.

EatingPie
06-07-2007, 02:43 PM
Ah... Oops! :) Thanks for the sample, that'll help!

Got a huge update coming, so I'll make sure this is part of it.

-Pie

JSWolf
06-08-2007, 07:53 PM
By the way, there is a problem with the pielrf 2.0.3 ZIP file under Windows. When using Windows Explorer with the ZIP file, it will not extract. I had to use my 4NT prompt and unzip to get it to extract. So for those command prompt challenged or no other utility to handle ZIP files, they won't be able to extract it.

Next issue.. where do I get pylrs 1.0.1?

EatingPie
06-09-2007, 10:12 PM
I'll give the zip file a run in Windows... I tested the 2.0 version in Windows but probably didn't do 2.0.1.

But just for a heads-up, I should have the next version out on Sunday. It fixes the above "<<" issue, and adds a few other features.

The pylrs-1.0.1 is part of the installation (it's in the "packages" directory), and is automatically installed when your run the installer in the pielrf directory itself. I did test it in Windows! :)

python setup.py install

This did require command line, but I don't know any other way to do it.

-Pie

JSWolf
06-09-2007, 10:16 PM
I'll give the zip file a run in Windows... I tested the 2.0 version in Windows but probably didn't do 2.0.1.

But just for a heads-up, I should have the next version out on Sunday. It fixes the above "<<" issue, and adds a few other features.

The pylrs-1.0.1 is part of the installation (it's in the "packages" directory), and is automatically installed when your run the installer in the pielrf directory itself. I did test it in Windows! :)

python setup.py install

This did require command line, but I don't know any other way to do it.

-Pie
I don't have any issues with using the command line. What I would like is to know the commands to convert a CLIT output HTML from LIT format. Either it's not working or I'm doing something wrong. I have no idea.

EatingPie
06-10-2007, 12:22 PM
I don't have any issues with using the command line. What I would like is to know the commands to convert a CLIT output HTML from LIT format. Either it's not working or I'm doing something wrong. I have no idea.
Okay.

There's two approaches.

First you can just trust that pielrf does the right thing, and use the "--strip-html" command line switch. This will run pielrf as usual, and strip out any of the html it doesn't know.

The second is to use the striphtml utility before running pielrf. This will do the exact same thing as "--strip-html" but output another text file for you to look at / edit.

I prefer pre-stripping with striphtml and then editing that file and feeding it to pielrf. CLIT creates pretty complex HTML, and if you want to add the "<chapter>" tags, pre-stripping makes that a lot easier. It also allows you to clean up any HTML that striphtml didn't get rid of.

-Pie

HarryT
06-10-2007, 12:25 PM
Is there a comma in any of the file names in the ZIP file? If there is, that "breaks" the built-in Windows unzipper.

EatingPie
06-10-2007, 01:10 PM
No commas in any file names... and this is one of those evil "it works for me" posts. :(

I downloaded the pielrf-2.0.3.zip file at the top of this thread.

Using WinXP, I Right-Clicked the "pielrf-2.0.3.zip" file and selected "Extract All..." This gives me a "Welcome to the Compressed (zipped) Folders Extraction Wizard." Clicking "Next>" a couple of times unzips me a "pielrf-2.0.3" folder.

If I go into the "pielrf-2.0.3" folder, there is a "pielrf-2.0.3" folder in there (no, that wasn't a typo! :) ). Opening THAT "pielrf-2.0.3" folder shows the correct contents, with the README, pielrf and striphtml commands, plus the setup.py, plus the "examples" and "packages" subdirectories, et cetera.

Could it be the dual "pielrf-2.0.3" folders were the problem?

EDIT: Just realized that I used the Mac to download, transferred to parallels and unzipped there. Maybe it's IE that's the problem? I'm off for a bit, but I'll try that later.

-Pie

JSWolf
06-10-2007, 03:25 PM
Maybe it is IE. But this is the only ZIP file I've had an issue using Windows Explorer. The other issue I have is the file extensions. All Python code under Windows needs to have a .py extension. You run the code by typing filename.py and then it runs it under Python.

If you'd like, I can send you some HTML output from CLIT and see how you get on converting it if you'd like.

EatingPie
06-10-2007, 06:49 PM
Maybe it is IE. But this is the only ZIP file I've had an issue using Windows Explorer. The other issue I have is the file extensions. All Python code under Windows needs to have a .py extension. You run the code by typing filename.py and then it runs it under Python.

If you'd like, I can send you some HTML output from CLIT and see how you get on converting it if you'd like.

Yeah go ahead and PM me the file(s). I haven't thoroughly tested the CLIT stiff, and I know it generates a wide variety of HTML.

In terms of the .py extension, your other choice is the precede the command with "python":

python pielrf -i infile.txt -o outfile.lrf -t "Book" ...

I realize it's extra typing, and not as "clean" but it gets the job done.

I still have to give it a go in IE, and I'll let you know. I use the Mac's built-in zip compression, but I have other programs to create zips, so I'll probably just use one of them from now on.

EDIT: IE Worked okay. I'll use a different zip utility for the new version when I post it.

-Pie

EatingPie
06-11-2007, 10:03 PM
Had some optimization issues with the new version, so I'm a bit delayed.

Definitely should be fixed in the next few days.

-Pie

JSWolf
06-11-2007, 11:16 PM
Hopefully with a perfect CLIT HTML conversion as well.

Jon

EatingPie
06-12-2007, 12:37 PM
Hopefully with a perfect CLIT HTML conversion as well.

Jon
:)

To be honest, depending on the complexity of the HTML you sent me (which I did receive), that may have to wait until the next version. I have some promised features that are overdue, and I want to get them out as soon as get the LRF optimized a bit more (it needs to at least match 2.0.3 in terms of load speed).

-Pie

JSWolf
06-12-2007, 09:53 PM
:)

To be honest, depending on the complexity of the HTML you sent me (which I did receive), that may have to wait until the next version. I have some promised features that are overdue, and I want to get them out as soon as get the LRF optimized a bit more (it needs to at least match 2.0.3 in terms of load speed).

-Pie
Not a problem. But can I ask that the new version be tested on a Windows environment (XP Please) so you can sort out the issues with the install and filename extensions? Thanks!

Jon

EatingPie
06-13-2007, 03:41 PM
Not a problem. But can I ask that the new version be tested on a Windows environment (XP Please) so you can sort out the issues with the install and filename extensions? Thanks!

Jon
Indeed, I certainly plan to do so. I have already tested one zip utility and it seemed to work fine.

I am actually not sure what I want to do about the file extension. I prefer to keep it off, since it executes as a script correctly under Mac OS X and Linux (or any other UNIX supporting python). Windows requires you to either add the extension -- as you're suggesting -- or type "python" first.

While adding two letters isn't a big deal, the ".py" extension suggests a "library" as opposed to an executable command. Leaving it off means Windows users have to type "python" first, while putting it on means UNIX users may interpret it as a library function rather than an executable.

I'd love to hear what others think. This kind of issue is exactly why this thread exists! :)

-Pie

kovidgoyal
06-13-2007, 04:08 PM
Pie have you considered making a windows executable with py2exe?

JSWolf
06-13-2007, 11:17 PM
Well, the way python installs and sets itself up, you have to type the path to python in a Windows command prompt to callthe python command as it's not made part of the path. So for people who do not know the command line well enough, this will be an issue and adding the extention will fix this for them. I say to just do it let the linux/MAC people deal.

EatingPie
06-15-2007, 02:07 PM
Pie have you considered making a windows executable with py2exe?

Thanks kovid, I'll definitely look into this. Because...

Well, the way python installs and sets itself up, you have to type the path to python in a Windows command prompt to callthe python command as it's not made part of the path. So for people who do not know the command line well enough, this will be an issue and adding the extention will fix this for them. I say to just do it let the linux/MAC people deal.

Turns out renaming with .py won't work at all at this point. This is because I named the library "pielrf"... and when you run "pielrf.py" and it tells python to look for the pielrf library, python looks in the current directory first, finding "pielrf.py" ... the executable you just ran. All sorts of mayhem ensues.

You're absolutely right about this being an important "feature," as it does make the Windows execute with python without having to know any path rigamarole. I'll figure out a solution, but it's going to have to wait until my next release (renaming the library, for example, is more than I want to do this time around).

At this point, I'm going to post a test download so I can check out the .zip file, and after I get that checked out, I'll post the current, and long-delayed, update.

-Pie

PS I can see why you want Linux/Mac people to deal... Poor windows users have to deal all the time, and they get really tired of it... or so I hear. Kidding.... Kidding... :)

kovidgoyal
06-15-2007, 03:37 PM
You know, maybe I could give you commit access to a subdirectory of the libprs500 SVN server and you could switch development of pielrf to that. That way you'd get Windows and OSX installers for free as part of the libprs500 umbrella of utilities.

simmepimme
06-15-2007, 04:34 PM
I really like the look of the output for pielrf. A few questions:

- Is it possible to add some extra vertical space before each paragraph; I like some air between paragraphs?
- I can't get the bold functionality to work, and neither avoiding creating a TOC. pielrf logs that font weight 800 is used and that no TOC will be created, but neither of those are true...
- I've created an OSX application which wraps pielrf functionality in a GUI, for my personal use. It includes the pielrf stuff, but you have to install python >= 2.5 in /usr/local/bin yourself. Would it be OK for me to put it up for downloading?

EatingPie
06-15-2007, 06:31 PM
You know, maybe I could give you commit access to a subdirectory of the libprs500 SVN server and you could switch development of pielrf to that. That way you'd get Windows and OSX installers for free as part of the libprs500 umbrella of utilities.

Thanks for the very kind offer Kovid! At this point, though, I'm going to keep it as a separate download. If I move toward needing additional features of libprs500 (like your extended image support), I'll consider this further.

-Pie

EatingPie
06-15-2007, 06:33 PM
- I've created an OSX application which wraps pielrf functionality in a GUI, for my personal use. It includes the pielrf stuff, but you have to install python >= 2.5 in /usr/local/bin yourself. Would it be OK for me to put it up for downloading?

Great! Go ahead and throw it up and see what people think. It'd be wonderful to make this easier for Mac users, since there's no BookDesigner on "our side" of the fence.

I really like the look of the output for pielrf. A few questions:

- Is it possible to add some extra vertical space before each paragraph; I like some air between paragraphs?

Not at this point. I'm pretty sure it's offered as an option, but I never implemented it. I'll double-check and add it after I get the next revision out.

- I can't get the bold functionality to work, and neither avoiding creating a TOC. pielrf logs that font weight 800 is used and that no TOC will be created, but neither of those are true...


Unfortunately, bold is not very bold. I loaded a set of mixed text onto the Reader, and there was very little discernable difference. If you do bold and increase the font size, that makes it more noticable.

On the "--without-toc" option, it's a little misleading as named. This suppresses the generation of the TOC Menu, which is item #5 in the Reader's Navigation menu. However, it STILL generates a TOC page. I do not (yet) offer an option to suppress the TOC page.

Originally, I mishandled TextBlocks, and this would cause the Reader to slow to a crawl when loading some books that had a TOC Menu. So I added "--without-toc" for these slow-loading books. I've since fixed the TextBlock issue, but I left the "--without-toc" in.

-Pie

simmepimme
06-16-2007, 02:05 AM
Thanks for the explanation!

I'm attaching the OSX application; it's also available for downloading at http://www.ozymandias.se/Pielrf.dmg.

Note: New version attached using pielrf 2.1.2, and also adds pielrf installation procedure from within GUI (had forgot that before). Also, you have to run this installation procedure again since a new pielrf lib is used.

EatingPie
06-16-2007, 02:18 PM
Here's a test post for pielrf 2.1 to see if I have solved the Windows problems with the ZIP. I compressed this one using a brand new zip utility.

EDIT: Works perfectly for me, booted into Windows XP Pro. I also tried the 2.0.3 post, and it worked fine too.

EDIT: File Removed, See first post of this thread for correct Version 2.1, created with same zip program.

-Pie

EatingPie
06-16-2007, 10:28 PM
New version pielrf 2.1.

See the first post to download.

Lots and lots of changes, both new features, bug fixes, and under-the-hood cleanup.

NEW FEATURES
- UNIX style "preferences" file, ".pielrfrc" and a "--write-rc" function.
- <justified></justified> tags simply remove the indent on the first line of a paragraph in any paragraphs between these tags.
- <verse></verse> tags for proper indentation of poetry.
- "--verseparindent" a NEGATIVE number which pulls the first line of the verse further to toward the left margin. The Margin of subsequent lines in the same verse are shared with "--quoteoffset"
- Added "--html-quotes" and "--trust-html" as aliases to the "--use-rdquotes" switch. They make more sense.


BUG FIXES
- Fixed "<<" (double less-than). Pielrf now outputs the same number less-than signs it encounters! (I even tested it this time, so it's really fixed!)
- Formatting tags "<center>" and "<h1>,<h2>,etc." no longer create vertical whitespace when encountered... unless they are on paragraph -- this allows for more "fine grained" control of formatting.
- Bold, Italic, Subscript and Superscript can all be combined (well, not Subscript/Superscript).
- Multiple <blockquote> levels are now supported, to a maximum of 3 levels. Pielrf will not indent further than 3 <blockquote> levels -- if it encounters fruther <blockquotes>, those remain indented at level 3.
- Both "--html-quotes" (aka "--use-rdquotes") and "--preserve-spaces" now apply correctly.


Preferences (.pielrfrc) File

My original intent for providing full control over command line options came because I realized that people have a wide variety of tastes in the "look and feel" of their e-books. The problem is, if you don't like the default settings, that can add up to a lot of typing for every book you convert. The ".pielrfrc" file stores all formatting options so you don't have to re-type them every time, and command line options will still override the ".pielrfrc" options when you need to!

Note that non-formatting related command line options like "--title", "--author", "--headerstyle", etc. are not stored in the .pielrfrc file, since they change for every book.

The .pielrfrc is NOT created automatically. You can create one yourself, or you can have pielrf write out the current options with the "--writerc" command line switch.

pielrf -t "Harry Potter" -a "Rowling, J.K." -i hp.txt -o hp.lrf --fontsize=200 --bold --parindent=30 --baselineskip=150 --write-rc

This creates (or overwrites) the ".pielrfrc" file in your home directory. Either "/Users/<username>/.pielrfrc" on Mac OS X / Linux / UNIX or "c:\Documents and Settings\<username>\.pielrfrc" on Windows.

Thanks to Lee Bigelow for providing the code for this feature

FORMATTING ADDITIONS

The new tags "<justified></justified>" and "<verse></verse>" allow you to mix paragraph styles within the text.

Standard text has every paragraph's first line indented by the amount indicated in "parindent" to delimit a tab (you know, every paragraph in a book).

<justified></justified> tag makes the whole paragraph left justify, meaning it does not have the first-line indentation.

<verse></verse> makes each paragraph reverse-indent. The first line is justified (on the left margin), and subsequent lines are indented. This allows you to include poetry in your book.

The defaults for "--verseparindent" matches exactly with the default margins and indent used by pielrf. If you use the <verse></verse> tags AND change your margins, you probably need to adjust the "--verseparindent" and "--quoteoffset" options. Beside the default, using "--quoteoffset=50" and "--verseparindent=-225" are good alternatives.


FORMATTING CHANGES

(1) The main change is that the formatting tags "<center>" and "<h1>,<h2>,etc." used to generate a new paragaraph when the open/close tags were encountered. This is no longer the case -- unless the tags form their own paragraph (see below). For example, you can now have standard paragraphs followed by centered text with no interveneing vertical whitespace (crs).

Here's two examples to illustrate behaviour of the center tag.

<tabchar>And this time he'd make sure they didn't fail. He had a plan.
<center>
* * *
</center>
<tabchar>The repaired alarm clock rang at six o'clock the next morning.
Generates
And this time he'd make sure they didn't fail. He had a plan.
* * *
The repaired alarm clock rang at six o'clock the next morning.
And this...
<tabchar>And this time he'd make sure they didn't fail. He had a plan.
<tabchar><center>
<tabchar>* * *
<tabchar></center>
<tabchar>The repaired alarm clock rang at six o'clock the next morning.
Generates
And this time he'd make sure they didn't fail. He had a plan.

* * *

The repaired alarm clock rang at six o'clock the next morning.

In these examples, <tabchar> is the actual tab character, and is the paragraph telimiter (-b tab).

(2) The "<blockquote>", however, still generates a single vertical whitespace. Though if you have mulitple <blockquotes> in a row, you get only 1 vertical whitespace.

-Pie

JSWolf
06-17-2007, 07:55 PM
When you tested it in Windows, did you test the install and see that it actually works without having to call Python? If you have to call Python in Windows, then you might as well give it up for lost for most novices as that will lose then totally.

Lime2K
06-17-2007, 08:36 PM
if they're using the command line anyway, it's not hard to add ONE WORD to the command you're typing. Please quit whining about trivial things, and let Pie focus on adding features that are useful.

Thx.

JSWolf
06-17-2007, 08:45 PM
if they're using the command line anyway, it's not hard to add ONE WORD to the command you're typing. Please quit whining about trivial things, and let Pie focus on adding features that are useful.

Thx.
For people not used to a command line, they'd have to find the path to where Python lives and put in the full path in the command line as well as the command. This will cause a lot of frustration. If the Python programs had the .py extensions on them it would be a lot easier to just type pielrf.py and then whatever option you wanted. The tools need to be made easy to use or they won't get used. This is the way it is. It's not whining. People who grew up in a GUI world and did not learn the command line need to have the command line programs made as easy to use as possible.

EatingPie
06-18-2007, 02:29 AM
When you tested it in Windows, did you test the install and see that it actually works without having to call Python? If you have to call Python in Windows, then you might as well give it up for lost for most novices as that will lose then totally.

Indeed, I don't have python in my Windows path, so I certainly have seen the benefit of this feature.

As I mentioned in a previous post, I couldn't get this to work in time for the 2.1 release, but will do it in an upcoming version. I'll either have to rename the pielrf library, or use py2exe as kovidgoyal suggested... both of which would have held pielrf 2.1 up, and it was already overdue.

Rest assured, though, it's on my list of features to implement. :)

-Pie

Lime2K
06-20-2007, 03:02 AM
I have a request for a feature. Is there any way to implement a <h0> tag, to force text that pielrf normally makes a header (like the first bit of a section, up to the first paragraph) to display as normal paragraphs? I'm trying to do a bit that looks like this:

<center> text </center>
<center> more text </center>
<center><h1> REALLY BIG TITLE TEXT </h1></center>
<center><h2> Medium Size Author Text </h2></center>
<center> still more text </center>
<center> backup backup text </center>

and only have the two lines in the middle show up bigger.
Any suggestions?
P.S. Thanks for fixing the << issue, I LOL'd at your comment in the readme (especially since I knew it was directed ar me ^_^)

JSWolf
06-20-2007, 05:24 AM
It would be a nice idea to be able to specify text in the font and font size we want. I would love to be able to have embedded fonts.

EatingPie
06-20-2007, 01:55 PM
I have a request for a feature. Is there any way to implement a <h0> tag, to force text that pielrf normally makes a header (like the first bit of a section, up to the first paragraph) to display as normal paragraphs? I'm trying to do a bit that looks like this:

<center> text </center>
<center> more text </center>
<center><h1> REALLY BIG TITLE TEXT </h1></center>
<center><h2> Medium Size Author Text </h2></center>
<center> still more text </center>
<center> backup backup text </center>

and only have the two lines in the middle show up bigger.
Any suggestions?
P.S. Thanks for fixing the << issue, I LOL'd at your comment in the readme (especially since I knew it was directed ar me ^_^)

If I interpret what you're asking correctly, there's a workaround. Specify "--chapterfontsize=95" and "--chapterfontweight=400" to have it match normal text. THEN you can add an <h1> tag to enlarge the font. Sort of a backwards way of doing what you're asking! :)

It would be a nice idea to be able to specify text in the font and font size we want. I would love to be able to have embedded fonts.

I'll have to look into the embedded fonts, along with the <h0> idea. Right now, I only have limited support of font sizes -- basically two sizes, normal and header. I don't currently have plans to move beyond this, but... we'll see. :)

-Pie

Lime2K
06-20-2007, 03:44 PM
If I interpret what you're asking correctly, there's a workaround. Specify "--chapterfontsize=95" and "--chapterfontweight=400" to have it match normal text. THEN you can add an <h1> tag to enlarge the font. Sort of a backwards way of doing what you're asking! :)


Sweet! I'll play around with this when I get home from work tonight!

EDIT: I tried compiling the file as you said, but the H1 and H2 tags are not affecting the text at all. I also tried it with a tab at the beginning of each line in the header, and no dice. Everything is all small (which _does_ look better than everything being frickin' huge)

EatingPie
06-21-2007, 09:41 PM
If you'd like, I can send you some HTML output from CLIT and see how you get on converting it if you'd like.

Version 2.1.1 (next post!) updates conversion slightly. I tested with the output you provided, and this generates a "correct" book (no extant HTML tags hanging around) when run with the "--strip-html" switch.

However, you will very likely still want to do some editing prior to running pielrf with any CLIT output. For example, running pielrf on raw CLIT HTML doesn't give you chapters, so you have one long book. And it's kind of "inelegant" to have the "THIS BOOK IS GREAT!" blurbs, followed by the Copyright Page, followed by the book itself, all in one shot.

So, pielrf --strip-html DOES work, but I recommend using striphtml to do the initial cleaning of all tags pielrf doesn't understand. THEN you can easily add <chapter> tags, and run THAT through pielrf. This will produce much nicer results, and only take a little extra time (depending on the complexity of the book).

-Pie

EatingPie
06-21-2007, 09:44 PM
New version pielrf 2.1.1.

See the first post to download.

- On Windows, the executable is now named PIELRF.PY after running setup.
- Added "--parskip=" setting, to allow added spacing between paragraphs
- Any "* * *" on its own line is converted to a section break, unless suppressed with the "--no-starbreak" switch
- Books without <chapter> tags now render without a TOC
- Little bit of extra stripping of CLIT output.
- Added back in one vertical space at beginning of chapter, to offset the chapter title slightly, suppressed with "--no-chapterspace"


By default, the parskip setting is 0, and an increase to about 10 or 20 starts to give visible results.

In the United States, a lot of books use the "* * *" to delimit section breaks within a chapter. These are now automatically found, centered, and given a vertical break, just as in a book.

In terms of vertical space at the chapter heading, this disappeared with version 2.1, so I added it back. If you prefer no additional vertical space, you can turn it off with the "--no-chapterpsace" option.

-Pie

JSWolf
06-21-2007, 09:49 PM
Does --parskip add in a 1/2 line space or a full line space? I hope it's not a full line space. Most people don't like full line spaces on the reader where they are not meant to be.

EatingPie
06-22-2007, 12:34 PM
The --parskip is actually in points, and is independent of the line spacing. I had to crank it up to like 10 to see any noticeable change.

It's "off" by default (0), so it won't effect anyone unless they actually use it.

EDIT: Let me clarify a bit. Line spacing is applied between paragraphs, THEN the parskip is also added. It being zero (0) means no ADDITIONAL spacing is added. Hope that helps.

-Pie

JSWolf
06-22-2007, 01:38 PM
The --parskip is actually in points, and is independent of the line spacing. I had to crank it up to like 10 to see any noticeable change.

It's "off" by default (0), so it won't effect anyone unless they actually use it.

EDIT: Let me clarify a bit. Line spacing is applied between paragraphs, THEN the parskip is also added. It being zero (0) means no ADDITIONAL spacing is added. Hope that helps.

-Pie
So let me see if I understand, PieLRF is adding a line space between paragraphs and then --parskip can add even more space?

EatingPie
06-22-2007, 01:59 PM
Yep.

-Pie

JSWolf
06-22-2007, 02:05 PM
Yep.

-Pie
Would you mind not putting any extra line spaces between paragraphs and letting the user decide? I find the Palm format of extra line spaces to be annoying. If the occasional one is there because it's means to be there, then that's not a problem. But we (the ones who voted in the poll on line spaces and voted no) would prefer not to have them with no way to turn them off.

EatingPie
06-22-2007, 11:04 PM
Oh! I think we had a miscommunication!

I hate the extra spacing between paragraphs, and would have voted against it too (no offense simmepimme)...

Is it possible to add some extra vertical space before each paragraph; I like some air between paragraphs?


This feature is OPTIONAL, added per the above request. You MUST specify "--parskip=n" for pielrf to add the extra space. If you don't put this on the command line, there's NO extra spacing. Everything behaves as it did before.

:)

Almost every feature I add, I give a command line switch to control it. Everyone has different tastes, and my goal is to have pielrf to be as flexible as possible to accommodate those tastes. There'll always be a way to turn new features off!

-Pie

EatingPie
06-22-2007, 11:14 PM
New version pielrf 2.1.2.

See the first post to download.

A minor update / bug fix for ConvertLit.

- Handles ConvertLit <span class="italic"></span>, <span class="bold"></span>, (etc.) for italics, bold, subscript and superscript formatting.
- A few programmatic clean-ups as well.

-Pie

JSWolf
06-23-2007, 08:40 PM
New version pielrf 2.1.2.

See the first post to download.

A minor update / bug fix for ConvertLit.

- Handles ConvertLit <span class="italic"></span>, <span class="bold"></span>, (etc.) for italics, bold, subscript and superscript formatting.
- A few programmatic clean-ups as well.

-Pie
Now I know you'll want to hate me for this, but how does PieLRF handle the seperate contents file sometimes generated from LIT to HTML conversions?

EatingPie
06-23-2007, 09:26 PM
Now I know you'll want to hate me for this, but how does PieLRF handle the seperate contents file sometimes generated from LIT to HTML conversions?

:)

In a word... not at all.

Pielrf will only process the file fed to it, and it doesn't handle external -- or even internal -- links.

-Pie

PS I'll only hate you if you request this as a feature! :)

JSWolf
06-23-2007, 09:36 PM
Ok, hate me. Consider it requested.

EatingPie
06-23-2007, 10:06 PM
Ok, hate me. Consider it requested.

Damn!

I'd be lying if I didn't see that coming though. :)

I'll look into it.

-Pie

JSWolf
06-23-2007, 10:08 PM
What might be easier to do that would also work is to come up with a program to join them together and make it in a format PieLRF likes.

Lime2K
06-23-2007, 11:25 PM
That's probably true. A way to feed it multiple files, and have links between them, would be awesome. Or even if there was a way to bookmark points in a single long file, and link between them, and I would love you forever (in a non-prison-movie way, of course...)

Oh, and the feature where pielrf doesn't make a TOC on a file without <chapter> tags isn't working for me. It just makes a TOC with a single entry of the first line of the file. Do I need to add --disable-toc to force this behaivor? Or did you fix it in 2.1.2, 'cause I havent downloaded that version yet?

EatingPie
06-24-2007, 01:39 PM
That's probably true. A way to feed it multiple files, and have links between them, would be awesome. Or even if there was a way to bookmark points in a single long file, and link between them, and I would love you forever (in a non-prison-movie way, of course...)

Oh, and the feature where pielrf doesn't make a TOC on a file without <chapter> tags isn't working for me. It just makes a TOC with a single entry of the first line of the file. Do I need to add --disable-toc to force this behaivor? Or did you fix it in 2.1.2, 'cause I havent downloaded that version yet?

Yeah, links are something I looked at a while back, and just decided I didn't know what to do with them. I'm a bit more savvy now and might be able to find a solution.

And on the no-TOC feature, I thought I fixed it in 2.1.1, but in retrospect, I think it's 2.1.2 that does it (hence me leaving it out of the feature list). Regardless, I recommend the latest version. It fixes also fixes a major bug with stripping HTML which I didn't list, and I've since discovered it was far worse than I knew (the advantage of the developer actually USING his product!).

Every time you update, always remember to do a:

python setup.py install

Most changes occur in the library these days.

-Pie

kovidgoyal
06-24-2007, 04:07 PM
pie if you want to support links you have to write a recursive algorithm, take a look at html2lrf's code.

EatingPie
07-03-2007, 02:34 PM
Now Sticky... my humble and hearty thanks to the admins!

-Pie

EatingPie
07-03-2007, 02:46 PM
I've been considering the features recently discussed (and thanks for the recursion pointer kovid!). At this point, however, I am pursuing a related program for a very specific application. I'm not completely optimistic, so I don't want to say too much, but I wanted to give everyone a heads-up in terms of what I'm doing.

I do have a few things in regards to pielrf specifically.

First, and foremost, while I work on the new project, I will continue to fix bugs as they're reported.

Second, I am planning two changes to defaults, and I wanted to know how others felt.

+--baselinkskip=120
+--trust-html

I would like to make these options default. Right now baselineskip is 100, and it's fairly cramped, especially in relation to other paperback books. A default of 120 opens things up a bit and strikes me as easier on the eyes. You can still set --baselinksip to whatever you want, this is just a change in the DEFAULT.

The --trust-html option is for HTML quotes. By default pielrf abandons html-specified curly quotes and uses its own algorithm. Now that I've been using the program for a while, I've found that it's generally better to trust the HTML curly quotes. I would add a reverse option so you can override override the HTML curly quotes and use pielrf's algorithm when necessary.

Does this sound good, bad, indifferent? Let me know.

-Pie

Lime2K
07-03-2007, 03:09 PM
I have a suggestion for a couple of new tags (one should be easy, the others might be harder):

<pgbreak> - forces a new page like <chapter> does, without making an entry in the TOC (would be useful for title pages, among other things)

<u>underline</u>

<monospace> or <mono> - force the text into a monospace (courier-ish) font (i dunno if the reader has one built-in, offhand) and have all spaces displayed (would be useful for tables, and things of that nature)

and maybe inline images, somehow?

ns66
07-28-2007, 10:06 PM
is there a way to not page break a new chapter? with too many chapters page breaks really wasted limited realestate

also any way to make a cover page with title and author?

if not implemented any pointer where to modify the code?

thanks

EatingPie
07-30-2007, 03:42 PM
Hi.

There is a way, and for my aforementioned "other project" I have started the code to do so. How this will blend back into pielrf, I'm not yet sure as I've been sidetracked from THAT project by something else. I'm pretty much done with this "something else"... unless I want to read The Deathly Hallows for a 3rd time... and I just might. :)

In terms of code, this requires a new class that doesn't page-break at a chapter. It can be derived from the existing classes IIRC, but I haven't looked at the code in a few weeks.

-Pie

tsgreer
07-30-2007, 04:55 PM
What about images? Is there any way to work images in somewhere when making a book with Pielrf? I like cover images and also it would be useful when the book calls for illustrations inside...

JSWolf
07-30-2007, 06:28 PM
Can I be really silly here? This sounds like it's going to turn into another html2lrf.

Lime2K
08-02-2007, 10:18 PM
Here's a bug report, _and_ the fix for it (it was a really easy one)

PieLRF wasn't recognizing &lsquo; and &rsquo; as single quotes.

Here's the original code <in textconvert.py>, under <def convert_html_ampersands>


The original code:
if html_quotes :
line = line.replace("&ldquo;", u"\u201C") # OPEN
line = line.replace("&rdquo;", u"\u201D") # CLOSE
line = line.replace("", u"\u201C")
line = line.replace("", u"\u201D")
line = line.replace("", u"\u2018")
line = line.replace("", u"\u2019")
else :
line = line.replace("&ldquo;", u"\"")
line = line.replace("&rdquo;", u"\"")
line = line.replace("", u"\"")
line = line.replace("", u"\"")
line = line.replace("", u"'")
line = line.replace("", u"'")
#endif

Replace with:
if html_quotes :
line = line.replace("&ldquo;", u"\u201C") # OPEN
line = line.replace("&rdquo;", u"\u201D") # CLOSE
line = line.replace("", u"\u201C")
line = line.replace("", u"\u201D")
line = line.replace("&lsquo;", u"\u2018")
line = line.replace("&rsquo;", u"\u2019")
line = line.replace("", u"\u2018")
line = line.replace("", u"\u2019")
else :
line = line.replace("&ldquo;", u"\"")
line = line.replace("&rdquo;", u"\"")
line = line.replace("", u"\"")
line = line.replace("", u"\"")
line = line.replace("&lsquo;", u"'")
line = line.replace("&rsquo;", u"'")
line = line.replace("", u"'")
line = line.replace("", u"'")
#endif


This keeps the correct behavior of --html-quotes.

I fixed it in my personal copy already, but am posting it here so it makes it into the official releases as well.

Enjoy!

ns66
08-03-2007, 03:12 AM
why even if i set margins=0, there are still space on left and right side, how do i make them smaller to make more use of the precsious screen? make screen width bigger like 620 doesn't help either

thx

EatingPie
09-04-2007, 07:32 PM
Man. I added this myself, and decided that -- while I was at it -- I should come back here to add your code too (assuming it was a different feature!). That's what I get for reading a bunch of books in my spare time instead of this thread! :)

I'll post an update in a few days. I also have the code for non-page-breaking Chapters, but it's not plugged in yet. I have to try it out then I'll probably post the update flagged as beta.

Sorry, no image support. I'm not sure I'll ever add that. :(

-Pie

Here's a bug report, _and_ the fix for it (it was a really easy one)

PieLRF wasn't recognizing &lsquo; and &rsquo; as single quotes.

Here's the original code <in textconvert.py>, under <def convert_html_ampersands>


The original code:
if html_quotes :
line = line.replace("&ldquo;", u"\u201C") # OPEN
line = line.replace("&rdquo;", u"\u201D") # CLOSE
line = line.replace("", u"\u201C")
line = line.replace("", u"\u201D")
line = line.replace("", u"\u2018")
line = line.replace("", u"\u2019")
else :
line = line.replace("&ldquo;", u"\"")
line = line.replace("&rdquo;", u"\"")
line = line.replace("", u"\"")
line = line.replace("", u"\"")
line = line.replace("", u"'")
line = line.replace("", u"'")
#endif

Replace with:
if html_quotes :
line = line.replace("&ldquo;", u"\u201C") # OPEN
line = line.replace("&rdquo;", u"\u201D") # CLOSE
line = line.replace("", u"\u201C")
line = line.replace("", u"\u201D")
line = line.replace("&lsquo;", u"\u2018")
line = line.replace("&rsquo;", u"\u2019")
line = line.replace("", u"\u2018")
line = line.replace("", u"\u2019")
else :
line = line.replace("&ldquo;", u"\"")
line = line.replace("&rdquo;", u"\"")
line = line.replace("", u"\"")
line = line.replace("", u"\"")
line = line.replace("&lsquo;", u"'")
line = line.replace("&rsquo;", u"'")
line = line.replace("", u"'")
line = line.replace("", u"'")
#endif


This keeps the correct behavior of --html-quotes.

I fixed it in my personal copy already, but am posting it here so it makes it into the official releases as well.

Enjoy!

phrodod
09-16-2007, 03:58 AM
I have a strange bug to report. When paragraphs are joined together, somehow the space inserted between lines is a non-expanding space, while regular lines are expanding spaces. This makes the text look very strange if a lot of space gets added (e.g., at large size) in a line like: This line of text has strange spacing in it! I can't see where the offending code is, so I can't offer a fix. Sorry!

Phrodod

yargoflick
09-24-2007, 09:30 PM
Here there, I'm trying out the <verse> tag, but she's not doing what I thought.

I thought the following:

<verse>
black against<br>
white sky<br>
from dropped tree<br>
</verse>


would give me:

black against
white sky
from dropped tree


but instead I get all left justified:

black against
white sky
from dropped tree


If I put a normal paragraph, one with no forced line breaks(<br>), between <verse> tags then it DOES get nicely verse indented.

Is there a way to specify line breaks and get verse indenting?

Oh, I tried using <pre> </pre> tags around the poems, settling for monospaced but properly formatted, but pielrf just ignores them.

Lime2K
09-25-2007, 12:54 AM
What <verse> does is called a 'hanging indent'. If the line is longer than a screen width, it does wrap, like this:


| end of page
text
text
text text really long
amount of text
text


It's designed for song lyrics, and stuff. To get what you want (assuming normal text is indented) you need to add <justified></justified> to the first line, and leave the others alone. If you want all the text centered, you could add a <blockquote> around it as well, like this:


<blockquote>
<justified>black against</justified>
white sky
from dropped tree
</blockquote>

Hope this helps!

yargoflick
09-26-2007, 01:17 PM
lime2k: thanks, that works fine.

Are there wiki pages for pielrf, or txt2html, that describe usage?
I'm thinking pages that show supported tags and usage tips, tricks and examples?

If there are some could ya point me the way.

If there aren't I'ld be happy to start some.
Documentation wiki (how does one pluralise wiki?) rock.

DreamDreams
09-29-2007, 10:10 PM
A little patch with allows utf-8 in title, author and category from command line

diff pielrf.orig pielrf
524a525,530
> if not isinstance(options.title, unicode):
> options.title = options.title.decode('utf-8')
> if not isinstance(options.category, unicode):
> options.category = options.category.decode('utf-8')
> if not isinstance(options.author, unicode):
> options.author = options.author.decode('utf-8')

megacoupe
09-30-2007, 11:50 AM
why even if i set margins=0, there are still space on left and right side, how do i make them smaller to make more use of the precsious screen? make screen width bigger like 620 doesn't help either

thx

Yes, I'm having the same problem; are there any setting tricks so that all the space on the Reader's screen is used up?

So far, I've tried the following:

--topmargin=0 --sidemargin=0 --headerstyle=none

But I still get enough empty space above and below to fit in 4 more lines of text (and a small amount of space on the left and right side as well). I tried adding this as well:

--headerheight=0

While that seems to remove the extra space at the top, it makes a new gap at the bottom that's twice as large. Changing the variable to "1" and "5" produces the same effect.

Ideally, I'd like to have the entire screen used (corner to corner). I'm going to mess around with this some more, but suggestions from anyone who's been using pielrf for longer than I have would be greatly appreciated.

Lime2K
09-30-2007, 01:16 PM
If you change the margins, you've got to change --screenwidth and --screenheight as well. Default width and height is 475 x 690. (Note you don't get 800 pixels of height out of the screen due to the status bar at the bottom of the screen).

Hope this helps!

megacoupe
09-30-2007, 08:09 PM
Well, I finally managed to get the text to fill the top and bottom of the screen using ALL of these commands:

--headerstyle=none --headerheight=0 --topmargin=0 --sidemargin=0 --screenheight=800 --screenwidth=650

The only problem is, I still have the thin blank spaces on the left and right sides. I started with a screenwidth of 600 and worked up to 650 in increments of 10, but there were no changes visible in any of my tests. I've given up figuring this last part out, unless someone has an inspired command for me to try out (I even tried using negative values for --sidemargin, but I got an error from the program).

EatingPie
10-09-2007, 07:41 PM
New version pielrf 2.1.3.

See first post to download.

NEW FEATURES
striphtml --atochapter can take HTML anchor tags and create <chapter> tags with them.
--use-html is now the default.
--baselineskip=120 is now the default
--nochapterbreaks does NOT put a pagebreak between chapters.
Added missing HTML tags.


Examples
striphtml --atochapter converts the following...
<a NAME="SOME_TAG">This is a Chapter</a>
to
<chapter>This is a Chapter

--nochapterbreaks implements n66's request from the following post:
http://www.mobileread.com/forums/showpost.php?p=84014&postcount=81

New HTML tags implement those found by lime2k in the following post:
http://www.mobileread.com/forums/showpost.php?p=85293&postcount=85

Sorry on the time it took to update. I created some crufty code in this update, and just got frustrated. It freakin' works though, which somehow makes it even MORE frustrating! Next step is to streamline the code (purely a "programmer's thing" and won't effect functionality).

Anway, here it is... or there it is in the first post. :)

-Pie

EatingPie
10-13-2007, 03:09 PM
I have a strange bug to report. When paragraphs are joined together, somehow the space inserted between lines is a non-expanding space, while regular lines are expanding spaces. This makes the text look very strange if a lot of space gets added (e.g., at large size) in a line like: This line of text has strange spacing in it! I can't see where the offending code is, so I can't offer a fix. Sorry!

Phrodod

This a Reader issue rather than a "programmatic" problem Pielrf strips spaces so that there is only one space between each word, and the Reader itself adds additional spacing to create justified text.

Typically you get lines like that when the previous or next lines have very large words in them. The Reader justifies all text, so lines where large words didn't fit get more spacing.

-Pie

Lime2K
10-14-2007, 12:15 AM
I think he's referring more to the fact that some lines have both big and small spaces in them, instead of having even justification across a line.

Example:

This is a line justified how it should be.
This is a line justified how it is wrong.

Where the line ends, there's a small space, instead of a properly justified one.

turtleclock
12-06-2007, 05:59 PM
Another question, can pielrf put a title page in the book before the TOC? I'd like to have the first page be the Author and the Title, then a page break via the * * * line, then the automatically generated TOC. Is this possible?

SilverMachine
01-11-2008, 10:40 PM
To expand on turtle's request, I have a two-part suggestion.

1: To be a little more flexible, I would like to insert the TOC at wherever I put the "TOC-goes-here" tag (which should ideally immediately precede a "chapter" tag). Why? that would permit building a book like "Title page - inside front cover blurb - publication info - TOC - chapters."

I was trying to build a book like that (but without the toc, knowing pielrf would generate it) and kept wondering why I kept getting an entry in the generated TOC called "undefined" until I realized that (doh!) there had to be something at the beginning, and if I didn't define the first bit as some kind of chapter then it was, of course, undefined.

I've also had difficulty with being unable to break pages without setting a chapter mark, but that's not really important -- I thought * * * was supposed to pagebreak, but it seems to only separate paragraphs.

2: Actually, I lied in part 1. What I really want is "(cover art) - Title page - inside front cover blurb - publication info - TOC - chapters" but I read earlier in this thread that inserting pictures isn't something you're too likely to do. Ah well, this is only a "it would be nice if" request, not a "I really need this feature" request.

I've not done any python programming, but I was looking at your code and it seems to me (and I could be all wet, not a good thing around computers or books) that it ought to be possible to emit some code before you even get around to assembling the TOC -- but I'm really not sure how to do it.

Thank you for writing pielrf - I just got my 505 for Christmas & being the type I am I immediately started loading it up with what I had available, but you have taken care of the hardest part for me with this easy little tool.

diablo9
01-20-2008, 07:29 AM
Hi there,
First thanks alot for the hard work of both EatingPie and simmepimme. :)
So I downloaded 2.13 of Pielrf and PielrfGUI. I downloaded Python 2.51 and installed it correctly in 10.5.1 OSX with the installer package. Then I extracted pielrf-2.1.3 into: /user/myusername/downloads/pielrf-2.1.3.
I also copied PielrfGUI into same folder.
Then I open terminal go to above folder, and type:

sudo python setup.py install

now it showed:


running install
running build
running build_py
running build_scripts
running install_lib
running install_scripts
changing mode of /Library/Frameworks/Python.framework/Versions/2.5/bin/asciicheck to 755
changing mode of /Library/Frameworks/Python.framework/Versions/2.5/bin/pielrf to 755
changing mode of /Library/Frameworks/Python.framework/Versions/2.5/bin/striphtml to 755
running install_egg_info
Removing /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/pielrf-2.0-py2.5.egg-info
Writing /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/pielrf-2.0-py2.5.egg-info


So this mean the pielrf is correctly installed right?

Then I launch PielrfGUI and go to menu-->install library pielrf, and there is no prompt no whatsoever.
So I opened the sample basic-test.txt in examples folder, made couple of changes in PielrfGUI and go to File-->save, and put "filename.lrf".
Now it gave me: "library failure!" have you installed pielrf library? also make sure you are using python with version >2.5. There is also a log: "env: python: Not a directory"

But I DID install pielrf library in the above step, didn't I??? :blink:
Please help~~~

eumesmo
03-03-2008, 06:53 AM
I must say I do love this app, it really does make it easy as pie(eating that is). Still, I too would like to request jpg support, nothing fancy, just take jpg and resize it to fit horizontally, like Web2Book, it would be so helpful in making text books, please please, I do beseech you. :cry:

myway
12-28-2008, 08:04 AM
Hi all

i both use Mac & Winxp but got same problems

Traceback (most recent call last):
File "/Volumes/PielrfGUI/PielrfGUI.app/Contents/Resources/pielrf/pielrf", line 130, in <module>
from pielrf.chapterbook import *
ImportError: No module named pielrf.chapterbook

i installed python 2.5 and run python -version is ok.

What can i do ?




ok, i tired again and run "sudo python setup.py install" under PielrfGUI folder. Then i try to convert the txt but get this error msg:

Traceback (most recent call last):
File "/Volumes/PielrfGUI/PielrfGUI.app/Contents/Resources/pielrf/pielrf", line 919, in <module>
pielrf()
File "/Volumes/PielrfGUI/PielrfGUI.app/Contents/Resources/pielrf/pielrf", line 656, in pielrf
book = ChapterBook(cmdline)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/pielrf/chapterbook.py", line 145, in __init__
options.title = convert_title_text(options.title)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/pielrf/textconvert.py", line 366, in convert_button_text
line = convert_misc(line)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/pielrf/textconvert.py", line 333, in convert_misc
line = line.replace("---", u"\u2013")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)

daesdaemar
12-29-2008, 05:45 PM
I am trying to format a bible and am happy at this point to use the names of the biblical books as chapter titles.

In using pielrf, I can use the command: pielrf.py -i bible.txt -o bible.lrf
and I get a nice conversion.

However, if I use the command: pielrf.py -i bible.txt -o bible.lrf <chapter>genesis <chapter>exodus
then I keep getting the error message "The system cannot find the file specified"

Any ideas what I'm doing wrong?

yargoflick
01-12-2009, 12:35 PM
If I'm hearing ya right... I think you've misunderstood.
You're supposed to edit the bible.txt file, search through it, and put <chapter> tags on the lines you want come out as titles. The <chapter> tags go in the text file being processed, not on the command line.

Hope that helps,
Cheers

I am trying to format a bible and am happy at this point to use the names of the biblical books as chapter titles.

In using pielrf, I can use the command: pielrf.py -i bible.txt -o bible.lrf
and I get a nice conversion.

However, if I use the command: pielrf.py -i bible.txt -o bible.lrf <chapter>genesis <chapter>exodus
then I keep getting the error message "The system cannot find the file specified"

Any ideas what I'm doing wrong?