Genii Weblog

Midas: Letting CSS handle the formatting

Wed 26 Sep 2007, 12:37 PM



by Ben Langhinrichs
While a lot of companies use our Midas Rich Text LSX and Midas Rich Text C++ API to render HTML because it does such a good job reproducing the look and feel of the Notes client, that is by no means whatever everybody wants.  I thought it might be worth mentioning that in Midas 3.70 (and in the upcoming 4.0), it is possible to let CSS guide the style much more effectively.  As an example, you can say that you want your tables rendered "sparsely", so that the following table

Original table

which might normally render (using Midas) as

<table border='1'>
  <tr valign='top'>
    <td width='96' bgcolor="#00ff00"><b>City</b></td>
    <td width='192' bgcolor="#00ff00" valign='top'><b>City</b></td>
  </tr>
  <tr valign='top'>
    <td width='96' bgcolor="#00ffff">80,000</td>
    <td width='192' bgcolor="#00ffff">Barcelona</td>
  </tr>
  <tr valign='top'>
    <td width='96' bgcolor="#00ffff">16,050</td>
    <td width='192' bgcolor="#00ffff">Madrid</td>
  </tr>
</table>

instead would render as

<table>
  <tr>
    <td><b>Sightings</b></td>
    <td><b>City</b></td>
  </tr>
  <tr>
    <td>80,000</td>
    <td>Barcelona</td>
  </tr>
  <tr>
    <td>16,050</td>
    <td>Madrid</td>
  </tr>
</table>

thus allowing you to use CSS to set the look and feel.  And if you need a bit more control, you could also AutoTag the table and rows (and cells, but that isn't needed here), and get

<table id='tbl1'>
  <tr id='tbl1_r1'>
    <td><b>Sightings</b></td>
    <td><b>City</b></td>
  </tr>
  <tr id='tbl1_r2'>
    <td>80,000</td>
    <td>Barcelona</td>
  </tr>
  <tr id='tbl1_r3'>
    <td>16,050</td>
    <td>Madrid</td>
  </tr>
</table>

which would then allow you to set the color of the first row differently.  In Midas 4.0 you can go one step further and instead AutoClass the rows (and columns and cells, but not here) so that you would get

<table id='tbl1'>
  <tr class='tblr1'>
    <td><b>Sightings</b></td>
    <td><b>City</b></td>
  </tr>
  <tr class='tblr2'>
    <td>80,000</td>
    <td>Barcelona</td>
  </tr>
  <tr class='tblr3'>
    <td>16,050</td>
    <td>Madrid</td>
  </tr>
</table>

so that you could set all first rows one style and all second rows another and so on.

It is all up to you, as it should be.

Copyright © 2007 Genii Software Ltd.

What has been said:


629.1. W^L+
(09/26/2007 12:12 PM)

Ben, why do you use b tags instead of th tags there? With a th tag, the CSS can be used to impart the bold or to underline or center or whatever, while retaining the meaning of "header".


629.2. Ben Langhinrichs
(09/26/2007 01:24 PM)

A valid question. It wasn't a great example, perhaps, because this is too evidently a header. If I had actually set the table to have a header row, the TH tags would have been created by Midas, but then I wouldn't have had a need to use this auto tagging or auto classing feature. So, Midas can certainly do what you suggest, but this is a different scenario. Perhaps I should make it the second row to avoid that sort of question.

By the way, it is also possible to AutoClass alternating rows or columns to allow those to be styled differently.

Thanks for the question.


629.3. Stan Rogers
(09/27/2007 09:27 AM)

One can never infer TH from bold text. Let's take the typical competitive feature comparison chart, where "our stuff" is obviously going to be bold, while the competitor's lesser offerings will be, well, rather less than bold. The actual header cells on such a table are usually in a smaller font than the table data entries as well, so font size isn't a reliable indicator either. The only reliable means of programmatically determining where the headings are is by seeing which cells the table's creator set as heading cells -- at least until culturally aware AI (that can keep up with the current cool, but knows a classic when it sees it) can be written into a compact LSX.


629.4. Ben Langhinrichs
(09/27/2007 10:16 AM)

Stan -

Your point is well made. In this case, Notes does allow the possibility to designate a cell as a row or column header, and that is what we use to determine the TH, not the bold or anything else. In Notes releases before 7.0, where there was no native mechanism to designate this, we had an alternative scheme where you could specify a set of color/face/size/attributes as you chose, and Midas would intuit headerness from those, but only if you chose to do so.

A lot of this was put into place so that CoexEdit, which uses the same Midas engine underneath, could be part of an accessible solution for governments, schools and corporations who have the need for such accessibility.

Again, in this particular case, I just should not have made the table even look like it had a header, as that managed to confuse the issue and distract from the original point. Sigh! Such is the nature of examples.

- Ben