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: 2024-07-31 03:15 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)
Comment 9 QA Administrators 2024-07-31 03:15:04 UTC
Dear Erkki Laaneoks,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug