Skip to content

Commit b230242

Browse files
author
Bc. Štefan Kubini
committed
fixed List item fail #1711
1 parent b8346af commit b230242

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* This file is part of PHPWord - A pure PHP library for reading and writing
4+
* word processing documents.
5+
*
6+
* PHPWord is free software distributed under the terms of the GNU Lesser
7+
* General Public License version 3 as published by the Free Software Foundation.
8+
*
9+
* For the full copyright and license information, please read the LICENSE
10+
* file that was distributed with this source code. For the full list of
11+
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
12+
*
13+
* @see https://github.com/PHPOffice/PHPWord
14+
* @copyright 2010-2018 PHPWord contributors
15+
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16+
*/
17+
18+
namespace PhpOffice\PhpWord\Writer\HTML\Element;
19+
20+
use PhpOffice\PhpWord\Settings;
21+
22+
/**
23+
* ListItem element HTML writer
24+
*
25+
* @since 0.10.0
26+
*/
27+
class ListItemRun extends ListItem
28+
{
29+
/**
30+
* Write list item
31+
*
32+
* @return string
33+
*/
34+
public function write()
35+
{
36+
if (!$this->element instanceof \PhpOffice\PhpWord\Element\ListItemRun) {
37+
return '';
38+
}
39+
40+
$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+
}
47+
48+
return $content;
49+
}
50+
}

tests/PhpWord/Writer/HTML/ElementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ElementTest extends \PHPUnit\Framework\TestCase
3434
*/
3535
public function testUnmatchedElements()
3636
{
37-
$elements = array('Container', 'Footnote', 'Image', 'Link', 'ListItem', 'Table', 'Title', 'Bookmark');
37+
$elements = array('Container', 'Footnote', 'Image', 'Link', 'ListItem', 'ListItemRun', 'Table', 'Title', 'Bookmark');
3838
foreach ($elements as $element) {
3939
$objectClass = 'PhpOffice\\PhpWord\\Writer\\HTML\\Element\\' . $element;
4040
$parentWriter = new HTML();

0 commit comments

Comments
 (0)