Edgewall Software

Ticket #3347 (new enhancement)

Opened 2 years ago

Last modified 9 days ago

Generate <th> for table header

Reported by: dserodio@… Owned by: jonas
Priority: normal Milestone: 1.0
Component: wiki system Version:
Severity: minor Keywords: table
Cc:

Description

The first row of a table created with WikiFormatting should be a <th> element instead of a <tr>

Attachments

3347_TableHeaders.diff (2.7 kB) - added by nado18@… 9 days ago.
Diff file for table headers against 0.11.1
3347_TableHeaders.gif (8.5 kB) - added by nado18@… 9 days ago.
Screenshot of table headers

Change History

Changed 2 years ago by eblot

-1: there is no reason for forcing the first row (or the first column) to be a table header. Such a configuration is probably the most common case, but it is not a universal case.

Support for tables is poor, IMHO <th> should only be used when a special tag is inserted in the wiki syntax.

Changed 2 years ago by mgood

I agree that table headers should be a separate syntax rather than automatic for the first row. However, maybe we should just encourage the use of reStructuredText for more powerful table layouts like this example.

Changed 19 months ago by cboos

  • keywords table added
  • severity changed from normal to minor
  • milestone set to 1.0

Simple tables could eventually support a simple way to specify to use of a <th> instead of a <td>. This could be something like, with the = ... = reminiscent of the heading syntax.

||= column title =||= column title =||
||= row title    =|| data           ||

More complex tables would anyway be supported by #1424.

Changed 6 months ago by kamil@…

  • version devel deleted

Restructured text is nice, but I think its table syntax sucks. The biggest problem is that when you are updating a table and one of the cells in a row becomes wider than the others you now have to go through the rest of the table and add more --- characters to make all of the cells be equal width. This is not too bad for small tables, but if you have large tables, something like 50 rows, it becomes very tedious.

th tag support would be great. Currently in my organization people typically use bold text in headers, but it would be nice to be able to color the background a different color with CSS. I like the syntax proposed by cboos.

Changed 9 days ago by nado18@…

Diff file for table headers against 0.11.1

Changed 9 days ago by nado18@…

Screenshot of table headers

Changed 9 days ago by nado18@…

I'm attaching a patch that will generate <th> and </th> tags for headers. The syntax is to use triple pipes for headers, i.e.

|||   ||| 1 ||| 2 ||| 3 ||
||| A ||  X ||    ||  X ||
||| B ||    ||  X ||    ||
||| C ||  X ||  X ||    ||

will render as the second table

Screenshot of table headers

Changes:

  1. Added the <table_header> token in parser.py for |||
  2. Updated formatter.py to translate <table_header>s to HTML
    1. Added these methods
      • _table_header_formatter
      • open_table_cell_or_header
        • _table_header_formatter and _table_cell_formatter are much simpler using this helper
      • close_table_cell_or_header
        • open_table_cell_or_header starts by calling this before opening anything new
        • was able to simplify close_table_row by using it
    2. Initializing in_table_header in the reset method
  3. Added CSS for th tags
    1. Applying td's borders and padding to ths
    2. Inverting body colours on ths

Manual Testing:

  1. Ran tracd, added the following wiki
    Headers on top
    
      ||| Trac ||| Headers ||
      ||  Trac ||  Rocks!  ||
    
    Headers on top and side
    
      |||   ||| 1 ||| 2 ||| 3 ||
      ||| A ||  X ||    ||  X ||
      ||| B ||    ||  X ||    ||
      ||| C ||  X ||  X ||    ||
    
  2. Inspected generated HTML
    Headers on top
    </p>
    <blockquote>
    <table class="wiki">
    <tr></th><th> Trac <th> Headers 
    </th></tr><tr></td><td> Trac <td> Rocks! 
    </td></tr></table>
    </blockquote>
    <p>
    Headers on top and side
    </p>
    <blockquote>
    <table class="wiki">
    <tr></th></th></th><th>   <th> 1 <th> 2 <th> 3 
    </th></tr><tr></th></td></td><th> A <td>  X <td>    <td>  X 
    </td></tr><tr></th></td></td><th> B <td>    <td>  X <td>    
    </td></tr><tr></th></td></td><th> C <td>  X <td>  X <td>    
    </td></tr></table>
    

Add/Change #3347 (Generate <th> for table header)

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change. Next status will be 'new'
The owner will change to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.