function MarkdownExtra_Parser::doTables in Markdown 6
Same name and namespace in other branches
- 5 markdown.php \MarkdownExtra_Parser::doTables()
File
- ./markdown.php, line 2651
Class
- MarkdownExtra_Parser
Code
function doTables($text) {
$less_than_tab = $this->tab_width - 1;
$text = preg_replace_callback('
{
^ # Start of a line
[ ]{0,' . $less_than_tab . '} # Allowed whitespace.
[|] # Optional leading pipe (present)
(.+) \\n # $1: Header row (at least one pipe)
[ ]{0,' . $less_than_tab . '} # Allowed whitespace.
[|] ([ ]*[-:]+[-| :]*) \\n # $2: Header underline
( # $3: Cells
(?>
[ ]* # Allowed whitespace.
[|] .* \\n # Row content.
)*
)
(?=\\n|\\Z) # Stop at final double newline.
}xm', array(
&$this,
'_doTable_leadingPipe_callback',
), $text);
$text = preg_replace_callback('
{
^ # Start of a line
[ ]{0,' . $less_than_tab . '} # Allowed whitespace.
(\\S.*[|].*) \\n # $1: Header row (at least one pipe)
[ ]{0,' . $less_than_tab . '} # Allowed whitespace.
([-:]+[ ]*[|][-| :]*) \\n # $2: Header underline
( # $3: Cells
(?>
.* [|] .* \\n # Row content
)*
)
(?=\\n|\\Z) # Stop at final double newline.
}xm', array(
&$this,
'_DoTable_callback',
), $text);
return $text;
}