Markdown: disabled atx-style header support
Rationale - collision with tag syntax: if #tag was first word in given line, the line was treated like header.
This commit is contained in:
parent
15486b6e9a
commit
be3b39bf42
1 changed files with 13 additions and 1 deletions
|
@ -27,6 +27,13 @@ class CustomMarkdown extends \Michelf\Markdown
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//disable atx-style headers
|
||||||
|
protected function _doHeaders_callback_atx($matches)
|
||||||
|
{
|
||||||
|
return $matches[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
//disable paragraph forming when using simple markdown
|
||||||
protected function formParagraphs($text)
|
protected function formParagraphs($text)
|
||||||
{
|
{
|
||||||
if ($this->simple)
|
if ($this->simple)
|
||||||
|
@ -56,6 +63,7 @@ class CustomMarkdown extends \Michelf\Markdown
|
||||||
return $parser->transform($text);
|
return $parser->transform($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//automatically form links out of http://(...) and www.(...)
|
||||||
protected function doAutoLinks2($text)
|
protected function doAutoLinks2($text)
|
||||||
{
|
{
|
||||||
$text = preg_replace_callback('{(?<!<)((https?|ftp):[^\'"><\s(){}]+)}i', [&$this, '_doAutoLinks_url_callback'], $text);
|
$text = preg_replace_callback('{(?<!<)((https?|ftp):[^\'"><\s(){}]+)}i', [&$this, '_doAutoLinks_url_callback'], $text);
|
||||||
|
@ -63,6 +71,7 @@ class CustomMarkdown extends \Michelf\Markdown
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//extend anchors callback for doAutolinks2
|
||||||
protected function _doAnchors_inline_callback($matches)
|
protected function _doAnchors_inline_callback($matches)
|
||||||
{
|
{
|
||||||
if ($matches[3] == '')
|
if ($matches[3] == '')
|
||||||
|
@ -74,6 +83,8 @@ class CustomMarkdown extends \Michelf\Markdown
|
||||||
return parent::_doAnchors_inline_callback($matches);
|
return parent::_doAnchors_inline_callback($matches);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//handle white characters inside code blocks
|
||||||
|
//so that they won't be optimized away by prettifying HTML
|
||||||
protected function _doCodeBlocks_callback($matches) {
|
protected function _doCodeBlocks_callback($matches) {
|
||||||
$codeblock = $matches[1];
|
$codeblock = $matches[1];
|
||||||
|
|
||||||
|
@ -89,7 +100,8 @@ class CustomMarkdown extends \Michelf\Markdown
|
||||||
return "\n\n".$this->hashBlock($codeblock)."\n\n";
|
return "\n\n".$this->hashBlock($codeblock)."\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//change hard breaks trigger - simple \n followed by text
|
||||||
|
//instead of two spaces followed by \n
|
||||||
protected function doHardBreaks($text)
|
protected function doHardBreaks($text)
|
||||||
{
|
{
|
||||||
return preg_replace_callback('/\n(?=[\[\]\(\)\w])/', [&$this, '_doHardBreaks_callback'], $text);
|
return preg_replace_callback('/\n(?=[\[\]\(\)\w])/', [&$this, '_doHardBreaks_callback'], $text);
|
||||||
|
|
Loading…
Reference in a new issue