4d73cee038820524946eb4a262ce09f1f3236173
[atutor.git] / mods / wiki / plugins / markup / table_colspan.php
1 <?php
2
3 /*
4    This markup extension, allows for following syntax to merge
5    neighboured table cells together:
6
7    | col1 | col2 | col3 |
8    | col2 || col2 and 3 |
9    ||| this occoupies the whole row |
10    | col1 | col2 | col3 |
11 */
12
13
14 $ewiki_plugins["format_final"][] = "ewiki_table_colspan";
15 function ewiki_table_colspan(&$html) {
16    $html = preg_replace(
17       '#(<td></td>\s*)+<td#e',
18       '"<td colspan=\"" . (1+((int)(strlen(preg_replace("/\s+/","","$0"))-3)/9)) . "\""',
19       $html
20    );
21 }
22
23 ?>