README.TRST 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. Tabular Support for Simple Tables
  2. =================================
  3. Some definitions first:
  4. * NO table support
  5. What it says. :) Table related tags are treated like other
  6. completely unrecognized tags.
  7. Only listed for completeness, this does not describe Lynx.
  8. * MINIMAL table support
  9. Table related tags are recognized, and are used to separate
  10. the contents of different cells (by at least a space) and rows
  11. (by a line break) visibly from each other.
  12. * LYNX minimal table support (LMTS)
  13. The minimal table support as implemented by Lynx up to this point,
  14. also includes the way ALIGN attributes are handled on TABLE, TR
  15. and other specific tweaks (e.g. handle TABLE within PRE specially).
  16. LMTS formatting is briefly described in the Lynx User Guide, see
  17. the section "Lynx and HTML Tables" there. (The Users Guide has not
  18. yet been updated for tabular support.)
  19. * TABULAR support for tables
  20. Support for tables that really arranges table cells in tabular form.
  21. * Tabular Rendering for SIMPLE Tables (TRST)
  22. Tabular support for some tables that are 'simple' enough; what this
  23. code change provides.
  24. One basic idea behind providing TRST is that correct tabular support
  25. for all tables is complex, doesn't fit well into the overwhelmingly
  26. one-pass way in which Lynx does things, and may in the end not give
  27. pleasant results anyway for pages that (ab-)use more complex table
  28. structures for display formatting purposes (especially in view of Lynx
  29. limitations such as fixed character cell size and lack of horizontal
  30. scrolling; see also emacs w3 mode). Full table support within Lynx
  31. hasn't happened so far, and continues to seem unlikely to happen in the
  32. near future.
  33. The other basic idea is the observation that for simple tables, as
  34. used mostly for data that are really tabular in nature, LMTS rendering
  35. can be transformed into TRST rendering, after parsing the TABLE element,
  36. by two simple transformations applied line by line:
  37. - Insert spaces in the right places.
  38. - Shift the line as a whole.
  39. And that's exactly what TRST does. An implementation based on the
  40. simple observation above is relatively straightforward, for simple
  41. tables. On encountering the start of a TABLE element, Lynx generates
  42. output as usual for LMTS. But it also keeps track of cell positions
  43. and lengths in parallel. If all goes well, that additional information
  44. is used to fix up the already formatted output lines when the TABLE
  45. ends. If not all goes well, the table was not 'simple' enough, the
  46. additional processing is canceled. One advantage is that we always
  47. have a 'safe' fallback to well-understood traditional LMTS formatting:
  48. TRST won't make more complex tables look worse than before.
  49. What are 'simple' tables? A table is simple enough if each of its TR
  50. rows translates into at most one display line in LMTS formatting (excluding
  51. leading and trailing line breaks), and the width required by each row
  52. (before as well as after fixup) does not exceed the available screen size.
  53. Note that this excludes all tables where some of the cells are marked up as
  54. block elements ('paragraphs'). Tables that include nested TABLE elements
  55. are always specifically excluded, but the inner tables may be subject to
  56. TRST handling. Also excluded are some constructs that indicate that markup
  57. was already optimized for Lynx (or other browsers with no or minimal table
  58. support): TABLE in PRE, use of TAB.
  59. The description so far isn't completely accurate. In many cases, tables are
  60. not simple enough according to the last paragraph, but parts of each TR row
  61. can still benefit from some TRST treatment. Some partial treatment is done
  62. for some tables in this grey zone, which may or may not help to a better
  63. display, depending on how the table is used. This is an area where tweaks
  64. in the future are most expected, and where the code's behavior is currently
  65. not well defined.
  66. One possible approach:
  67. - The table is 'simple' according to all criteria set out in the previous
  68. paragraph, except that some cells at the beginning and/or end of TR rows
  69. may contain block elements (or other markup that results in formatting
  70. like separate paragraphs).
  71. - There is at most one range of (non-empty) table cells in each row whose
  72. contents is not paragraph-formatted, and who are rendered on one line
  73. together by LMTS, separate from the paragraph-formatted cells. Let's
  74. call these cells the 'core' of a row.
  75. Fixups are then only applied to the text lines showing the 'core' cells.
  76. The paragraph-formatted cells are effectively pulled out before/after
  77. their row (no horizontal space is allocated to them for the purpose of
  78. determining column widths for core line formatting).
  79. This is expected to be most useful for tables that are mostly
  80. simple tabular data cells, but with the occasional longer
  81. text thrown in. For example, a table with intended rendering:
  82. --------------------------------------------------------
  83. | date | item no. | price | remarks |
  84. |--------|--------------|---------|----------------------|
  85. | date-1 | item #1 | $0.00 | |
  86. |--------|--------------|---------|----------------------|
  87. | date-2 | item #2 | $101.99 | A longer annotation |
  88. | | | | marked up as a block |
  89. | | | | of text. |
  90. |--------|--------------|---------|----------------------|
  91. | date-3 | long item #3 | $99.00 | |
  92. --------------------------------------------------------
  93. It may now be shown by Lynx as
  94. .................................................
  95. date item no. price remarks
  96. date-1 item #1 $0.00
  97. date-2 item #2 $101.99
  98. A longer annotation marked up as a block of
  99. text.
  100. date-3 long item #3 $99.00
  101. .................................................
  102. As can be seen, this is still quite far from the intended rendering,
  103. but it is better than without any tabular support.
  104. Whether the code does something sensible with "grey area" tables is up
  105. for testing. Most of the typical tables in typical Web pages aren't
  106. used in a way that can benefit from the TRST approach. Parts of such
  107. tables may still end up getting shifted left or right by the TRST code
  108. when that doesn't improve anything, but I haven't seen it make things
  109. really worse so far (with the current code).
  110. TRST and Partial Display
  111. ------------------------
  112. [ Partial display mode is the feature which allows viewing and scrolling
  113. of pages while they are loaded, without having to wait for a complete
  114. transfer. ] During partial display rendering, table lines can sometimes
  115. be shown in the original formatting, i.e. with horizontal fixups not yet
  116. applied. This is more likely for longer tables, and depends on the state
  117. in which partial display 'catches' the TRST code. Sometimes the display
  118. may flicker: first the preliminary rendering of table lines is shown, then
  119. after loading is finished it is replaced by the fixed-up version. I do
  120. not consider this a serious problem: if you have partial display mode
  121. enabled, presumably you want to be able to see as much data as possible,
  122. and scroll up and down through it, as early as possible. In fact, the
  123. approach taken keeps Lynx free from a problem that may graphical browsers
  124. have: they often cannot render a table at all until it is received in full.
  125. ------------------------------------------------------------------------
  126. To summarize:
  127. - TRST is a solution that works in many cases where lack of tabular support
  128. was most annoying.
  129. - TRST doesn't implement a full table model, and it is extremely unlikely
  130. that it will ever be the basis for that. Keep on exploring external
  131. solutions, or perhaps waiting for (better: working on) a more fundamental
  132. redesign of Lynx's rendering engine.
  133. Klaus Weide - kweide@enteract.com 1999-10-13