Table class breaks preceding tables
robbm - January 5, 2009 - 17:00
| Project: | Table Alternate Rows |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
It seems that if:
- I use FCKeditor to create a page
- I create multiple tables on this page
- I add a (table) class to one or more of those tables
then the rows within those tables that are before the last table with the (table) class applied do not get "even" and "odd" (row) classes added to their rows.
Here's a simple example (I've added some whitespace to make it readable):
<div class="content">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr><td>A1</td><td>A2</td><td>A3</td></tr>
<tr><td>A4</td><td>A5</td><td>A6</td></tr>
<tr><td>A7</td><td>A8</td><td>A9</td></tr>
</tbody>
</table>
<table class="data" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr><td>B1</td><td>B2</td><td>B3</td></tr>
<tr><td>B4</td><td>B5</td><td>B6</td></tr>
<tr><td>B7</td><td>B8</td><td>B9</td></tr>
</tbody>
</table>
<table class="data" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr><td>C1</td><td>C2</td><td>C3</td></tr>
<tr><td>C4</td><td>C5</td><td>C6</td></tr>
<tr><td>C7</td><td>C8</td><td>C9</td></tr>
</tbody>
</table>
<table class="data" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr class="odd"><td>D1</td><td>D2</td><td>D3</td></tr>
<tr class="even"><td>D4</td><td>D5</td><td>D6</td></tr>
<tr class="odd"><td>D7</td><td>D8</td><td>D9</td></tr>
</tbody>
</table>
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr class="odd"><td>E1</td><td>E2</td><td>E3</td></tr>
<tr class="even"><td>E4</td><td>E5</td><td>E6</td></tr>
<tr class="odd"><td>E7</td><td>E8</td><td>E9</td></tr>
</tbody>
</table>
</div>Note that none of the tables that come before the last table with a (table) class (i.e. table D) have even or odd rows, but that table D and table E do.
Interestingly:
- switching FCKEditor to source mode
- cutting and pasting the source code
- resubmitting the page
seems to fix the problem. This seems to suggest that FCKEditor is initially producing code that the Table Alternate Rows module cannot parse, but that it changes this to code that the Table Alternate Rows module can parse when switched to source mode.

#1
Further investigations seems to show that the Table Alternate Rows module depends upon a certain amount of whitespace in the source. If FCKEditor's "Apply source formatting" is set to "true" then
This ensures that the Table Alternate Rows module works on all tables.If FCKEditor's "Apply source formatting" is set to "false" and I manually format the source HTML, then again the Table Alternate Rows module works on all tables.
However, if I create a number of tables (with or without FCKEditor) without any line breaks (or superfluous white space) then any tables that come before a table with a (table) class do not get even and odd rows.
However, I can't currently see the connection between table classes and whitespace...
#2
If anyone's experiencing the same problem, I now have a workaround:
admin/settings/customfilter/*to your WYSIWYG editor's excluded paths (e.g. Admininster > Site Configuration > FCKeditor > edit FCKeditor Global Profile > Visibility settings > Paths to exclude/include)/<table/i<table
<table)This will then add (a space and) a line break before each
<table...>tag, which seems to be enough for Table Alternate Rows to work...#3
Interesting. This is definitely something to fix in the module itself, versus relying on something else. What I'm curious about is that the module never actually looks for a table tag - it skips right to
<tbody>. Also, the filter keeps an offset counter, so it shouldn't care about newlines at all.I'm thinking the problem is the '.*' being a little greedy. Can you try this patch and see if it fixes it?
#4
#5
Thanks. That seems to fix it here.
#6
Looks like I missed committing this patch - it's now committed for both DRUPAL-5 and DRUPAL-6--1.
#7
Automatically closed -- issue fixed for 2 weeks with no activity.