This commit is contained in:
Richard Kimberly Heck 2022-12-04 12:51:47 -05:00
parent dfa87371f7
commit 6f4f7442ef
3 changed files with 52 additions and 4 deletions

View 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

View 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_;
}

View 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.