protected function MarkdownExtra::formParagraphs in Express 8
* Parse text into paragraphs *
Parameters
string $text String to process in paragraphs: * @param boolean $wrap_in_p Whether paragraphs should be wrapped in <p> tags * @return string HTML output
Overrides Markdown::formParagraphs
File
- vendor/
michelf/ php-markdown/ Michelf/ MarkdownExtra.php, line 1512
Class
- MarkdownExtra
- Markdown Extra Parser Class
Namespace
MichelfCode
protected function formParagraphs($text, $wrap_in_p = true) {
// Strip leading and trailing lines:
$text = preg_replace('/\\A\\n+|\\n+\\z/', '', $text);
$grafs = preg_split('/\\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY);
// Wrap <p> tags and unhashify HTML blocks
foreach ($grafs as $key => $value) {
$value = trim($this
->runSpanGamut($value));
// Check if this should be enclosed in a paragraph.
// Clean tag hashes & block tag hashes are left alone.
$is_p = $wrap_in_p && !preg_match('/^B\\x1A[0-9]+B|^C\\x1A[0-9]+C$/', $value);
if ($is_p) {
$value = "<p>{$value}</p>";
}
$grafs[$key] = $value;
}
// Join grafs in one text, then unhash HTML tags.
$text = implode("\n\n", $grafs);
// Finish by removing any tag hashes still present in $text.
$text = $this
->unhash($text);
return $text;
}