I have written a simple utility which is intended to complement Calibre's HTML2LRF in several ways which I found useful and which Kovidgoyal doesn't want (perhaps rightfully so) included in the utility itself. I focused on three things:
1) Include all HTML2LRF parameters within the HTML file itself. Until now, I had to write a separate batch file for every book I ever intended to convert, because each book uses similar but slightly different parameters.
2) Allow easy maintenance by centralizing common parameters while allowing for special behavior for each book.
3) Allow conversion of multiple books at once.
In the end, I decided to define several special <META> tags. My application would parse a HTML file for these tags, build a correct command line and finally execute HTML2LRF. This allows for easy inclusion of parameters while maintaining complete compatibility with HTML format.
A simple example: I have a book in HTML format. When I convert this book to LRF, I want to keep information about its title (HTML2LRF already does that) and author (HTML2LRF requires author specified on command line or in a special metadata file - .OPF, I think). And I might just as well define e.g. headers (as far as I know, this can only be specified on command line). I can do that by including these tags in the book's header:
<meta name="lrf:--author" content="First Last">
<meta name="lrf:--author-sort" content="Last First">
<meta name="lrf:--header" content="">
...
Since I wanted to keep this maintainable, I defined another special meta tag:
<meta name="@include" content="common.htm">
This would include the metatags from common.htm. Recursively, too. So that I could e.g. include an author-specific parameter file, which would in turn include a common parameter file.
If you think you'll find it useful, you can download the utility and its source code (in Delphi 5, but it should be easy enough to translate it to your favorite programming language) here:
http://www.pepak.net/sonyreader/h2lrf.zip
(The code is not optimized in any way - the purpose was to save myself effort writing batch files, not to demonstrate advanced algorithms; if it was to be too slow, no big deal - I would simply leave it running overnight)