You are here

protected function MarkdownExtra::processDefListItems in Express 8

* Process the contents of a single definition list, splitting it * into individual term and definition list items. *

Parameters

string $list_str: * @return string

1 call to MarkdownExtra::processDefListItems()
MarkdownExtra::_doDefLists_callback in vendor/michelf/php-markdown/Michelf/MarkdownExtra.php
* Callback for processing definition lists *

File

vendor/michelf/php-markdown/Michelf/MarkdownExtra.php, line 1316

Class

MarkdownExtra
Markdown Extra Parser Class

Namespace

Michelf

Code

protected function processDefListItems($list_str) {
  $less_than_tab = $this->tab_width - 1;

  // Trim trailing blank lines:
  $list_str = preg_replace("/\n{2,}\\z/", "\n", $list_str);

  // Process definition terms.
  $list_str = preg_replace_callback('{
			(?>\\A\\n?|\\n\\n+)						# leading line
			(									# definition terms = $1
				[ ]{0,' . $less_than_tab . '}	# leading whitespace
				(?!\\:[ ]|[ ])					# negative lookahead for a definition
												#   mark (colon) or more whitespace.
				(?> \\S.* \\n)+?					# actual term (not whitespace).	
			)			
			(?=\\n?[ ]{0,3}:[ ])					# lookahead for following line feed
												#   with a definition mark.
			}xm', array(
    $this,
    '_processDefListItems_callback_dt',
  ), $list_str);

  // Process actual definitions.
  $list_str = preg_replace_callback('{
			\\n(\\n+)?							# leading line = $1
			(									# marker space = $2
				[ ]{0,' . $less_than_tab . '}	# whitespace before colon
				\\:[ ]+							# definition mark (colon)
			)
			((?s:.+?))							# definition text = $3
			(?= \\n+ 							# stop at next definition mark,
				(?:								# next term or end of text
					[ ]{0,' . $less_than_tab . '} \\:[ ]	|
					<dt> | \\z
				)						
			)					
			}xm', array(
    $this,
    '_processDefListItems_callback_dd',
  ), $list_str);
  return $list_str;
}