diff options
-rw-r--r-- | data/wiki/syntax.txt | 14 | ||||
-rw-r--r-- | inc/parser.php | 20 | ||||
-rw-r--r-- | print.css | 14 | ||||
-rw-r--r-- | style.css | 15 |
4 files changed, 53 insertions, 10 deletions
diff --git a/data/wiki/syntax.txt b/data/wiki/syntax.txt index e315ceed7..ecb07133a 100644 --- a/data/wiki/syntax.txt +++ b/data/wiki/syntax.txt @@ -251,6 +251,20 @@ As you can see, it's the cell separator before a cell which decides about the fo Note: Vertical spans (rowspan) are not possible. +You can align the table contents, too. Just add at least two whitespaces at the opposite end of your text: Add two spaces on the left to align right, two spaces on the right to align left and two spaces at least at both ends for centered text. + +^ Table with alignment ^^^ +| right| center |left | +|left | right| center | +| xxxxxxxxxxxx | xxxxxxxxxxxx | xxxxxxxxxxxx | + +This is how it looks in the source: + + ^ Table with alignment ^^^ + | right| center |left | + |left | right| center | + | xxxxxxxxxxxx | xxxxxxxxxxxx | xxxxxxxxxxxx | + ===== Nonparsed Blocks ===== You can include non parsed blocks into your documents by either indenting them by at least two spaces (like used for the previous examples) or by using the tags ''code'' or ''file''. diff --git a/inc/parser.php b/inc/parser.php index f040d167e..73bbee765 100644 --- a/inc/parser.php +++ b/inc/parser.php @@ -596,6 +596,7 @@ function quoteformat($block){ * format inline tables * * @author Andreas Gohr <andi@splitbrain.org> + * @author Aaron Evans <aarone@klamathsystems.com> */ function tableformat($block) { $block = trim($block); @@ -630,7 +631,7 @@ function tableformat($block) { for ($c=0; $c < count($rows[$r]); $c++){ $cspan=1; - $data = trim($rows[$r][$c]['data']); + $data = $rows[$r][$c]['data']; $head = $rows[$r][$c]['head']; //join cells if next is empty @@ -644,15 +645,26 @@ function tableformat($block) { $cspan = ''; } + //determine alignment from whitespace + if (preg_match('/^\s\s/', $data)) { // right indentation + $td_class = "rightalign"; + if (preg_match('/\s\s$/', $data)) { // both left and right indentation + $td_class = "centeralign"; + } + } else { // left indentation (default) + $td_class = "leftalign"; + } + + $data = trim($data); if ($head) { - $ret .= " <th class=\"inline\" $cspan>$data</th>\n"; + $ret .= " <th class=\"$td_class\" $cspan>$data </th>\n"; // set css class for alignment } else { - $ret .= " <td class=\"inline\" $cspan>$data</td>\n"; + $ret .= " <td class=\"$td_class\" $cspan>$data </td>\n"; // set css class for alignment } } $ret .= " </tr>\n"; } - $ret .= "</table>\n<p>"; + $ret .= "</table><br />\n<p>"; return $ret; } @@ -197,19 +197,27 @@ table.inline { border-collapse: collapse; } -th.inline{ +table.inline th { padding: 3px; border: 1px solid #000000; border-bottom: 2px solid #000000; - text-align: left; } -td.inline{ +table.inline td { padding: 3px; border: 1px solid #000000; +} + +.leftalign{ text-align: left; } +.centeralign{ + text-align: center; +} +.rightalign{ + text-align: right; +} .toc, .footerinc, .header, .bar, .user {display:none} @@ -445,19 +445,28 @@ table.inline { border-collapse: collapse; } -th.inline{ +table.inline th { padding: 3px; border: 1px solid #8cacbb; background-color: #dee7ec; - text-align: left; } -td.inline{ +table.inline td { padding: 3px; border: 1px solid #8cacbb; +} + +.leftalign{ text-align: left; } +.centeralign{ + text-align: center; +} + +.rightalign{ + text-align: right; +} /* ---------- table of contents ------------------- */ |