protected function MarkdownExtra::doHeaders in Markdown 7
* Process markdown headers. Redefined to add ID and class attribute support. *
Parameters
string $text: * @return string
Overrides Markdown::doHeaders
File
- includes/
MarkdownExtra.php, line 1020
Class
- MarkdownExtra
- Markdown Extra Parser Class
Namespace
MichelfCode
protected function doHeaders($text) {
// Setext-style headers:
// Header 1 {#header1}
// ========
//
// Header 2 {#header2 .class1 .class2}
// --------
//
$text = preg_replace_callback('{
(^.+?) # $1: Header text
(?:[ ]+ ' . $this->id_class_attr_catch_re . ' )? # $3 = id/class attributes
[ ]*\\n(=+|-+)[ ]*\\n+ # $3: Header footer
}mx', array(
$this,
'_doHeaders_callback_setext',
), $text);
// atx-style headers:
// # Header 1 {#header1}
// ## Header 2 {#header2}
// ## Header 2 with closing hashes ## {#header3.class1.class2}
// ...
// ###### Header 6 {.class2}
//
$text = preg_replace_callback('{
^(\\#{1,6}) # $1 = string of #\'s
[ ]*
(.+?) # $2 = Header text
[ ]*
\\#* # optional closing #\'s (not counted)
(?:[ ]+ ' . $this->id_class_attr_catch_re . ' )? # $3 = id/class attributes
[ ]*
\\n+
}xm', array(
$this,
'_doHeaders_callback_atx',
), $text);
return $text;
}