Is this expected behaviour?

Using XPP 9.4 in CSS mode if I have:

para::before { counter-reset: tester 5; content: counter(tester); }

then I get the 5 output before the start of the text, however if I have:

para::after { counter-reset: tester 5; content: counter(tester); }

then the output is zero.

I don't understand why I can't load a value into a counter in the "after" selector - am I missing something?

Parents
  • Chris,

    First of all: I could easily duplicate your problem and in the doc there is nothing that says that the counter-reset property can not be used in a ::before or ::after pseudo element.

    But there is a lot more going on
    I think the whole counter-reset thing seem to be broken.
    I have created the following test case:

    doc {
    	counter-reset: pCounter 5;
    }
    
    p {
    	display: block;
    	counter-increment: pCounter;
    }
    
    p::before {
    	content: counter(pCounter) ". ";
    	
    }

    and that works fine, so you get 6 for the first para and 7 for the next one.

    But if you change things to:

    doc {
    	counter-reset: pCounter 5;
    	counter-reset: pCounter2 6;
    }
    

    Things stop working and the first para is numbered 1, etc
    The same thing happens if you add a second counter-reset statement in your example

    Time to open up a ticket?

  • I don't have an answer (yet) for the problem being reported by Chris.

    But, Bart, I think that your reported "problem" is merely a CSS syntax problem with how you've specified your rule with the two counter-reset's in it (for the doc selector).

    AFAIK having the same property specified multiple times within the same CSS rule is not "additive" as you seem to be expecting. So, in your example the second counter-reset (for pCounter2) causes the first counter-reset (for pCounter) to effectively be ignored.

    If I change the order of those two counter-reset lines, then the pCounter reset does happen (because it's specified last).

    To make both counter-reset's happen, this is what I used to make it work:

    doc {
    counter-reset: pCounter 5 pCounter2 6;
    }

    Jonathan Dagresta
    SDL XPP Engineering

  • Yes Jonathan you are right.
    I did not think this through...

    Maybe I need to open up a documentation issue on this as the doc does not specify that you can address several counters at the same time....?

    Currently the doc for counter-reset is as follows:
    counter-reset The counter-reset property creates or resets one or more
    counters. The counter-reset property is usually used together
    with the counter-increment property and the content property.
    Initial Value none
    Inherited? no
    Syntax identifier integer | none | inherit

    I think this last thing should become

    Syntax (identifier integer )+ | none | inherit
    with a little extra info and maybe a small example

Reply
  • Yes Jonathan you are right.
    I did not think this through...

    Maybe I need to open up a documentation issue on this as the doc does not specify that you can address several counters at the same time....?

    Currently the doc for counter-reset is as follows:
    counter-reset The counter-reset property creates or resets one or more
    counters. The counter-reset property is usually used together
    with the counter-increment property and the content property.
    Initial Value none
    Inherited? no
    Syntax identifier integer | none | inherit

    I think this last thing should become

    Syntax (identifier integer )+ | none | inherit
    with a little extra info and maybe a small example

Children
No Data