PEAR2_Text_Markdown › PEAR2_Text_Markdown-0.1.0/php/PEAR2/Text/Markdown/Apidoc/Paragraph.php
- PEAR2_Text_Markdown-0.1.0/
- doc/
- pear2.php.net/
- PEAR2_Text_Markdown/
- examples/
- examples/
- examples/
- PEAR2_Text_Markdown/
- pear2.php.net/
- php/
- PEAR2/
- Autoload.php
- Exception.php
- MultiErrors/
- MultiErrors.php
- Text/
- Markdown/
- Apidoc/
- Apidoc.php
- Extra/
- Extra.php
- Main.php
- Plugin/
- Plugin.php
- Wiki/
- Wiki.php
- Markdown/
- PEAR2/
- doc/
- package.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
*
* Block plugin to form paragraphs of text with 2 newlines around it.
*
* @category Solar
*
* @package Markdown_Apidoc
*
* @author Paul M. Jones <pmjones@solarphp.com>
*
* @license http://opensource.org/licenses/bsd-license.php BSD
*
* @version $Id: Paragraph.php 4600 2010-06-16 03:27:55Z pmjones $
*
*/
namespace PEAR2\Text;
class Markdown_Apidoc_Paragraph extends Markdown_Plugin_Paragraph
{
/**
*
* Forms paragraphs from source text.
*
* @param string $text Portion of the Markdown source text.
*
* @return string The transformed XHTML.
*
*/
public function parse($text)
{
// // Strip leading and trailing lines:
// $text = preg_replace(array('/\A\n+/', '/\n+\z/'), '', $text);
// split into possible paragraphs
$grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY);
// Wrap <p> tags around apparent paragraphs.
foreach ($grafs as $key => $value) {
if (! $this->_isHtmlToken($value)) {
// not an HTML token, looks like a paragraph.
$value = $this->_processSpans($value);
$value = preg_replace('/^([ \t]*)/', '<para>', $value);
$value .= "</para>";
$grafs[$key] = $this->_toHtmlToken($value);
}
}
// done!
return implode("\n\n", $grafs);
}
}
EOF
