` tags. * * This feature is useful for comments where newlines are often * meant to be hard line breaks. */ public $enableNewlines = false; /** * @var boolean Whether to sanitize disallowed raw HTML tags. * * This toggles section 6.11 of the GFM specification on or off. */ public $disallowedRawHTML = true; /** * @var array Disallowed HTML elements defined in GFM spec * @see https://github.github.com/gfm/#disallowed-raw-html-extension- */ protected $disallowedRawHTMLElements = [ 'iframe', 'noembed', 'noframes', 'plaintext', 'script', 'style', 'title', 'textarea', 'xmp', ]; /** * @inheritDoc */ protected function consumeParagraph($lines, $current): array { $content = []; // Consume until blank line or end condition... for ($i = $current, $count = count($lines); $i < $count; $i++) { $line = $lines[$i]; if ( $line === '' || ($trimmed = ltrim($line)) === '' || ( (ctype_punct($trimmed[0]) || ctype_digit($trimmed[0])) && ( $this->identifyQuote($line, $lines, $i) || $this->identifyFencedCode($line, $lines, $i) || $this->identifyUl($line, $lines, $i) || $this->identifyOl($line, $lines, $i) || $this->identifyHr($line, $lines, $i) || $this->identifyHtml($line, $lines, $i) ) ) || $this->identifyHeadline($line, $lines, $i) ) { break; } else { $content[] = ltrim($line); } } $block = [ 'paragraph', 'content' => $this->parseInline(trim(implode("\n", $content))), ]; return [$block, --$i]; } /** * @inheritDoc * * Parses all newlines as hard line breaks if `enableNewlines` is set. */ protected function renderText($text): string { if ($this->enableNewlines) { $br = $this->html5 ? "
\n" : "
\n"; $text[1] = preg_replace("/ *\n/", $br, $text[1]); } return parent::renderText($text); } /** * @inheritDoc * * Sanitize disallowed raw HTML tags, then post-process markup. */ protected function postprocess($markup): string { if ($this->disallowedRawHTML) { $patterns = implode('|', $this->disallowedRawHTMLElements); $markup = preg_replace( "/<($patterns)(\s|>|\/>)/i", "<$1$2", $markup ); } return parent::postprocess($markup); } }