| @@ 19-45 (lines=27) @@ | ||
| 16 | * Parses strong element: ** ... ** |
|
| 17 | * @marker ** |
|
| 18 | */ |
|
| 19 | protected function parseStrong($text) |
|
| 20 | { |
|
| 21 | $pattern = <<< REGEXP |
|
| 22 | /^\*\*( |
|
| 23 | (.*?{{{.*?}}}.*?)+?| # including inline code span |
|
| 24 | (?!.*{{{.*?}}}).*? # without inline code span |
|
| 25 | )\*\*/sx |
|
| 26 | REGEXP; |
|
| 27 | if (preg_match($pattern, $text, $matches)) { |
|
| 28 | return [ |
|
| 29 | [ |
|
| 30 | 'strong', |
|
| 31 | $this->parseInline($matches[1]) |
|
| 32 | ], |
|
| 33 | strlen($matches[0]) |
|
| 34 | ]; |
|
| 35 | } else { |
|
| 36 | // no ending ** ... should be treated as strong |
|
| 37 | return [ |
|
| 38 | [ |
|
| 39 | 'strong', |
|
| 40 | $this->parseInline(substr($text, 2)) |
|
| 41 | ], |
|
| 42 | strlen($text) |
|
| 43 | ]; |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||
| 47 | /** |
|
| 48 | * Parses strong element: // ... // |
|
| @@ 51-79 (lines=29) @@ | ||
| 48 | * Parses strong element: // ... // |
|
| 49 | * @marker // |
|
| 50 | */ |
|
| 51 | protected function parseEmph($text) |
|
| 52 | { |
|
| 53 | // must take care of code elements, 'http://', 'https://', and 'ftp://' |
|
| 54 | $pattern = <<< REGEXP |
|
| 55 | /^\/\/( |
|
| 56 | (.*?{{{.*?}}}.*?)+?| # including inline code span |
|
| 57 | ((?!.*{{{.*?}}}).*?) # without inline code span |
|
| 58 | )(?<!http:|(?<=h)ttps:|(?<=f)tp:)\/\/(?!\/)/sx |
|
| 59 | REGEXP; |
|
| 60 | ||
| 61 | if (preg_match($pattern, $text, $matches)) { |
|
| 62 | return [ |
|
| 63 | [ |
|
| 64 | 'emph', |
|
| 65 | $this->parseInline($matches[1]) |
|
| 66 | ], |
|
| 67 | strlen($matches[0]) |
|
| 68 | ]; |
|
| 69 | } else { |
|
| 70 | // no ending // ... should be treated as em |
|
| 71 | return [ |
|
| 72 | [ |
|
| 73 | 'emph', |
|
| 74 | $this->parseInline(substr($text, 2)) |
|
| 75 | ], |
|
| 76 | strlen($text) |
|
| 77 | ]; |
|
| 78 | } |
|
| 79 | } |
|
| 80 | ||
| 81 | protected function renderStrong($block) |
|
| 82 | { |
|