Add List for docx to html writer #1717
This commit is contained in:
parent
b230242127
commit
1451fadc4a
@ -17,14 +17,12 @@
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\HTML\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Settings;
|
||||
|
||||
/**
|
||||
* ListItem element HTML writer
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
class ListItemRun extends ListItem
|
||||
class ListItemRun extends TextRun
|
||||
{
|
||||
/**
|
||||
* Write list item
|
||||
@ -38,12 +36,7 @@ class ListItemRun extends ListItem
|
||||
}
|
||||
|
||||
$writer = new Container($this->parentWriter, $this->element);
|
||||
|
||||
if (Settings::isOutputEscapingEnabled()) {
|
||||
$content = '<p>' . $this->escaper->escapeHtml($writer->write()) . '</p>' . PHP_EOL;
|
||||
} else {
|
||||
$content = '<p>' . $writer->write() . '</p>' . PHP_EOL;
|
||||
}
|
||||
$content = $writer->write() . PHP_EOL;
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
@ -163,6 +163,31 @@ class ElementTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertContains($expected, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test write element ListItemRun
|
||||
*/
|
||||
public function testListItemRun()
|
||||
{
|
||||
$expected1 = 'List item run 1';
|
||||
$expected2 = 'List item run 1 in bold';
|
||||
|
||||
$phpWord = new PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
|
||||
$listItemRun = $section->addListItemRun(0, null, 'MyParagraphStyle');
|
||||
$listItemRun->addText($expected1);
|
||||
$listItemRun->addText($expected2, array('bold' => true));
|
||||
|
||||
$htmlWriter = new HTML($phpWord);
|
||||
$content = $htmlWriter->getContent();
|
||||
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadHTML($content);
|
||||
|
||||
$this->assertEquals($expected1, $dom->getElementsByTagName('p')->item(0)->textContent);
|
||||
$this->assertEquals($expected2, $dom->getElementsByTagName('p')->item(1)->textContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests writing table with layout
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user