mirror of
https://github.com/KnpLabs/KnpMarkdownBundle.git
synced 2024-06-29 02:40:10 +02:00
Merge pull request #45 from vierbergenlars/fix-nohtml
Use no_markup option of the parser itself
This commit is contained in:
commit
9ccca13101
|
@ -104,6 +104,9 @@ class MarkdownParser extends MarkdownExtra implements MarkdownParserInterface
|
||||||
if (!$this->features['entities'] && !$this->features['no_html']) {
|
if (!$this->features['entities'] && !$this->features['no_html']) {
|
||||||
$this->no_entities = true;
|
$this->no_entities = true;
|
||||||
}
|
}
|
||||||
|
if ($this->features['no_html']) {
|
||||||
|
$this->no_html = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,10 +114,6 @@ class MarkdownParser extends MarkdownExtra implements MarkdownParserInterface
|
||||||
*/
|
*/
|
||||||
public function transformMarkdown($text)
|
public function transformMarkdown($text)
|
||||||
{
|
{
|
||||||
if ($this->features['no_html']) {
|
|
||||||
$text = htmlspecialchars($text, ENT_NOQUOTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::transform($text);
|
return parent::transform($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,31 +241,4 @@ class MarkdownParser extends MarkdownExtra implements MarkdownParserInterface
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _doCodeBlocks_callback($matches)
|
|
||||||
{
|
|
||||||
$codeblock = $matches[1];
|
|
||||||
|
|
||||||
$codeblock = $this->outdent($codeblock);
|
|
||||||
if (!$this->features['no_html']) {
|
|
||||||
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
# trim leading newlines and trailing newlines
|
|
||||||
$codeblock = preg_replace('/\A\n+|\n+\z/', '', $codeblock);
|
|
||||||
$codeblock = "<pre><code>$codeblock\n</code></pre>";
|
|
||||||
|
|
||||||
return "\n\n".$this->hashBlock($codeblock)."\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function makeCodeSpan($code)
|
|
||||||
{
|
|
||||||
if (!$this->features['no_html']) {
|
|
||||||
$code = htmlspecialchars(trim($code), ENT_NOQUOTES);
|
|
||||||
}
|
|
||||||
#
|
|
||||||
# Create a code span markup for $code. Called from handleSpanToken.
|
|
||||||
#
|
|
||||||
return $this->hashPart("<code>$code</code>");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue