diff --git a/docs/changes/1.x/1.5.0.md b/docs/changes/1.x/1.5.0.md index bbe131d32f..2ad3c87859 100644 --- a/docs/changes/1.x/1.5.0.md +++ b/docs/changes/1.x/1.5.0.md @@ -4,6 +4,8 @@ ## Enhancements +- Allow setting list style while reading HTML as input + ### Bug fixes - Set writeAttribute return type by [@radarhere](https://github.com/radarhere) fixing [#2204](https://github.com/PHPOffice/PHPWord/issues/2204) in [#2776](https://github.com/PHPOffice/PHPWord/pull/2776) diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 170dc5dff3..27e69591b8 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -608,9 +608,15 @@ protected static function parseList($node, $element, &$styles, &$data) */ protected static function getListStyle($isOrderedList) { + $type = $isOrderedList ? 'multilevel' : 'hybridMultilevel'; + + if (isset(self::$options['LIST_STYLES'][$type])) { + return self::$options['LIST_STYLES'][$type]; + } + if ($isOrderedList) { return [ - 'type' => 'multilevel', + 'type' => $type, 'levels' => [ ['format' => NumberFormat::DECIMAL, 'text' => '%1.', 'alignment' => 'left', 'tabPos' => 720, 'left' => 720, 'hanging' => 360], ['format' => NumberFormat::LOWER_LETTER, 'text' => '%2.', 'alignment' => 'left', 'tabPos' => 1440, 'left' => 1440, 'hanging' => 360], @@ -626,7 +632,7 @@ protected static function getListStyle($isOrderedList) } return [ - 'type' => 'hybridMultilevel', + 'type' => $type, 'levels' => [ ['format' => NumberFormat::BULLET, 'text' => '•', 'alignment' => 'left', 'tabPos' => 720, 'left' => 720, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'], ['format' => NumberFormat::BULLET, 'text' => '◦', 'alignment' => 'left', 'tabPos' => 1440, 'left' => 1440, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'],