function MarkdownExtra_Parser::doHeaders in Markdown 6
Same name and namespace in other branches
- 5 markdown.php \MarkdownExtra_Parser::doHeaders()
Overrides Markdown_Parser::doHeaders
File
- ./
markdown.php, line 2595
Class
Code
function doHeaders($text) {
#
# Redefined to add id and class attribute support.
#
# 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;
}