[oXygen-user] Differences in CSS counters between Author and Web Author

Cristi Talau support at oxygenxml.com
Fri Oct 5 08:56:23 CDT 2018


Hello,

If you change the CSS from

chapter > title:before {
    counter-reset: figure sect1_count;
}

to

chapter {
    counter-reset: figure sect1_count;
}


The difference between Author and Web Author is the handling of 
pseudo-elements. In Author :before is considered sibling with the 
element while in Web Author it is a child. This stackoverflow answer [1] 
helped me troubleshooting this problem, more precisely, these quotes 
from the CSS specification:

The scope of a counter starts at the first element in the document that 
has a 'counter-reset' for that counter and includes the element's 
descendants and its following siblings with their descendants.

If 'counter-increment' or 'content' on an element or pseudo-element 
refers to a counter that is not in the scope of any 'counter-reset', 
implementations should behave as though a 'counter-reset' had reset the 
counter to 0 on that element or pseudo-element.

Best,
Cristian

[1] https://stackoverflow.com/a/20839693

On 10/4/2018 12:35 PM, Jirka Kosek wrote:
> Hi,
>
> I'm creating customized CSS stylesheet for DocBook based vocabulary. In
> Author I need to prepend Figure X.Y label before each figure title.
> Where X is chapter number and Y is number of figure inside chapter.
> I'm doing this by providing additional styleheet in framework that is
> extending DocBook framework:
>
> figure > title:before {
>    content: "Figure " counter(chapter_count) "." counter(figure) " ";
> }
>
> figure {
>    counter-increment: figure;
> }
>
> chapter > title:before {
>     counter-reset: figure sect1_count;
> }
>
> This works as expected in desktop Author. However in Web Author figure
> number is being reset for each section, so for example for document like
>
> <chapter>
>    ...
>    <section>
>      ...
>      <figure>  <!-- 1.1 -->
>      ...
>    </section>
>    <section>
>      ...
>      <figure>  <!-- 1.2 -->
>      ...
>    </section>
> </chapter>
>
> Web Author labels both figures as 1.1.
>
> I have briefly looked into HTML/CSS code of Web Author and it seems that
> you are somehow preprocessing Author CSS stylesheet for browser and this
> particular case is not handled properly.
>
> I suppose there is no easy workaround for this, but perhaps next version
> of Web Author could fix this ;-)
>
> Many thanks and have a nice day,
>
> 				Jirka
>
>
>
> _______________________________________________
> oXygen-user mailing list
> oXygen-user at oxygenxml.com
> https://www.oxygenxml.com/mailman/listinfo/oxygen-user


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.oxygenxml.com/pipermail/oxygen-user/attachments/20181005/b4282658/attachment.html>


More information about the oXygen-user mailing list