Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<br> in addHtml #1518

Open
1 of 3 tasks
disprog opened this issue Nov 22, 2018 · 1 comment
Open
1 of 3 tasks

<br> in addHtml #1518

disprog opened this issue Nov 22, 2018 · 1 comment

Comments

@disprog
Copy link

disprog commented Nov 22, 2018

This is:

Expected Behavior

text1
text2

  • text3

Current Behavior

text1

text2

  • text3

Failure Information

tag <br> makes new empty line beetween 'text1' and 'text2' instead of line break of line
I can't wrap sting in tag p, because I get html from external source and this may contain <ul>
(Exception "Cannot add ListItemRun in TextRun")

How to Reproduce

<?php
require __DIR__ . '/vendor/autoload.php';

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$value = "text1<br />text2<ul><li>text3</li></ul>";
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $value, false, false);

Context

  • PHP version: 5.6.23
  • PHPWord version: dev-master a93250f
@thomasb88
Copy link

addTextBreak leads to, for example for HTML Writer in PhpWord\Writer\HTML\Element\TextBreak.php
"if ($this->withoutP) {
$content = '
' . PHP_EOL;
} else {
$content = '

 

' . PHP_EOL;
}"

But if you write it in Word 2007, you don't have this problem
"if (!$this->withoutP) {
$hasStyle = $element->hasStyle();
$this->startElementP();

        if ($hasStyle) {
            $xmlWriter->startElement('w:pPr');
            $this->writeFontStyle();
            $xmlWriter->endElement(); // w:pPr
        }

        $this->endElementP(); // w:p
    } else {
        $xmlWriter->writeElement('w:br');
    }"

For "I can't wrap sting in tag p, because I get html from external source and this may contain

    ",
    Can't you wrap it so that it the paragraphe don't include ul or ol tags ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants