column widths of a TABLE when using xhtml()

Asked by Luc Saffre


when I generate myself some XHTML code of a table, for example

s = """
<TR><TD width="20">foo</TD><TD width="100">bar</TD></TR>

and then insert it into a document using:

do text
from xhtml(s)

then the result is a beautiful table, but all columns have same width.
It seems that the width values are ignored. Is that true?
Or am I missing something?
If that feature is not yet implemented, is there some workaround to specify column widths?


Question information

English Edit question
Appy Edit question
No assignee Edit question
Solved by:
Luc Saffre
Last query:
Last reply:
Revision history for this message
Gaëtan Delannay (gaetan-delannay) said :

Hi Luc,
Indeed, not yet implemented, sorry ;-)
The workaround for generating more "complex" tables is to create it programmatically via the class Once you have an instance of this class you can write

do text
from odtTableInstance.get()

But the problem is that OdtTable does not manage cell widths... Maybe if you take a look to this class, you could improve it?


Revision history for this message
Luc Saffre (luc-saffre) said :

Gaëtan, I had a look at this during the week-end.

`do text from <>`_
currently simply expects a chunk of XML to be inserted at that place of the template.
But it seems that we need more.
In order to specify widths of table columns,
we also need to be able add styles to the document:
at least one automatic style for each column that has a width specified.
This cannot be done using a simple XML chunk.
The `´ is useless as long as it cannot do more than returning an XML chunk.

My suggestion for :term:`appy.pod` is to extend the `do text from` clause so that
the user function may return something else than a string.
For example a `dict` with different keys "content", "styles", "automaticstyles"...

or an `odf.opendocument.OpenDocumentText
instance, and in that case appy.pod would
(1) inspect the `styles` and `automaticstyles`
of this instance and add them to the styles and automatic styles
of the template, (2) consider the whole `text` part
of the document instance as the XML chunk to be inserted.

Revision history for this message
Luc Saffre (luc-saffre) said :

Uff, I have a working solution. Not really beautiful but working. Besides generating the correct chunks of XML, we also need to add “dynamic” styles (i.e. which get generated only while rendering the content). The work is done by the finalizeFunction of the appy.pod renderer which inserts these additional styles afterwards (when the document has been processed).

Concretely this is done in
and demonstrated in file /tests/appy/20120419/

This implementation is partly Lino specific since it is a generic solution for rendering any Lino table, but the principal method should be reusable.

Any comments are welcome.


Revision history for this message
Luc Saffre (luc-saffre) said :