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 17
17
18
18
namespace PhpOffice \PhpWord \Writer \HTML \Element ;
19
19
20
- use PhpOffice \PhpWord \Settings ;
21
-
22
20
/**
23
21
* ListItem element HTML writer
24
22
*
25
23
* @since 0.10.0
26
24
*/
27
- class ListItemRun extends ListItem
25
+ class ListItemRun extends TextRun
28
26
{
29
27
/**
30
28
* Write list item
@@ -38,12 +36,7 @@ public function write()
38
36
}
39
37
40
38
$ 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 ;
47
40
48
41
return $ content ;
49
42
}
Original file line number Diff line number Diff line change @@ -163,6 +163,31 @@ public function testWriteTitleTextRun()
163
163
$ this ->assertContains ($ expected , $ content );
164
164
}
165
165
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
+
166
191
/**
167
192
* Tests writing table with layout
168
193
*/
You can’t perform that action at this time.
0 commit comments