]> git.lyx.org Git - lyx.git/commitdiff
Fix bug #11769
authorRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 4 Dec 2022 17:51:47 +0000 (12:51 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 4 Dec 2022 17:51:47 +0000 (12:51 -0500)
lib/layouts/stdlists.inc
src/Layout.cpp
src/output_xhtml.cpp

index 45ec559f6d3e593a4df2bf2c64e72ffb4c26e60c..1a50878991e4ada60150d2e166c39ac0550d4492 100644 (file)
@@ -88,6 +88,12 @@ Style Enumerate
        DocBookTag            orderedlist
        DocBookItemTag        listitem
        DocBookItemInnerTag   para
+       HTMLStyle
+               ol.enumi   { list-style-type: decimal; }
+               ol.enumii  { list-style-type: lower-latin; }
+               ol.enumiii { list-style-type: lower-roman; }
+               ol.enumiv  { list-style-type: upper-latin; }
+       EndHTMLStyle
 End
 
 Style Description
index b94696fa0c1953bdb470cc11aa1c1fd21ab5e707..f782c12d9b01a8ef6a5b943fb19ed75d4e991fd2 100644 (file)
@@ -1809,7 +1809,9 @@ string const & Layout::htmltag() const
 
 string const & Layout::htmlattr() const
 {
-       if (htmlattr_.empty())
+       // If it's an enumeration, then we recalculate the class each time through
+       // unless it has been given explicitly
+       if (htmlattr_.empty() && labeltype != LABEL_ENUMERATE)
                htmlattr_ = "class=\"" + defaultCSSClass() + "\"";
        return htmlattr_;
 }
index 47c4145456399f7202074309e6c395c5f2707979..3fb292e4dacbacae6bf95876665720003c672128 100644 (file)
@@ -19,6 +19,7 @@
 #include "Counters.h"
 #include "Font.h"
 #include "Layout.h"
+#include "LayoutEnums.h"
 #include "Paragraph.h"
 #include "ParagraphList.h"
 #include "ParagraphParameters.h"
@@ -156,7 +157,7 @@ namespace {
 // convenience functions
 
 inline void openParTag(XMLStream & xs, Layout const & lay,
-                       const std::string & parlabel)
+                       std::string const & parlabel)
 {
        string attrs = lay.htmlattr();
        if (!parlabel.empty())
@@ -165,9 +166,18 @@ inline void openParTag(XMLStream & xs, Layout const & lay,
 }
 
 
+void openParTag(XMLStream & xs, Layout const & lay,
+                std::string const & cssclass,
+                std::string const & parlabel) {
+    string attrs = "class='" + cssclass + "'";
+    if (!parlabel.empty())
+        attrs += " id='" + parlabel + "'";
+    xs << xml::ParTag(lay.htmltag(), attrs);
+}
+
 void openParTag(XMLStream & xs, Layout const & lay,
                 ParagraphParameters const & params,
-                const std::string & parlabel)
+                std::string const & parlabel)
 {
        // FIXME Are there other things we should handle here?
        string const align = alignmentToCSS(params.align());
@@ -398,7 +408,37 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
        depth_type const origdepth = pbegin->params().depth();
 
        // open tag for this environment
-       openParTag(xs, bstyle, pbegin->magicLabel());
+       if (bstyle.labeltype == LABEL_ENUMERATE && bstyle.htmlattr().empty()) {
+               // In this case, we have to calculate the CSS class ourselves, each time
+               // through
+               // FIXME We assume in these cases that the standard enumeration counter
+               // is being used. (We also do not deal with 'resume' counters, though I'm
+               // not sure that can be done at all.)
+
+               // Code borrowed from Buffer::Impl::setLabel
+               docstring enumcounter = bstyle.counter.empty() ?
+                                       from_ascii("enum") : bstyle.counter;
+               switch (par->itemdepth) {
+               case 2:
+                       enumcounter += 'i';
+                       // fall through
+               case 1:
+                       enumcounter += 'i';
+                       // fall through
+               case 0:
+                       enumcounter += 'i';
+                       break;
+               case 3:
+                       enumcounter += "iv";
+                       break;
+               default:
+                       // not a valid enumdepth...
+                       break;
+               }
+               openParTag(xs, bstyle, to_utf8(enumcounter), pbegin->magicLabel());
+       }
+       else
+               openParTag(xs, bstyle, pbegin->magicLabel());
        xs << xml::CR();
 
        // we will on occasion need to remember a layout from before.