You are here

protected function Markdown::stripLinkDefinitions in Express 8

* Strips link definitions from text, stores the URLs and titles in * hash references *

Parameters

string $text: * @return string

1 method overrides Markdown::stripLinkDefinitions()
MarkdownExtra::stripLinkDefinitions in vendor/michelf/php-markdown/Michelf/MarkdownExtra.php
* Strips link definitions from text, stores the URLs and titles in * hash references. *

File

vendor/michelf/php-markdown/Michelf/Markdown.php, line 273

Class

Markdown
Markdown Parser Class

Namespace

Michelf

Code

protected function stripLinkDefinitions($text) {
  $less_than_tab = $this->tab_width - 1;

  // Link defs are in the form: ^[id]: url "optional title"
  $text = preg_replace_callback('{
							^[ ]{0,' . $less_than_tab . '}\\[(.+)\\][ ]?:	# id = $1
							  [ ]*
							  \\n?				# maybe *one* newline
							  [ ]*
							(?:
							  <(.+?)>			# url = $2
							|
							  (\\S+?)			# url = $3
							)
							  [ ]*
							  \\n?				# maybe one newline
							  [ ]*
							(?:
								(?<=\\s)			# lookbehind for whitespace
								["(]
								(.*?)			# title = $4
								[")]
								[ ]*
							)?	# title is optional
							(?:\\n+|\\Z)
			}xm', array(
    $this,
    '_stripLinkDefinitions_callback',
  ), $text);
  return $text;
}