protected function Markdown::formParagraphs in Express 8
* Parse paragraphs * *
Parameters
string $text String to process in paragraphs: * @param boolean $wrap_in_p Whether paragraphs should be wrapped in <p> tags * @return string
2 calls to Markdown::formParagraphs()
- Markdown::runBasicBlockGamut in vendor/
michelf/ php-markdown/ Michelf/ Markdown.php - * Run block gamut tranformations, without hashing HTML blocks. This is * useful when HTML blocks are known to be already hashed, like in the first * whole-document pass. * *
- Markdown::_processListItems_callback in vendor/
michelf/ php-markdown/ Michelf/ Markdown.php - * List item parsing callback *
1 method overrides Markdown::formParagraphs()
- MarkdownExtra::formParagraphs in vendor/
michelf/ php-markdown/ Michelf/ MarkdownExtra.php - * Parse text into paragraphs *
File
- vendor/
michelf/ php-markdown/ Michelf/ Markdown.php, line 1482
Class
- Markdown
- Markdown 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) {
if (!preg_match('/^B\\x1A[0-9]+B$/', $value)) {
// Is a paragraph.
$value = $this
->runSpanGamut($value);
if ($wrap_in_p) {
$value = preg_replace('/^([ ]*)/', "<p>", $value);
$value .= "</p>";
}
$grafs[$key] = $this
->unhash($value);
}
else {
// Is a block.
// Modify elements of @grafs in-place...
$graf = $value;
$block = $this->html_hashes[$graf];
$graf = $block;
// if (preg_match('{
// \A
// ( # $1 = <div> tag
// <div \s+
// [^>]*
// \b
// markdown\s*=\s* ([\'"]) # $2 = attr quote char
// 1
// \2
// [^>]*
// >
// )
// ( # $3 = contents
// .*
// )
// (</div>) # $4 = closing tag
// \z
// }xs', $block, $matches))
// {
// list(, $div_open, , $div_content, $div_close) = $matches;
//
// // We can't call Markdown(), because that resets the hash;
// // that initialization code should be pulled into its own sub, though.
// $div_content = $this->hashHTMLBlocks($div_content);
//
// // Run document gamut methods on the content.
// foreach ($this->document_gamut as $method => $priority) {
// $div_content = $this->$method($div_content);
// }
//
// $div_open = preg_replace(
// '{\smarkdown\s*=\s*([\'"]).+?\1}', '', $div_open);
//
// $graf = $div_open . "\n" . $div_content . "\n" . $div_close;
// }
$grafs[$key] = $graf;
}
}
return implode("\n\n", $grafs);
}