3 * @copyright Copyright (c) 2014 Carsten Brandt
4 * @license https://github.com/cebe/markdown/blob/master/LICENSE
5 * @link https://github.com/cebe/markdown#readme
8 namespace cebe\markdown\inline;
11 * Adds inline emphasizes and strong elements
16 * Parses empathized and strong elements.
20 protected function parseEmphStrong($text)
24 if (!isset($text[1])) {
25 return [['text', $text[0]], 1];
28 if ($marker == $text[1]) { // strong
29 if ($marker == '*' && preg_match('/^[*]{2}((?:[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s', $text, $matches) ||
30 $marker == '_' && preg_match('/^__((?:[^_]|_[^_]*_)+?)__(?!_)/us', $text, $matches)) {
35 $this->parseInline($matches[1]),
41 if ($marker == '*' && preg_match('/^[*]((?:[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s', $text, $matches) ||
42 $marker == '_' && preg_match('/^_((?:[^_]|__[^_]*__)+?)_(?!_)\b/us', $text, $matches)) {
46 $this->parseInline($matches[1]),
52 return [['text', $text[0]], 1];
55 protected function renderStrong($block)
57 return '<strong>' . $this->renderAbsy($block[1]) . '</strong>';
60 protected function renderEmph($block)
62 return '<em>' . $this->renderAbsy($block[1]) . '</em>';