Bug 135449 - Export into HTML and bullets incorrect ("</li>" missing)
Summary: Export into HTML and bullets incorrect ("</li>" missing)
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.4.3.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: (X)HTML-Export
  Show dependency treegraph
 
Reported: 2020-08-04 21:10 UTC by Erkki Laaneoks
Modified: 2022-07-31 16:44 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Nested List (10.26 KB, application/vnd.oasis.opendocument.text)
2022-07-31 16:35 UTC, Andreas Heinisch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erkki Laaneoks 2020-08-04 21:10:34 UTC
Steps:
Open Writer
Write some text
Add some bullets and text
Add some text.
File => "Save a Copy..." => "Save as Type" := "HTML" => Save
Open the saved file. The result is like (fragment):


<ul>
	<li><p style="text-indent: 0cm; margin-top: 0cm; line-height: 100%">midagi</p>
	<li><p style="text-indent: 0cm; margin-top: 0cm; line-height: 100%">kedasi</p>
	<li><p style="text-indent: 0cm; margin-top: 0cm; line-height: 100%">kuidagi</p>
	<li><p style="text-indent: 0cm; margin-top: 0cm; line-height: 100%">OK</p>
</ul>

There are no "</li>" tags after "</p>". This is a bug.


Why "<p style="text-indent: 0cm; margin-top: 0cm; line-height: 100%">" needed at all as default?
Comment 1 Julien Nabet 2020-08-05 09:41:23 UTC
On which env are you? (MacOs, Windows, Linux)
Could you give a try with last stable LO version 6.4.5?
Comment 2 Erkki Laaneoks 2020-08-05 17:09:50 UTC
I use Win7.
I just tested with LibreOffice 7.0.0.3. The result was the same.
Comment 3 Julien Nabet 2020-08-05 17:20:55 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.
Comment 4 Andreas Heinisch 2022-07-12 12:09:41 UTC
The li element has an end tag (</li>), but it’s optional in some cases:

An li element's end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element.

Should we go for XHTML compliance here and close the li tag?
Comment 5 Andreas Heinisch 2022-07-13 10:21:51 UTC
Hm, not so easy to correctly close and open nested lists because I have not the insight in that part of the code :(
Comment 6 Julien Nabet 2022-07-30 15:59:23 UTC
Miklos: reading some docs it seems ending li is optional in html in some cases.
But what about putting it anyway and just use this simple patch:
diff --git a/sw/source/filter/html/htmlnumwriter.cxx b/sw/source/filter/html/htmlnumwriter.cxx
index f41ac73929f9..a556f4139da4 100644
--- a/sw/source/filter/html/htmlnumwriter.cxx
+++ b/sw/source/filter/html/htmlnumwriter.cxx
@@ -354,18 +354,16 @@ Writer& OutHTML_NumberBulletListEnd( SwHTMLWriter& rWrt,
         }
     }
 
-    if (rWrt.mbXHTML)
+    // The list is numbered if the previous text node is numbered or any other previous text
+    // node is numbered.
+    bool bPrevIsNumbered = rInfo.IsNumbered() || *oAtLeastOneNumbered;
+    // XHTML </li> for the list item content, if there is an open <li>.
+    // also for HTML even if it's optional, it can't be bad (see tdf#135449)
+    if ((bListEnd && bPrevIsNumbered) || (!bListEnd && rNextInfo.IsNumbered()))
     {
-        // The list is numbered if the previous text node is numbered or any other previous text
-        // node is numbered.
-        bool bPrevIsNumbered = rInfo.IsNumbered() || *oAtLeastOneNumbered;
-        // XHTML </li> for the list item content, if there is an open <li>.
-        if ((bListEnd && bPrevIsNumbered) || (!bListEnd && rNextInfo.IsNumbered()))
-        {
-            HTMLOutFuncs::Out_AsciiTag(
-                rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_li),
-                false);
-        }
+        HTMLOutFuncs::Out_AsciiTag(
+          rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_li),
+          false);
     }
 
     if (!bListEnd)

?
Comment 7 Andreas Heinisch 2022-07-31 16:35:07 UTC
Created attachment 181510 [details]
Nested List

Thank you for your patch! I tried to tackle this bug, too, but in a nested list case, it produces wrong HTML code :(

Wrong output:
        <ul>
            <li>
                <p style="line-height: 100%; margin-bottom: 0in">A</p>
            </li>
            <ul>
                <li>
                    <p style="line-height: 100%; margin-bottom: 0in">One</p>
                </li>
                <li>
                    <p style="line-height: 100%; margin-bottom: 0in">Two</p>
                </li>
            </ul>
            <li>
                <p style="line-height: 100%; margin-bottom: 0in">B</p>
            </li>
        </ul>

Should be:

        <ul>
            <li>
                <p style="line-height: 100%; margin-bottom: 0in">A</p>
                <ul>
                    <li>
                        <p style="line-height: 100%; margin-bottom: 0in">One</p>
                    </li>
                    <li>
                        <p style="line-height: 100%; margin-bottom: 0in">Two</p>
                    </li>
                </ul>
            </li>
            <li>
                <p style="line-height: 100%; margin-bottom: 0in">B</p>
            </li>
        </ul>
Comment 8 Julien Nabet 2022-07-31 16:44:34 UTC
(In reply to Andreas Heinisch from comment #7)
> Created attachment 181510 [details]
> Nested List
> 
> Thank you for your patch! I tried to tackle this bug, too, but in a nested
> list case, it produces wrong HTML code :(
> ...
Indeed :-(

(I wanted to give a try to exporting in xhtml but it's not in the list)