From d372419e4035758cfec1620de394c488cdaea516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?= Date: Fri, 3 Jan 2020 15:37:32 -0600 Subject: [PATCH 1/2] Allow rendering emojis when not surrounded by spaces --- .gitignore | 2 ++ src/EmojiParser.php | 13 ------------- tests/EmojiParserTest.php | 3 ++- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 81b9258..dc772a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ composer.lock phpunit.xml vendor +.idea +.phpunit.result.cache \ No newline at end of file diff --git a/src/EmojiParser.php b/src/EmojiParser.php index 2f9d50b..fc8de6b 100755 --- a/src/EmojiParser.php +++ b/src/EmojiParser.php @@ -75,11 +75,6 @@ public function parse(InlineParserContext $inlineContext): bool { $cursor = $inlineContext->getCursor(); - $previous = $cursor->peek(-1); - if ($previous !== null && $previous !== ' ') { - return false; - } - $saved = $cursor->saveState(); $cursor->advance(); @@ -92,14 +87,6 @@ public function parse(InlineParserContext $inlineContext): bool return false; } - $next = $cursor->peek(0); - - if ($next !== null && $next !== ' ') { - $cursor->restoreState($saved); - - return false; - } - $key = substr($handle, 0, -1); if ($this->map === null) { diff --git a/tests/EmojiParserTest.php b/tests/EmojiParserTest.php index 7b06d2f..4a0aaf4 100755 --- a/tests/EmojiParserTest.php +++ b/tests/EmojiParserTest.php @@ -30,9 +30,10 @@ public function provideRenderCases() [':+1:', '

+1

'], ['* :airplane:', ""], ['foo bar baz: lol', '

foo bar baz: lol

'], - [':+1:123', '

:+1:123

'], + [':+1:123', '

+1123

'], [':123123123:', '

:123123123:

'], [':+1 :', '

:+1 :

'], + [':+1::+1:', '

+1+1

'], [':8ball: :100:', '

8ball 100

'], ]; } From 2f7ce6636aac99722d92e3b3b42633c195ef6fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?= Date: Fri, 3 Jan 2020 16:58:16 -0600 Subject: [PATCH 2/2] Remove '.idea' from .gitignore --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index dc772a8..e17c7ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ composer.lock phpunit.xml vendor -.idea -.phpunit.result.cache \ No newline at end of file +.phpunit.result.cache