@@ 48-65 (lines=18) @@ | ||
45 | * @param string $text the text to parse |
|
46 | * @return string parsed markup |
|
47 | */ |
|
48 | public function parse($text) |
|
49 | { |
|
50 | $this->prepare(); |
|
51 | ||
52 | if (ltrim($text) === '') { |
|
53 | return ''; |
|
54 | } |
|
55 | ||
56 | $text = str_replace(["\r\n", "\n\r", "\r"], "\n", $text); |
|
57 | ||
58 | $this->prepareMarkers($text); |
|
59 | ||
60 | $absy = $this->parseBlocks(explode("\n", $text)); |
|
61 | $markup = $this->renderAbsy($absy); |
|
62 | ||
63 | $this->cleanup(); |
|
64 | return $markup; |
|
65 | } |
|
66 | ||
67 | /** |
|
68 | * Parses a paragraph without block elements (block elements are ignored). |
|
@@ 73-90 (lines=18) @@ | ||
70 | * @param string $text the text to parse |
|
71 | * @return string parsed markup |
|
72 | */ |
|
73 | public function parseParagraph($text) |
|
74 | { |
|
75 | $this->prepare(); |
|
76 | ||
77 | if (ltrim($text) === '') { |
|
78 | return ''; |
|
79 | } |
|
80 | ||
81 | $text = str_replace(["\r\n", "\n\r", "\r"], "\n", $text); |
|
82 | ||
83 | $this->prepareMarkers($text); |
|
84 | ||
85 | $absy = $this->parseInline($text); |
|
86 | $markup = $this->renderAbsy($absy); |
|
87 | ||
88 | $this->cleanup(); |
|
89 | return $markup; |
|
90 | } |
|
91 | ||
92 | /** |
|
93 | * This method will be called before `parse()` and `parseParagraph()`. |