From: Richard Kimberly Heck Date: Sun, 4 Dec 2022 17:51:47 +0000 (-0500) Subject: Fix bug #11769 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=6f4f7442ef3d5ec254e3af33ca6f1461a287200e;p=features.git Fix bug #11769 --- diff --git a/lib/layouts/stdlists.inc b/lib/layouts/stdlists.inc index 45ec559f6d..1a50878991 100644 --- a/lib/layouts/stdlists.inc +++ b/lib/layouts/stdlists.inc @@ -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 diff --git a/src/Layout.cpp b/src/Layout.cpp index b94696fa0c..f782c12d9b 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -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_; } diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 47c4145456..3fb292e4da 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -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.