I am trying to format the style of my PDF export using a custom CSS snippet. However, I was negatively surprised when I saw that my export no longer works as it was supposed to. Looks like first-of-type and last-of-type selector modifiers are no longer treated properly by Obsidian.
To prove this, I created a brand new vault with no community plugins and a single note. I added the following basic global styles for testing:
However, as you can see, none of what I expected actually happened. It looks almost as if Obsidian now loads each heading section on the fly, causign every heading to look like it is both the first and the last one in the page.
Have this ever worked in Obsidian? These two selectors select either the first or last occurrence of a list of elements at the same level. Within Obsidian each markdown heading is within a div element which makes the div’s appear at the same level, not the header element which is a child element.
On a related note; The same reasoning is why it was a game changer when we could use the has() selector since we then could target the parent div, through checking its child element(s).
I can confirm that the DOM did change recently for PDF exports. Each section is now wrapped in a <div> element. Because first-of-type and last-of-type only checks elements on the same level, these queries will no longer work, unfortunately. You will need to find a new way to query for the elements you are after.
The change was added as part of changes that improve support for exporting right-to-left text.