no_markup = true; $this->span_gamut += ['doSpoilers' => 71]; $this->span_gamut += ['doPosts' => 8]; $this->span_gamut += ['doTags' => 9]; $this->span_gamut += ['doAutoLinks2' => 29]; //fix italics/bold in the middle of sentence $prop = ['em_relist', 'strong_relist', 'em_strong_relist']; for ($i = 0; $i < 3; $i ++) { $this->{$prop[$i]}[''] = '(?:(?{$prop[$i]}[str_repeat('*', $i + 1)] = '(?<=\S|^)(?{$prop[$i]}[str_repeat('_', $i + 1)] = '(?<=\S|^)(?<\s]+)}i', [&$this, '_doAutoLinks_url_callback'], $text); $text = preg_replace_callback('{(?<\s]+)}i', [&$this, '_doAutoLinks_url_callback'], $text); return $text; } protected function _doAnchors_inline_callback($matches) { if ($matches[3] == '') $url = &$matches[4]; else $url = &$matches[3]; if (!preg_match('/^((https?|ftp):|)\/\//', $url)) $url = 'http://' . $url; return parent::_doAnchors_inline_callback($matches); } protected function doHardBreaks($text) { return preg_replace_callback('/\n/', [&$this, '_doHardBreaks_callback'], $text); } protected function doSpoilers($text) { if (is_array($text)) $text = $this->hashPart('') . $text[1] . $this->hashPart(''); return preg_replace_callback('{\[spoiler\]((?:[^\[]|\[(?!\/?spoiler\])|(?R))+)\[\/spoiler\]}is', [__CLASS__, 'doSpoilers'], $text); } protected function doPosts($text) { return preg_replace_callback('/(?:(?hashPart('') . $x[0] . $this->hashPart(''); }, $text); } protected function doTags($text) { return preg_replace_callback('/(?:(?hashPart('') . $x[0] . $this->hashPart(''); }, $text); } }