File tree Expand file tree Collapse file tree 2 files changed +27
-9
lines changed
src/PhpWord/Writer/HTML/Element
tests/PhpWord/Writer/HTML Expand file tree Collapse file tree 2 files changed +27
-9
lines changed Original file line number Diff line number Diff line change 1717
1818namespace PhpOffice \PhpWord \Writer \HTML \Element ;
1919
20- use PhpOffice \PhpWord \Settings ;
21-
2220/**
2321 * ListItem element HTML writer
2422 *
2523 * @since 0.10.0
2624 */
27- class ListItemRun extends ListItem
25+ class ListItemRun extends TextRun
2826{
2927 /**
3028 * Write list item
@@ -38,12 +36,7 @@ public function write()
3836 }
3937
4038 $ writer = new Container ($ this ->parentWriter , $ this ->element );
41-
42- if (Settings::isOutputEscapingEnabled ()) {
43- $ content = '<p> ' . $ this ->escaper ->escapeHtml ($ writer ->write ()) . '</p> ' . PHP_EOL ;
44- } else {
45- $ content = '<p> ' . $ writer ->write () . '</p> ' . PHP_EOL ;
46- }
39+ $ content = $ writer ->write () . PHP_EOL ;
4740
4841 return $ content ;
4942 }
Original file line number Diff line number Diff line change @@ -163,6 +163,31 @@ public function testWriteTitleTextRun()
163163 $ this ->assertContains ($ expected , $ content );
164164 }
165165
166+ /**
167+ * Test write element ListItemRun
168+ */
169+ public function testListItemRun ()
170+ {
171+ $ expected1 = 'List item run 1 ' ;
172+ $ expected2 = 'List item run 1 in bold ' ;
173+
174+ $ phpWord = new PhpWord ();
175+ $ section = $ phpWord ->addSection ();
176+
177+ $ listItemRun = $ section ->addListItemRun (0 , null , 'MyParagraphStyle ' );
178+ $ listItemRun ->addText ($ expected1 );
179+ $ listItemRun ->addText ($ expected2 , array ('bold ' => true ));
180+
181+ $ htmlWriter = new HTML ($ phpWord );
182+ $ content = $ htmlWriter ->getContent ();
183+
184+ $ dom = new \DOMDocument ();
185+ $ dom ->loadHTML ($ content );
186+
187+ $ this ->assertEquals ($ expected1 , $ dom ->getElementsByTagName ('p ' )->item (0 )->textContent );
188+ $ this ->assertEquals ($ expected2 , $ dom ->getElementsByTagName ('p ' )->item (1 )->textContent );
189+ }
190+
166191 /**
167192 * Tests writing table with layout
168193 */
You can’t perform that action at this time.
0 commit comments