Blame docs/README.TRST

Packit f574b8
Tabular Support for Simple Tables
Packit f574b8
=================================
Packit f574b8
Some definitions first:
Packit f574b8
Packit f574b8
* NO table support
Packit f574b8
  What it says. :)  Table related tags are treated like other
Packit f574b8
  completely unrecognized tags.
Packit f574b8
  Only listed for completeness, this does not describe Lynx.
Packit f574b8
Packit f574b8
* MINIMAL table support
Packit f574b8
  Table related tags are recognized, and are used to separate
Packit f574b8
  the contents of different cells (by at least a space) and rows
Packit f574b8
  (by a line break) visibly from each other.
Packit f574b8
Packit f574b8
* LYNX minimal table support (LMTS)
Packit f574b8
  The minimal table support as implemented by Lynx up to this point,
Packit f574b8
  also includes the way ALIGN attributes are handled on TABLE, TR
Packit f574b8
  and other specific tweaks (e.g. handle TABLE within PRE specially).
Packit f574b8
  LMTS formatting is briefly described in the Lynx User Guide, see
Packit f574b8
  the section "Lynx and HTML Tables" there. (The Users Guide has not
Packit f574b8
  yet been updated for tabular support.)
Packit f574b8
Packit f574b8
* TABULAR support for tables
Packit f574b8
  Support for tables that really arranges table cells in tabular form.
Packit f574b8
Packit f574b8
* Tabular Rendering for SIMPLE Tables (TRST)
Packit f574b8
  Tabular support for some tables that are 'simple' enough; what this
Packit f574b8
  code change provides.
Packit f574b8
Packit f574b8
One basic idea behind providing TRST is that correct tabular support
Packit f574b8
for all tables is complex, doesn't fit well into the overwhelmingly
Packit f574b8
one-pass way in which Lynx does things, and may in the end not give
Packit f574b8
pleasant results anyway for pages that (ab-)use more complex table
Packit f574b8
structures for display formatting purposes (especially in view of Lynx
Packit f574b8
limitations such as fixed character cell size and lack of horizontal
Packit f574b8
scrolling; see also emacs w3 mode).  Full table support within Lynx
Packit f574b8
hasn't happened so far, and continues to seem unlikely to happen in the
Packit f574b8
near future.
Packit f574b8
Packit f574b8
The other basic idea is the observation that for simple tables, as
Packit f574b8
used mostly for data that are really tabular in nature, LMTS rendering
Packit f574b8
can be transformed into TRST rendering, after parsing the TABLE element,
Packit f574b8
by two simple transformations applied line by line:
Packit f574b8
- Insert spaces in the right places.
Packit f574b8
- Shift the line as a whole.
Packit f574b8
Packit f574b8
And that's exactly what TRST does.  An implementation based on the
Packit f574b8
simple observation above is relatively straightforward, for simple
Packit f574b8
tables.  On encountering the start of a TABLE element, Lynx generates
Packit f574b8
output as usual for LMTS.  But it also keeps track of cell positions
Packit f574b8
and lengths in parallel.  If all goes well, that additional information
Packit f574b8
is used to fix up the already formatted output lines when the TABLE
Packit f574b8
ends.  If not all goes well, the table was not 'simple' enough, the
Packit f574b8
additional processing is canceled.  One advantage is that we always
Packit f574b8
have a 'safe' fallback to well-understood traditional LMTS formatting:
Packit f574b8
TRST won't make more complex tables look worse than before.
Packit f574b8
Packit f574b8
What are 'simple' tables?  A table is simple enough if each of its TR
Packit f574b8
rows translates into at most one display line in LMTS formatting (excluding
Packit f574b8
leading and trailing line breaks), and the width required by each row
Packit f574b8
(before as well as after fixup) does not exceed the available screen size.
Packit f574b8
Note that this excludes all tables where some of the cells are marked up as
Packit f574b8
block elements ('paragraphs').  Tables that include nested TABLE elements
Packit f574b8
are always specifically excluded, but the inner tables may be subject to
Packit f574b8
TRST handling.  Also excluded are some constructs that indicate that markup
Packit f574b8
was already optimized for Lynx (or other browsers with no or minimal table
Packit f574b8
support): TABLE in PRE, use of TAB.
Packit f574b8
Packit f574b8
The description so far isn't completely accurate.  In many cases, tables are
Packit f574b8
not simple enough according to the last paragraph, but parts of each TR row
Packit f574b8
can still benefit from some TRST treatment.  Some partial treatment is done
Packit f574b8
for some tables in this grey zone, which may or may not help to a better
Packit f574b8
display, depending on how the table is used.  This is an area where tweaks
Packit f574b8
in the future are most expected, and where the code's behavior is currently
Packit f574b8
not well defined.
Packit f574b8
Packit f574b8
One possible approach:
Packit f574b8
- The table is 'simple' according to all criteria set out in the previous
Packit f574b8
  paragraph, except that some cells at the beginning and/or end of TR rows
