diff --git a/src/Entities.php b/src/Entities.php
index 8d3f0d7..f943b3f 100644
--- a/src/Entities.php
+++ b/src/Entities.php
@@ -316,6 +316,9 @@ final class Entities
'pre' => $node->hasAttribute('language')
? ['type' => 'pre', 'language' => $node->getAttribute('language')]
: ['type' => 'pre'],
+ 'span' => $node->hasAttribute('class') && $node->getAttribute('class') === 'tg-spoiler'
+ ? ['type' => 'spoiler']
+ : null,
'tg-emoji' => ['type' => 'custom_emoji', 'custom_emoji_id' => (int) $node->getAttribute('emoji-id')],
'emoji' => ['type' => 'custom_emoji', 'custom_emoji_id' => (int) $node->getAttribute('id')],
'a' => self::handleLink($node->getAttribute('href')),
@@ -384,7 +387,7 @@ final class Entities
"email" => '',
"phone" => '',
"mention" => '',
- "spoiler" => $allowTelegramTags ? '' : '',
+ "spoiler" => $allowTelegramTags ? '' : '',
"custom_emoji" => $allowTelegramTags ? '' : '',
"text_mention" => $allowTelegramTags ? '' : '',
default => '',
@@ -400,7 +403,7 @@ final class Entities
"strikethrough" => '',
"underline" => '',
"block_quote" => '',
- "spoiler" => $allowTelegramTags ? '' : '',
+ "spoiler" => $allowTelegramTags ? '' : '',
"custom_emoji" => $allowTelegramTags ? "" : '',
"text_mention" => $allowTelegramTags ? '' : '',
default => '',
diff --git a/tests/EntitiesTest.php b/tests/EntitiesTest.php
index 6922d62..1ba6213 100644
--- a/tests/EntitiesTest.php
+++ b/tests/EntitiesTest.php
@@ -262,7 +262,7 @@ class EntitiesTest extends TestCase
yield [
'test',
'test',
- 'test',
+ 'test',
[[
'type' => 'spoiler',
'offset' => 0,
@@ -618,6 +618,19 @@ class EntitiesTest extends TestCase
],
''"',
],
+ [
+ 'html',
+ 'spoiler',
+ 'spoiler',
+ [
+ [
+ 'offset' => 0,
+ 'length' => 7,
+ 'type' => 'spoiler',
+ ],
+ ],
+ 'spoiler',
+ ],
[
'html',
'mention1 mention2',