diff --git a/syntax/table.php b/syntax/table.php index fd4e5cb..1d41d62 100644 --- a/syntax/table.php +++ b/syntax/table.php @@ -87,6 +87,7 @@ function handle($match, $state, $pos, Doku_Handler $handler) { 'sepbyheaders' => false, 'headers' => array(), 'widths' => array(), + 'format' => array(), 'filter' => array() ); @@ -138,6 +139,13 @@ function handle($match, $state, $pos, Doku_Handler $handler) { $data['align'][] = $col; } break; + case 'format': + $cols = explode(',', $line[1]); + foreach($cols as $col) { + $col = trim($col); + $data['format'][] = $col; + } + break; case 'widths': $cols = explode(',', $line[1]); foreach($cols as $col) { @@ -301,6 +309,12 @@ function render($format, Doku_Renderer $R, $data) { foreach(array_values($row) as $num => $cval) { $num_rn = $num + $offset; + $sformat = $data['format'][$num]; + if ($sformat != ""){ + # format a numeric column + $cval = number_format($cval,$sformat); + } + $R->doc .= sprintf($this->beforeVal($data, $num_rn), 'class="' . $classes[$num_rn] . '"'); $R->doc .= $this->dthlp->_formatData( $data['cols'][$clist[$num]],