You are here

function Markdown_Parser::doAutoLinks in Markdown 6

Same name and namespace in other branches
  1. 5 markdown.php \Markdown_Parser::doAutoLinks()

File

./markdown.php, line 1458

Class

Markdown_Parser

Code

function doAutoLinks($text) {
  $text = preg_replace_callback('{<((https?|ftp|dict):[^\'">\\s]+)>}i', array(
    &$this,
    '_doAutoLinks_url_callback',
  ), $text);

  # Email addresses: <address@domain.foo>
  $text = preg_replace_callback('{
			<
			(?:mailto:)?
			(
				(?:
					[-!#$%&\'*+/=?^_`.{|}~\\w\\x80-\\xFF]+
				|
					".*?"
				)
				\\@
				(?:
					[-a-z0-9\\x80-\\xFF]+(\\.[-a-z0-9\\x80-\\xFF]+)*\\.[a-z]+
				|
					\\[[\\d.a-fA-F:]+\\]	# IPv4 & IPv6
				)
			)
			>
			}xi', array(
    &$this,
    '_doAutoLinks_email_callback',
  ), $text);
  return $text;
}