diff --git a/CHANGELOG.md b/CHANGELOG.md index 579e7aeea2..4e0d52eec1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ HumHub Changelog ---------------------- - Fix #5822: Fix content width in mobile view - Fix #5825: Fix format date to mysql on date stream filter +- Fix #5814: Fix numerated lists in mail summary content - Fix #5830: Fix cron job of search index rebuilding 1.12.0 (July 27, 2022) diff --git a/protected/humhub/modules/content/tests/codeception/unit/widgets/RichTextShortTextConverterTest.php b/protected/humhub/modules/content/tests/codeception/unit/widgets/RichTextShortTextConverterTest.php index bf9fdfae51..61ede0d81c 100644 --- a/protected/humhub/modules/content/tests/codeception/unit/widgets/RichTextShortTextConverterTest.php +++ b/protected/humhub/modules/content/tests/codeception/unit/widgets/RichTextShortTextConverterTest.php @@ -522,6 +522,17 @@ class RichTextShortTextConverterTest extends HumHubDbTestCase "This is a list 1. First Element 2. Second Element"); } + public function testConvertOrderedListWithCustomNumbers() + { + $this->assertConversionResult( + "This is a list\n\n21. November - First line\n22. November - Second line\n23. November - Third line", + 'This is a list 21. November - First line 22. November - Second line 23. November - Third line'); + + $this->assertConversionResult( + "This is a list\n\n29. November - First line\n24. November - Second line\n15. November - Third line", + 'This is a list 29. November - First line 24. November - Second line 15. November - Third line'); + } + public function testConvertOrderedSubList() { $this->assertConversionResult( diff --git a/protected/humhub/modules/content/widgets/richtext/converter/BaseRichTextConverter.php b/protected/humhub/modules/content/widgets/richtext/converter/BaseRichTextConverter.php index f4b1661634..8ce1175359 100644 --- a/protected/humhub/modules/content/widgets/richtext/converter/BaseRichTextConverter.php +++ b/protected/humhub/modules/content/widgets/richtext/converter/BaseRichTextConverter.php @@ -539,4 +539,24 @@ REGEXP; { return preg_replace('/\/i', "\n", $text); } -} + + /** + * @inheritdoc + */ + protected function consumeOl($lines, $current) + { + $result = parent::consumeOl($lines, $current); + + if (is_array($lines) && count($lines) > 0 && !empty($result[0]['items'])) { + $result[0]['origNums'] = []; + $i = array_keys($result[0]['items'])[0]; + foreach ($lines as $line) { + if (preg_match('/^(\d+)\./', $line, $num)) { + $result[0]['origNums'][$i++] = $num[1]; + } + } + } + + return $result; + } +} \ No newline at end of file diff --git a/protected/humhub/modules/content/widgets/richtext/converter/RichTextToMarkdownConverter.php b/protected/humhub/modules/content/widgets/richtext/converter/RichTextToMarkdownConverter.php index a722435711..f6bd103868 100644 --- a/protected/humhub/modules/content/widgets/richtext/converter/RichTextToMarkdownConverter.php +++ b/protected/humhub/modules/content/widgets/richtext/converter/RichTextToMarkdownConverter.php @@ -178,7 +178,7 @@ class RichTextToMarkdownConverter extends BaseRichTextConverter unset( $line ); $output .= $level !== 0 ? "\n".str_repeat(' ', $level * 3) : ''; - $output .= $block['list'] === 'ol' ? ++$count.'. ' : '- '; + $output .= $block['list'] === 'ol' ? (isset($block['origNums'][$item]) ? $block['origNums'][$item] : ++$count).'. ' : '- '; $output .= $this->renderAbsy($itemLines). ($level === 0 ? "\n" : ''); }