function _FormParagraphs($text) { # # Params: # $text - string to process with html <p> tags # global $md_html_blocks; # Strip leading and trailing lines: $text = preg_replace(array('/\\A\\n+/', '/\\n+\\z/'), '', $text); $grafs = preg_split('/\\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY); # # Wrap <p> tags. # foreach ($grafs as $key => $value) { if (!isset($md_html_blocks[$value])) { $value = _RunSpanGamut($value); $value = preg_replace('/^([ \\t]*)/', '<p>', $value); $value .= "</p>"; $grafs[$key] = $value; } } # # Unhashify HTML blocks # foreach ($grafs as $key => $value) { if (isset($md_html_blocks[$value])) { $grafs[$key] = $md_html_blocks[$value]; } } return implode("\n\n", $grafs); }
function _FormParagraphs($text) { global $g_html_blocks; # Strip leading and trailing lines: $text = preg_replace(array('/\\A\\n+/', '/\\n+\\z/'), '', $text); $grafs = preg_split('/\\n{2,}/', $text); $count = count($graph); foreach ($grafs as $key => $value) { if (!isset($g_html_blocks[$value])) { $value = _RunSpanGamut($value); $value = preg_replace('/^([ \\t]*)/', '<p>', $value); $value .= "</p>"; $grafs[$key] = $value; } } foreach ($grafs as $key => $value) { if (isset($g_html_blocks[$value])) { $grafs[$key] = $g_html_blocks[$value]; } } return implode("\n\n", $grafs); }
function _FormParagraphs($text) { # # Params: # $text - string to process with html <p> tags # global $md_html_blocks, $md_html_hashes; # Strip leading and trailing lines: $text = preg_replace(array('/\\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(_RunSpanGamut($value)); # Check if this should be enclosed in a paragraph. # Text equaling to a clean tag hash are not enclosed. # Text starting with a block tag hash are not either. $clean_key = $value; $block_key = substr($value, 0, 32); $is_p = !isset($md_html_blocks[$block_key]) && !isset($md_html_hashes[$clean_key]); 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 = _UnhashTags($text); return $text; }