diff --git a/Michelf/Markdown.php b/Michelf/Markdown.php index c5245fdc..2419a4fa 100644 --- a/Michelf/Markdown.php +++ b/Michelf/Markdown.php @@ -2564,6 +2564,7 @@ protected function doTables($text) { [|] .* \n # Row content. )* ) + ('.$this->id_class_attr_catch_re.')? # $4 = id/class attributes (?=\n|\Z) # Stop at final double newline. }xm', array($this, '_doTable_leadingPipe_callback'), $text); @@ -2590,9 +2591,10 @@ protected function doTables($text) { .* [|] .* \n # Row content )* ) + ('.$this->id_class_attr_catch_re.')? # $4 = id/class attributes (?=\n|\Z) # Stop at final double newline. }xm', - array($this, '_DoTable_callback'), $text); + array($this, '_doTable_callback'), $text); return $text; } @@ -2600,11 +2602,12 @@ protected function _doTable_leadingPipe_callback($matches) { $head = $matches[1]; $underline = $matches[2]; $content = $matches[3]; + $attrs = (isset($matches[4])) ? $matches[4] : null; # Remove leading pipe for each row. $content = preg_replace('/^ *[|]/m', '', $content); - return $this->_doTable_callback(array($matches[0], $head, $underline, $content)); + return $this->_doTable_callback(array($matches[0], $head, $underline, $content, $attrs)); } protected function _doTable_makeAlignAttr($alignname) { @@ -2618,6 +2621,7 @@ protected function _doTable_callback($matches) { $head = $matches[1]; $underline = $matches[2]; $content = $matches[3]; + $attrs = (isset($matches[4])) ? $matches[4] : null; # Remove any tailing pipes for each line. $head = preg_replace('/[|] *$/m', '', $head); @@ -2645,7 +2649,9 @@ protected function _doTable_callback($matches) { $attr = array_pad($attr, $col_count, ''); # Write column headers. - $text = "\n"; + $text = "doExtraAttributes('', $matches[4]) : ''; + $text .= ">\n"; $text .= "\n"; $text .= "\n"; foreach ($headers as $n => $header)