You are here

protected function MarkdownExtra::doDefLists in Markdown 7

* Form HTML definition lists. *

Parameters

string $text: * @return string

File

includes/MarkdownExtra.php, line 1254

Class

MarkdownExtra
Markdown Extra Parser Class

Namespace

Michelf

Code

protected function doDefLists($text) {
  $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;
}