/** * @param ContextInterface $context * @param InlineParserContext $inlineContext * * @return bool */ public function parse(ContextInterface $context, InlineParserContext $inlineContext) { if ($m = $inlineContext->getCursor()->match(RegexHelper::REGEX_ENTITY)) { $inlineContext->getInlines()->add(new Text(Html5Entities::decodeEntity($m))); return true; } return false; }
/** * @param InlineParserContext $inlineContext * * @return bool */ public function parse(InlineParserContext $inlineContext) { if ($m = $inlineContext->getCursor()->match('/^' . RegexHelper::REGEX_ENTITY . '/i')) { $inlineContext->getContainer()->appendChild(new Text(Html5Entities::decodeEntity($m))); return true; } return false; }
/** * Replace backslash escapes with literal characters * * @param string $string * * @return string */ public static function unescape($string) { $allEscapedChar = '/\\\\(' . self::REGEX_ESCAPABLE . ')/'; $escaped = preg_replace($allEscapedChar, '$1', $string); $replaced = preg_replace_callback('/' . self::REGEX_ENTITY . '/i', function ($e) { return Html5Entities::decodeEntity($e[0]); }, $escaped); return $replaced; }