Skip to content

Commit

Permalink
Emoji: added support for textual codepoint sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Jan 1, 2018
1 parent f31b098 commit efdcb8f
Show file tree
Hide file tree
Showing 6 changed files with 8,938 additions and 3 deletions.
7 changes: 6 additions & 1 deletion scripts/patchEmoji.php
Expand Up @@ -83,8 +83,13 @@
{
echo bin2hex($utf8), " does not contain 0xE2, 0xEF or 0xF0. Parser.php would need to be updated.\n";
}
$seq = utf8ToSeq($utf8);

$allText .= $utf8 . "\n";
$allXml .= '<EMOJI seq="' . utf8ToSeq($utf8) . '">' . $utf8 . "</EMOJI>\n";
$allXml .= '<EMOJI seq="' . $seq . '">' . $utf8 . "</EMOJI>\n";

$allText .= ':' . $seq . ":\n";
$allXml .= '<EMOJI seq="' . $seq . '">:' . $seq . ":</EMOJI>\n";
}
$allXml .= '</r>';

Expand Down
7 changes: 6 additions & 1 deletion src/Plugins/Emoji/Parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/Plugins/Emoji/Parser.php
Expand Up @@ -136,9 +136,14 @@ protected function parseAsciiEmoji($text)
foreach ($matches[0] as list($shortName, $tagPos))
{
$shortName = substr($shortName, 1);
$tagLen = 2 + strlen($shortName);
if (isset(self::$map[$shortName]))
{
$this->addTag($tagPos, 2 + strlen($shortName), self::$map[$shortName]);
$this->addTag($tagPos, $tagLen, self::$map[$shortName]);
}
elseif (preg_match('/^[0-3][0-9a-f]{3,4}(?:-[0-9a-f]{4,5})*$/', $shortName))
{
$this->addTag($tagPos, $tagLen, preg_replace('/-(?:200d|fe0f)/', '', $shortName));
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Plugins/Emoji/ParserTest.php
Expand Up @@ -129,6 +129,10 @@ function ($configurator, $plugin)
'👩‍❤️‍👨',
'<r><EMOJI seq="1f469-2764-1f468">&#128105;‍❤️‍&#128104;</EMOJI></r>'
],
[
':00a9: :1f1ef-1f1f5: :1f468-200d-2764-fe0f-200d-1f468:',
'<r><EMOJI seq="00a9">:00a9:</EMOJI> <EMOJI seq="1f1ef-1f1f5">:1f1ef-1f1f5:</EMOJI> <EMOJI seq="1f468-2764-1f468">:1f468-200d-2764-fe0f-200d-1f468:</EMOJI></r>'
],
[
file_get_contents(__DIR__ . '/all.txt'),
file_get_contents(__DIR__ . '/all.xml'),
Expand Down

0 comments on commit efdcb8f

Please sign in to comment.