https://bugs.documentfoundation.org/show_bug.cgi?id=160413
Bug ID: 160413
Summary: docx to html conversion: error with table of content:
missing 2 x </div>
Product: LibreOffice
Version: 7.6.5.2 release
Hardware: All
OS: Windows (All)
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: LibreOffice
Assignee: [email protected]
Reporter: [email protected]
Description:
Hello.
There is an error in LibreOffice when it converts a docx table of content to
html: two div tages are made, but they are not closed.
Code made by Libreoffice:
<div id="Inhoudsopgave1" dir="ltr">
<div id="TextSection" dir="ltr">
To close the <div> tags I used the following code (in PHP):
$dom = new DOMDocument();
$dom->loadHTMLFile($htmlFilePath, LIBXML_HTML_NOIMPLIED |
LIBXML_HTML_NODEFDTD);
$divs = $dom->getElementsByTagName('div');
// Count the number of <div> tags
$numDivs = $divs->length;
// Loop through the <div> tags
for ($i = 0; $i < $numDivs; $i++) {
$div = $divs->item($i);
// Check if the <div> tag is not the last one
if ($i !== $numDivs - 1) {
// Add a closing </div> tag after each <div> tag
$closingDiv = $dom->createElement('div');
$closingDiv->appendChild($dom->createTextNode('</div>'));
$div->parentNode->insertBefore($closingDiv, $div->nextSibling);
}
}
// Save the modified HTML
$modifiedHtml = $dom->saveHTML();
This seems to work for the case I'm working on, but I'm not sure if it works
for all cases.
I would really appreciate if this can be fixed in LibreOffice.
Thank you! :-)
Jeroen Buse
Steps to Reproduce:
1. Convert a docx document with a table of content to html.
2.
3.
Actual Results:
See the bug description.
Expected Results:
See the bug description.
Reproducible: Always
User Profile Reset: No
Additional Info:
See the bug description.
--
You are receiving this mail because:
You are the assignee for the bug.