| @@ 149-155 (lines=7) @@ | ||
| 146 | protected function parseInlineHtml($text) |
|
| 147 | { |
|
| 148 | if (strpos($text, '>') !== false) { |
|
| 149 | if (preg_match('~^</?(\w+\d?)( .*?)?>~s', $text, $matches)) { |
|
| 150 | // HTML tags |
|
| 151 | return [['inlineHtml', $matches[0]], strlen($matches[0])]; |
|
| 152 | } elseif (preg_match('~^<!--.*?-->~s', $text, $matches)) { |
|
| 153 | // HTML comments |
|
| 154 | return [['inlineHtml', $matches[0]], strlen($matches[0])]; |
|
| 155 | } |
|
| 156 | } |
|
| 157 | return [['text', '<'], 1]; |
|
| 158 | } |
|
| @@ 21-37 (lines=17) @@ | ||
| 18 | */ |
|
| 19 | protected function parseInlineCode($text) |
|
| 20 | { |
|
| 21 | if (preg_match('/^(``+)\s(.+?)\s\1/s', $text, $matches)) { // code with enclosed backtick |
|
| 22 | return [ |
|
| 23 | [ |
|
| 24 | 'inlineCode', |
|
| 25 | $matches[2], |
|
| 26 | ], |
|
| 27 | strlen($matches[0]) |
|
| 28 | ]; |
|
| 29 | } elseif (preg_match('/^`(.+?)`/s', $text, $matches)) { |
|
| 30 | return [ |
|
| 31 | [ |
|
| 32 | 'inlineCode', |
|
| 33 | $matches[1], |
|
| 34 | ], |
|
| 35 | strlen($matches[0]) |
|
| 36 | ]; |
|
| 37 | } |
|
| 38 | return [['text', $text[0]], 1]; |
|
| 39 | } |
|
| 40 | ||
| @@ 172-184 (lines=13) @@ | ||
| 169 | { |
|
| 170 | if (strpos($text, '>') !== false) { |
|
| 171 | if (!in_array('parseLink', $this->context)) { // do not allow links in links |
|
| 172 | if (preg_match('/^<([^\s>]*?@[^\s]*?\.\w+?)>/', $text, $matches)) { |
|
| 173 | // email address |
|
| 174 | return [ |
|
| 175 | ['email', $this->replaceEscape($matches[1])], |
|
| 176 | strlen($matches[0]) |
|
| 177 | ]; |
|
| 178 | } elseif (preg_match('/^<([a-z]{3,}:\/\/[^\s]+?)>/', $text, $matches)) { |
|
| 179 | // URL |
|
| 180 | return [ |
|
| 181 | ['url', $this->replaceEscape($matches[1])], |
|
| 182 | strlen($matches[0]) |
|
| 183 | ]; |
|
| 184 | } |
|
| 185 | } |
|
| 186 | // try inline HTML if it was neither a URL nor email if HtmlTrait is included. |
|
| 187 | if (method_exists($this, 'parseInlineHtml')) { |
|