Thread: Rss2Book
View Single Post
Old 01-25-2007, 11:57 AM   #101
geekraver
Addict
geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.geekraver ought to be getting tired of karma fortunes by now.
 
Posts: 364
Karma: 1035291
Join Date: Jul 2006
Location: Redmond, WA
Device: iPad Mini,Kindle Paperwhite
Quote:
Originally Posted by AndyQ
Thats a shame as I'm looking at an RSS import for BBeBinder and your html output converts quite nicely to LRF. What I was thinking of was to wrap your output engine as a library and use that.


If you do change your mind at any point then let me know. (Note BBeBinder is totally opensource).
Andy, right now with release 20 you could write a plug-in for rss2book to generate LRF. You need to implement IHtmlConverter (add a reference to IHtmlConverter.dll), which is pretty straightforward:

[Flags]
public enum FontStyle
{
Normal = 0,
Italic = 1,
Bold = 2,
Underline = 4
}

public enum TypeFace
{
Courier,
Helvetica,
TimesRoman
}

public interface IHtmlConverter
{
string Name // e.g. "PDF"
{
get;
}
string Extension // e.g. ".pdf"
{
get;
}
void Initialize(int leftMargin,
int rightMargin,
int topMargin,
int bottomMargin,
int pageWidth,
int pageHeight,
TypeFace font, // for normal text
int fontSize // for normal text
);

void HandleText(string text, TypeFace face, FontStyle style);
void FlushParagraph(); // called at <p> elements
void LineBreak(); // called at <br> elements
void EnterHeader(int level); // called at <h1>, <h2>, etc
void ExitHeader(); // called at </h1>, ...
void StartUnorderedList(); // called at <ul>
void StartOrderedList(); // called at <ol>
void FlushListItem(); // called at end of <li>
void EndList(); // called at </ul> or </ol>
void AddImage(string fname); // called for <img>
byte[] GetBytes(); // called at end to get the converted output
}

The DLL for your plugin needs to have a name starting with "write", and go in the same directory as rss2book.exe.

As you can see most entry points are for simple demarcating elements. HandleText is called for the text between elements. Right now the typeface can't change so HandleText will always pass the default typeface through, but the style can change (to combinations of bold and italic).

There is a chance I'll make front-ends plug-ins too but that is a much more ambitious project as it requires custom UI for each (I'm thinking things like rss, html, wikipedia, Gutenberg, ...). So writing a back-end converter plug-in is the easiest approach for now.

Last edited by geekraver; 01-25-2007 at 12:01 PM.
geekraver is offline   Reply With Quote