_MarkdownExtra_TmpImpl::formParagraphs PHP Method

formParagraphs() protected method

protected formParagraphs ( $text )
    protected function formParagraphs($text)
    {
        #
        #	Params:
        #		$text - string to process with html <p> tags
        #
        # 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 = !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;
    }