Packit f574b8
  may contain block elements (or other markup that results in formatting
Packit f574b8
  like separate paragraphs).
Packit f574b8
- There is at most one range of (non-empty) table cells in each row whose
Packit f574b8
  contents is not paragraph-formatted, and who are rendered on one line
Packit f574b8
  together by LMTS, separate from the paragraph-formatted cells.  Let's
Packit f574b8
  call these cells the 'core' of a row.
Packit f574b8
Fixups are then only applied to the text lines showing the 'core' cells.
Packit f574b8
The paragraph-formatted cells are effectively pulled out before/after
Packit f574b8
their row (no horizontal space is allocated to them for the purpose of
Packit f574b8
determining column widths for core line formatting).
Packit f574b8
Packit f574b8
This is expected to be most useful for tables that are mostly
Packit f574b8
simple tabular data cells, but with the occasional longer
Packit f574b8
text thrown in.  For example, a table with intended rendering:
Packit f574b8
Packit f574b8
      --------------------------------------------------------
Packit f574b8
     |  date  |   item no.   |  price  |       remarks        |
Packit f574b8
     |--------|--------------|---------|----------------------|
Packit f574b8
     | date-1 | item #1      |   $0.00 |                      |
Packit f574b8
     |--------|--------------|---------|----------------------|
Packit f574b8
     | date-2 | item #2      | $101.99 | A longer annotation  |
Packit f574b8
     |        |              |         | marked up as a block |
Packit f574b8
     |        |              |         | of text.             |
Packit f574b8
     |--------|--------------|---------|----------------------|
Packit f574b8
     | date-3 | long item #3 |  $99.00 |                      |
Packit f574b8
      -------------------------------------------------------- 
Packit f574b8
Packit f574b8
It may now be shown by Lynx as
Packit f574b8
Packit f574b8
    .................................................
Packit f574b8
Packit f574b8
      date    item no.    price  remarks
Packit f574b8
     date-1 item #1        $0.00
Packit f574b8
     date-2 item #2      $101.99
Packit f574b8
Packit f574b8
     A longer annotation marked up as a block of
Packit f574b8
     text.
Packit f574b8
Packit f574b8
     date-3 long item #3  $99.00
Packit f574b8
Packit f574b8
    .................................................
Packit f574b8
Packit f574b8
As can be seen, this is still quite far from the intended rendering,
Packit f574b8
but it is better than without any tabular support.
Packit f574b8
Packit f574b8
Whether the code does something sensible with "grey area" tables is up
Packit f574b8
for testing.  Most of the typical tables in typical Web pages aren't
Packit f574b8
used in a way that can benefit from the TRST approach.  Parts of such
Packit f574b8
tables may still end up getting shifted left or right by the TRST code
Packit f574b8
when that doesn't improve anything, but I haven't seen it make things
Packit f574b8
really worse so far (with the current code).
Packit f574b8
Packit f574b8
TRST and Partial Display
Packit f574b8
------------------------
Packit f574b8
[ Partial display mode is the feature which allows viewing and scrolling
Packit f574b8
of pages while they are loaded, without having to wait for a complete
Packit f574b8
transfer. ]  During partial display rendering, table lines can sometimes
Packit f574b8
be shown in the original formatting, i.e. with horizontal fixups not yet
Packit f574b8
applied.  This is more likely for longer tables, and depends on the state
Packit f574b8
in which partial display 'catches' the TRST code.  Sometimes the display
Packit f574b8
may flicker: first the preliminary rendering of table lines is shown, then
Packit f574b8
after loading is finished it is replaced by the fixed-up version.  I do
Packit f574b8
not consider this a serious problem: if you have partial display mode
Packit f574b8
enabled, presumably you want to be able to see as much data as possible,
Packit f574b8
and scroll up and down through it, as early as possible.  In fact, the
Packit f574b8
approach taken keeps Lynx free from a problem that may graphical browsers
Packit f574b8
have: they often cannot render a table at all until it is received in full.
Packit f574b8
Packit f574b8
------------------------------------------------------------------------
Packit f574b8
Packit f574b8
To summarize:
Packit f574b8
 - TRST is a solution that works in many cases where lack of tabular support
Packit f574b8
   was most annoying.
Packit f574b8
 - TRST doesn't implement a full table model, and it is extremely unlikely
Packit f574b8
   that it will ever be the basis for that.  Keep on exploring external
Packit f574b8
   solutions, or perhaps waiting for (better: working on) a more fundamental
Packit f574b8
   redesign of Lynx's rendering engine.
Packit f574b8
Packit f574b8
Klaus Weide - kweide@enteract.com 1999-10-13