2009/4/28 Rob Healey <robhealey1@gmail.com>


Still open for comments and suggestions...  I will not start until this coming weekend to give time for discussion!

I did not have any time to code on GRAMPS the last month.
As you know, I want to make different backends that are used to manage the file and do the actual writing. Simple classes that mainly abstract away some repeating code (open file, file extensions, ...) and things that do not fit in the basedoc class (styled tag conversion to physical output in file).

For html this htmlbackend will be a bit more elaborate as a html file will be a html file and css.

We have much to many half finished pieces in GRAMPS that need cleaning, so yes, it would be best  that libhtml is used everywhere where html is written. Just keep in mind that in the end some backend will be added too, so libhtml is only for the DOM tree.
So the interaction is:

  pdfdoc/htmldoc --- implements --> textdoc
     |    
     |-- write on --> pdfbackend/htmlbackend  -- implements --> textbackend  (works with the file )

Specifically for styled notes, there will be some interaction with the backend, as the backend class will be the class that knows how specific style must be written to the backend (eg basedoc has a start_bold method, and pdfdoc does this by writing a <b> to the file now, which would be replaced by having the pdfbackend start bold).
I really need to develop that to know how it would work for html, I have no experience with the html code yet. I would expect that htmlbackend can be written to with a Html object or appended with one, and stores that in an internal Html object. So keep that in mind when working on nar web conversion.
You would have:

backend = HtmlBackend(filename)
backend.open()
... construct a Html object htmlobj ...
backend.write_html(htmlobj)
backend.close()

Also keep in mind that styled notes would be passed as styled text to the htmlbackend, with the htmlbackend having the code to convert the styled note to the correct html dom. So the styled note must be passed to the backend

backend = HtmlBackend(filename)
backend.open()
... construct a Html object htmlobj ...
backend.write_html(htmlobj)
... output some styled notes
backend.write_styled_paragraph(text, styletags)
.... continue with more output in htmlobj_extra
backend.write_html(htmlobj_extra)
backend.close()

Important in above is to note that the html object that is written to file is the one stored in the backend.
The alternative is that the backend can construct a html obj for a styled note, and returns it for inclusion in a html object managed outside of the backend. 
I would hope to have that decided and done by the summer holidays. So you can wait till then to, or start now, knowing managing the files and the doing styled notes must be added later.

Benny