diff --git a/CHANGELOG.md b/CHANGELOG.md index cd6c12ac01..fd987eae6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Fixed -- Nothing yet. +- Add support for `` tag when converting HTML to RichText. [Issue #4223](https://github.com/PHPOffice/PhpSpreadsheet/issues/4223) [PR #4224](https://github.com/PHPOffice/PhpSpreadsheet/pull/4224) ## 2024-11-10 - 3.4.0 diff --git a/src/PhpSpreadsheet/Helper/Html.php b/src/PhpSpreadsheet/Helper/Html.php index e690ae6525..f9fc6e3dc2 100644 --- a/src/PhpSpreadsheet/Helper/Html.php +++ b/src/PhpSpreadsheet/Helper/Html.php @@ -561,6 +561,7 @@ class Html 'u' => [self::class, 'startUnderlineTag'], 'ins' => [self::class, 'startUnderlineTag'], 'del' => [self::class, 'startStrikethruTag'], + 's' => [self::class, 'startStrikethruTag'], 'sup' => [self::class, 'startSuperscriptTag'], 'sub' => [self::class, 'startSubscriptTag'], ]; @@ -575,6 +576,7 @@ class Html 'u' => [self::class, 'endUnderlineTag'], 'ins' => [self::class, 'endUnderlineTag'], 'del' => [self::class, 'endStrikethruTag'], + 's' => [self::class, 'endStrikethruTag'], 'sup' => [self::class, 'endSuperscriptTag'], 'sub' => [self::class, 'endSubscriptTag'], 'br' => [self::class, 'breakTag'], diff --git a/tests/PhpSpreadsheetTests/Helper/HtmlTest.php b/tests/PhpSpreadsheetTests/Helper/HtmlTest.php index 784eb4c551..26f22847a1 100644 --- a/tests/PhpSpreadsheetTests/Helper/HtmlTest.php +++ b/tests/PhpSpreadsheetTests/Helper/HtmlTest.php @@ -48,4 +48,26 @@ public function testLiTag(): void self::assertSame($expected, $actual->getPlainText()); } + + public function testSTag(): void + { + $html = new Html(); + $input = 'Hello testworld'; + $richText = $html->toRichTextObject($input); + $elements = $richText->getRichTextElements(); + + self::assertSame(count($elements), 3); + + self::assertSame($elements[0]->getText(), 'Hello '); + self::assertNotNull($elements[0]->getFont()); + self::assertFalse($elements[0]->getFont()->getStrikethrough()); + + self::assertSame($elements[1]->getText(), 'test'); + self::assertNotNull($elements[1]->getFont()); + self::assertTrue($elements[1]->getFont()->getStrikethrough()); + + self::assertSame($elements[2]->getText(), 'world'); + self::assertNotNull($elements[2]->getFont()); + self::assertFalse($elements[2]->getFont()->getStrikethrough()); + } }