'noscript'
);
+ /**
+ * Map of link IDs to their link
+ * @var string
+ */
+ private $linkMap = array();
+
// ###################################################################
/**
* Quick parsing function that uses the system defaults for parsing.
$this->text = preg_replace('/^\s*?$/m', '', $this->text);
$this->_extractHtmlBlocks();
+ $this->_extractLinkMap();
$this->_convertHardLineBreaks();
$this->_convertAtxHeaders();
return str_replace(array_keys($this->htmlBlockMap), array_values($this->htmlBlockMap), $text);
}
+ // ###################################################################
+ /**
+ * Extracts all links in the "[id]: link" form
+ */
+ public function _extractLinkMap()
+ {
+ $this->text = preg_replace_callback('/\[(\w+)\]:\s*<?(\S+)>?(\s*(("|\')|\()(.*?)(\4|\)))?\n?/', array(&$this, '_extractLinkMapCallback'), $this->text);
+ }
+
+ // ###################################################################
+ /**
+ * Converts extracted link definitions into the map
+ *
+ * @param array Matches array
+ */
+ private function _extractLinkMapCallback($matches)
+ {
+ $this->linkMap[$matches[1]] = array($matches[2], $matches[6]);
+ }
+
// ###################################################################
/**
* Converts text surrounded by #sings to headers (## Heading 2)
*/
private function _convertAtxHeadersCallback($matches)
{
- var_dump($matches);
+ // var_dump($matches);
$html = '<h' . strlen($matches[1]) . '>' . $this->_expandHtmlBlocks($matches[2]) . '</h' . strlen($matches[1]) . '>';
$hash = md5($html . microtime());
$this->htmlBlockMap[$hash] = $html;