[Kde-pim] asCleanHtml, and thoughts towards html replies to html emails

Stephen Kelly steveire at gmail.com
Sat Sep 13 15:43:38 BST 2008


Hi,

I've spent the last while working on a way to get clean html from
KRichTextEdit. 

I've recently been reading Design Patterns[Gamma et al] and decided to make
it also output plain text markup using the Builder pattern (I'm a kid with a
hammer). Making it produce markdown should be easy, and should be something
that kblogger should be able to use for blogs that accept markdown entries.
I intend to put those classes in kdelibs, but not until they've had some
maturity and use in kdepim (hopefully in KDE4.2), as I can't add any new
virtuals to the AbstractMarkupBuilder once it's in, and I might have
forgotten something.

I've put the lot in playground here:

http://websvn.kde.org/trunk/playground/pim/richtextbuilders/

To try it out, just cmakekde in there to get a krichtexteditor with outputs
in dock widgets when you push the update button. I looked at callgrind
output for it, and as far as I can tell it's pretty fast, but I'm planning
to design some incremental update system for it too, so the entire thing
doesn't have to be updated all the time. I might also add some kind of
MarkupDirector::registerBuilder() method and maintain a list of builders so
that the doc only needs to be traversed once even for multiple output
types.

There's also a sample html file with for testing. The new stuff is
incomplete in some obvious ways (eg images) and some non-obvious ways
regarding clean output, but I need to get it out the door in some form or
I'll never finish.

I also need to add support for super/sub script, paragraph top and bottom
margins and tables to KRichTextWidget before this goes in. 

It has apidox, but here's a rundown anyway:

Files for kdelibs:
markupdirector           -- instructs builders to construct markup
abstractmarkupbuilder    -- abstract class for all builders
plaintextmarkupbuilder   -- builds plain text markup
htmlbuilder              -- builds nice html markup

I think the above stuff could go into libkdepim soon, and be used to create
toNiceHtml and toPlainTextMarkup convenience methods in kmeditor.

The hope with the plainttextmarkupbuilder (or plaintextemailbuilder below)
is that people could compose rich text, but send plain text (configurable
for mailing lists etc), or send both as part of a multipart/alternative.


Files for kdepim (don't work at all. Mostly a braindump):
emailmarkupdirector              -- markupdirector with support for quotes,
                                        attachments etc
abstractemailbuilder             -- builder with support for quotes, etc
richemailbuilder                 -- multiply inherited htmlbuilder (for
                                    html building implementation) and 
                                    abstractemailbuilder. To be used to
                                    create html replies to html emails
plaintextemailbuilder            -- builds plaintext markup with quotes etc.
emaildocument                    -- QTextDocument with overriden
                                    createObject for attachments (and maybe
                                    quotes - depends on how it eventually 
                                    works).
emaildocumentquotedata           -- quote data associated with a textblock.
                                    Might be able to make quoting cleaner, 
                                    and allow nepomuk queries like 'replies
                                    to me in a mailing list containing the 
                                    word giraffe'

All the pim stuff is not going to work until I figure out how to create
custom QTextObjects properly. If anyone knows how that's done, please let
me know.

http://lists.trolltech.com/qt-interest/2008-09/thread00216-0.html

One major issue I see with html replies to html emails is that non-kmail
clients will send html that qtextedit doesn't know how to handle. That
might take some work to manipulate foreign emails into a format usable to
kmail.

On the other hand, I think khtml and webkit now have editing capabilities,
and might be usable instead of the pim stuff above. Does anyone know more
about it?

I know a lot of stuff that should be in .cpp files is still in .h files. I
was just doing that for convenience, and I'll fix it later.

If anyone else wants to change anything in there either, just go ahead.

All the best,

Steve.



_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list