Differences in CSS counters between Author and Web Author

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 -- ------------------------------------------------------------------ Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz ------------------------------------------------------------------ Professional XML and Web consulting and training services DocBook/DITA customization, custom XSLT/XSL-FO document processing ------------------------------------------------------------------ Bringing you XML Prague conference http://xmlprague.cz ------------------------------------------------------------------

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@oxygenxml.com https://www.oxygenxml.com/mailman/listinfo/oxygen-user

On 5.10.2018 15:56, Cristi Talau wrote:
If you change the CSS from
chapter > title:before { counter-reset: figure sect1_count; }
to
chapter { counter-reset: figure sect1_count; }
Hi Cristian, thanks for hint. Unfortunately this was not sufficient to fix the issue. I had to use chapter { counter-reset: figure example sect1_count !important; } The reason is that DocBook framework in elements.css contains the following rule: chapter:root { counter-reset:chapter_count; } Selector "chapter:root" is more specific then "chapter" and thus new rule for chapter defining proper counter scope has been ignored. I'm not sure why elements.css is using "chapter:root" instead of just "chapter". If there is no reason for using :root then I think it would be better not to use it as counter-reset properties are not combined for multiple counters. Thanks and have a nice day, Jirka -- ------------------------------------------------------------------ Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz ------------------------------------------------------------------ Professional XML and Web consulting and training services DocBook/DITA customization, custom XSLT/XSL-FO document processing ------------------------------------------------------------------ Bringing you XML Prague conference http://xmlprague.cz ------------------------------------------------------------------
participants (2)
-
Cristi Talau
-
Jirka Kosek