Welcome | Get started | Dive into Lino | Contribute | Topics | Reference | More

lino.utils.html2odf

This module contains mainly a utility function html2odf() which converts an ElementTree object generated using etgen.html to a fragment of ODF.

This is not trivial. The challenge is that HTML and ODF are quite different document representations. But something like this seems necessary. Lino uses it in order to generate .odt documents which contain (among other) chunks of html that have been entered using TinyMCE and stored in database fields.

TODO: is there really no existing library for this task? I saw approaches which call libreoffice in headless mode to do the conversion, but this sounds inappropriate for our situation where we must glue together fragments from different sources. Also note that we use appy.pod to do the actual generation.

More about the usage of this module is in About formatting.

Functions

html2odf(e[, ct])

Convert a etgen.html element to an ODF text element.

toxml(node)

Convert an ODF node to a string with its XML representation.

lino.utils.html2odf.toxml(node)

Convert an ODF node to a string with its XML representation.

lino.utils.html2odf.html2odf(e, ct=None, **ctargs)

Convert a etgen.html element to an ODF text element. Most formats are not implemented. There's probably a better way to do this...

Ct:

the root element ("container"). If not specified, we create one.