Changeset 132
- Timestamp:
- 06/21/2006 06:24:34 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
css/wikka.css (modified) (2 diffs)
-
formatters/wakka.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/css/wikka.css
r129 r132 447 447 } 448 448 449 table.wikka caption {450 border: 1px dotted #BBB;451 font-size: 9 0%;449 table.wikka caption { 450 border: 1px solid #CCC; 451 font-size: 95%; 452 452 color: #666; 453 453 margin:5px 0; … … 455 455 } 456 456 457 table.wikka thead { 458 background-color: #DDD; 459 } 460 461 table.wikka tfoot { 462 background-color: #DDD; 463 } 464 457 465 table.wikka th { 458 466 border: 1px solid #CCC; 459 467 padding: .1em .25em; 468 } 469 470 table.wikka thead th { 471 background-color: #DDD; 472 } 473 474 table.wikka tfoot th { 475 background-color: #DDD; 476 } 477 478 table.wikka tbody th { 479 background-color: #EEE; 480 } 481 482 table.wikka tbody tr:hover { 460 483 background-color: #EEE; 461 484 } -
trunk/formatters/wakka.php
r131 r132 46 46 static $br = 1; 47 47 static $trigger_table = 0; 48 static $trigger_rowgroup = 0; 48 49 static $trigger_bold = 0; 49 50 static $trigger_italic = 0; … … 70 71 if (2 < $trigger_table) echo ('</th></tr>'); 71 72 else if (1 < $trigger_table) echo ('</td></tr>'); 73 if (2 < $trigger_rowgroup) echo ('</tbody>'); 74 else if (1 < $trigger_rowgroup) echo ('</tfoot>'); 75 else if (0 < $trigger_rowgroup) echo ('</thead>'); 72 76 if (0 < $trigger_table) echo ('</table>'); 73 77 if ($trigger_strike % 2) echo ('</span>'); … … 87 91 return; 88 92 } 89 if ( preg_match("/^\|(\?)(.*?)?\|(\n)?$/", $thing, $matches) ) { 90 if ( $trigger_table == 0 ) { 93 94 if ( preg_match("/^\|(\?)(.*?)\|\n$/", $thing, $matches) ) 95 { 96 if ( $trigger_table == 0 ) 97 { 91 98 $trigger_table = 1; 92 //TODO escape text for safety93 99 return '<table class="wikka" summary="'.$matches[2].'">'."\n"; 94 100 } 95 101 } 96 102 // table. trigger means: 0==no table, 1==in table no cell, 2==in table data cell, 3==in table header cell 97 else if ( preg_match("/^\|(=|!)?(c|r)?(\d*)?(?:,)?(\d*)?\|(\n)?$/", $thing, $matches) ) { 98 //First catch is header|caption|summary, second is colspan, third is rowspan, fourth is linebreak. 99 if ( $trigger_table == 4 ) { 103 else if ( preg_match("/^\|(=|!|#)?(c|r|h|f|b)?(\d*)?(?:,)?(\d*)?\|(\n)?$/", $thing, $matches) ) 104 { 105 //Set up the two variables that will aggregate the html markup 106 $close_part = ''; 107 $open_part = ''; 108 //First catch is header|caption|rowgroup, second is attribute, third is colspan, fourth is rowspan, fifth is linebreak. 109 if ( $trigger_table == 4 ) 110 { 100 111 $trigger_table = 1; 101 112 return '</caption>'."\n"; //Can return here, it is closed. 102 113 } 103 else if ( $trigger_table == 3 ) $close_part = '</th>'; 104 else if ( $trigger_table == 2 ) $close_part = '</td>'; 105 else if ( $trigger_table == 1 ) $close_part = ''; 106 else $close_part = '<table class="wikka">'."\n"; 114 else if ( $trigger_table == 3 ) 115 { 116 $close_part = '</th>'; 117 } 118 else if ( $trigger_table == 2 ) 119 { 120 $close_part = '</td>'; 121 } 122 else if ( $trigger_table == 1 ) 123 { 124 $close_part = ''; 125 } 126 else 127 { 128 //This is actually opening the table (i.e. nothing at all to close). 129 $close_part = '<table class="wikka">'."\n"; 130 } 107 131 108 if ( $trigger_table > 1 && $matches[5] == "\n" ) { 132 if ( $trigger_table > 1 && $matches[5] == "\n" ) 133 { 109 134 $trigger_table = 1; 110 135 return $close_part .= '</tr>'."\n"; //Can return here, it is closed- 111 136 } 112 137 113 if ( $matches[1] == '!' ) { 138 if ( $matches[1] == '!' ) 139 { 114 140 $trigger_table = 4; 115 141 $open_part = '<caption>'; 116 } else { 117 if ( $trigger_table == 1 ) $open_part = '<tr>'; 118 else $open_part = ''; 119 120 if ( $matches[1] == '=' ) { 142 } 143 else if ( $matches[1] == '#' ) 144 { 145 //If we're here, we want to close any open rowgroup. 146 if (2 < $trigger_rowgroup) 147 { 148 $close_part .= '</tbody>'."\n"; 149 } 150 else if (1 < $trigger_rowgroup) 151 { 152 $close_part .= '</tfoot>'."\n"; 153 } 154 else if (0 < $trigger_rowgroup) 155 { 156 $close_part .= '</thead>'."\n"; 157 } 158 159 if ($matches[2] && ($matches[2] == 'h' || $matches[2] == 'f') ) 160 { 161 //thead or tfoot 162 if ($matches[2] == 'h') 163 { 164 $open_part .= '<thead>'."\n"; 165 $trigger_rowgroup = 1; 166 } 167 else if ($matches[2] == 'f') 168 { 169 $open_part .= '<tfoot>'."\n"; 170 $trigger_rowgroup = 2; 171 } 172 } 173 else 174 { 175 //tbody 176 $open_part .= '<tbody>'."\n"; 177 $trigger_rowgroup = 3; 178 } 179 } 180 else 181 { 182 $open_part = ''; 183 if ($trigger_rowgroup == 0) 184 { 185 $open_part .= '<tbody>'."\n"; 186 $trigger_rowgroup = 3; 187 } 188 189 if ( $trigger_table == 1 ) 190 { 191 $open_part .= '<tr>'; 192 } 193 194 if ( $matches[1] == '=' ) 195 { 121 196 $trigger_table = 3; 122 197 $open_part .= '<th'; 123 if ( $matches[2] ) { 124 if ( $matches[2] == 'c' ) $open_part .= ' scope="col"'; 125 else if ( $matches[2] == 'r' ) $open_part .= ' scope="row"'; 198 if ( $matches[2] ) 199 { 200 if ( $matches[2] == 'c' ) 201 { 202 $open_part .= ' scope="col"'; 203 } 204 else if ( $matches[2] == 'r' ) 205 { 206 $open_part .= ' scope="row"'; 126 207 } 127 } else { 208 } 209 } 210 else 211 { 128 212 $trigger_table = 2; 129 213 $open_part .= '<td'; 130 214 } 131 215 132 if ( $matches[3] && $matches[3] > 1 ) $open_part .= ' colspan="'.$matches[3].'"'; 133 if ( $matches[4] && $matches[4] > 1 ) $open_part .= ' rowspan="'.$matches[4].'"'; 134 216 if ( $matches[3] && $matches[3] > 1 ) 217 { 218 $open_part .= ' colspan="'.$matches[3].'"'; 219 } 220 221 if ( $matches[4] && $matches[4] > 1 ) 222 { 223 $open_part .= ' rowspan="'.$matches[4].'"'; 224 } 135 225 $open_part .= '>'; 136 226 } 137 138 227 return $close_part . $open_part; 228 } 229 else if ( $trigger_table == 1 ) 230 { 231 //Are in table, no cell - but not asked to open new: please close and parse again. ;) 232 $close_part = ''; 233 if (2 < $trigger_rowgroup) 234 { 235 $close_part .= '</tbody>'."\n"; 236 } 237 else if (1 < $trigger_rowgroup) 238 { 239 $close_part .= '</tfoot>'."\n"; 240 } 241 else if (0 < $trigger_rowgroup) 242 { 243 $close_part .= '</thead>'."\n"; 244 } 139 245 140 } else if ( $trigger_table == 1 ) { 141 //Are in table, no cell - but not asked to open new: please close and parse again. ;) 142 $trigger_table = 0; 143 return "</table>\n".wakka2callback($things); 246 $close_part .= '</table>'."\n"; 247 248 $trigger_table = $trigger_rowgroup = 0; 249 250 return $close_part.wakka2callback($things); 144 251 } 145 252 // convert HTML thingies