Forum How do I...?

List counter reset issues while nesting styled ordered lists that use pseudo elements

mwims
Hi There,

I have an ordered list where I decorate the running counter with brackets (1), (2) etc...
I use li:before in a generally recommended way of styling such custom lists.
Problem occurs when I attempt to nest such lists in regular ol's:

HTML looks like this:

    1. item1
    2. item2
    3. item3

      (1) nested item1
      (2) nested item2
      (3) nested item3
      (4) nested item4
    4. item4
    5. item5

PDF looks like this:

    1. item1
    2. item2
    3. item3

      (1) nested item1
      (2) nested item2
      (3) nested item3
      (4) nested item4
    8. item4
    9. item5

Any ideas why the items in the nested list are being taken into account while numbering the top level list? Some sort of counter-reset issue? I've attached my testcase...

Kind Regards,
-Mark

  1. list-counter-test-case.zip91.0 kB
    List counter reset issue
mikeday
This is a bug in Prince where we are incorrectly incrementing the list-item counter even though list-style-type is set to none.

We will fix this in the next release, but in the meantime you can workaround the problem by overriding the counter-increment on the list item:
ol.decimalWithBracketsOrderedList li {
    list-style-type: none;
    counter-increment: list-item 0
}

mikeday
Sorry I had that completely upside down, it's because it's overriding the counter-reset of the list-item, and can be fixed like this:
ol.decimalWithBracketsOrderedList {
    counter-reset: decimal list-item;
}

(The other fix will also work, but this fix makes more sense!)