function MarkdownExtra_Parser::doDefLists in Markdown 5
Same name and namespace in other branches
- 6 markdown.php \MarkdownExtra_Parser::doDefLists()
File
- ./
markdown.php, line 2375
Class
Code
function doDefLists($text) {
#
# Form HTML definition lists.
#
$less_than_tab = $this->tab_width - 1;
# Re-usable pattern to match any entire dl list:
$whole_list_re = '(?>
( # $1 = whole list
( # $2
[ ]{0,' . $less_than_tab . '}
((?>.*\\S.*\\n)+) # $3 = defined term
\\n?
[ ]{0,' . $less_than_tab . '}:[ ]+ # colon starting definition
)
(?s:.+?)
( # $4
\\z
|
\\n{2,}
(?=\\S)
(?! # Negative lookahead for another term
[ ]{0,' . $less_than_tab . '}
(?: \\S.*\\n )+? # defined term
\\n?
[ ]{0,' . $less_than_tab . '}:[ ]+ # colon starting definition
)
(?! # Negative lookahead for another definition
[ ]{0,' . $less_than_tab . '}:[ ]+ # colon starting definition
)
)
)
)';
// mx
$text = preg_replace_callback('{
(?>\\A\\n?|(?<=\\n\\n))
' . $whole_list_re . '
}mx', array(
&$this,
'_doDefLists_callback',
), $text);
return $text;
}