-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Html to Docx issues #543
Comments
In the meantime I found out that (for my use case) this is the best solution: /**
* Parse paragraph node
*
* @param \DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array &$styles
* @return \PhpOffice\PhpWord\Element\TextRun
*/
private static function parseParagraph($node, $element, &$styles)
{
$styles['paragraph'] = self::parseInlineStyle($node, $styles['paragraph']);
$newElement = $element->addTextRun($styles['paragraph']);
$newElement->addTextBreak(1);
return $newElement;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this great package!
I'm having issues converting html to docx.
I get user input in Markdown and convert this to html with https://github.com/thephpleague/commonmark
Input:
Gets converted to:
In the Word-document it will look like:
This behaviour seems logical when I read the code. All linebreaks get deleted and html linebreaks (
<br />
get ignored).By adding a method that parses the br's (I added with nl2br), it works just like I would expect.
I'm wondering if this is the best way of handling it (and if this could be added to the package) or if there's a better way of handling it?
Any help would be appreciated. Happy to make a pull request if needed.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: