docbook / xslTNG

DocBook xslTNG Stylesheets
https://xsltng.docbook.org
MIT License
44 stars 21 forks source link

Potential issue with landscape feature and AHFormatter #565

Open frankarensmeier opened 4 days ago

frankarensmeier commented 4 days ago

Earlier in October this year, the "landscape" feature was added to DocbookNG, which is highly appreciated. However, I’ve observed that it has the side effect of making rendering smaller documents take considerably longer with AHFormatter. For example, I have a simple test case where the resulting PDF document has 3 pages. Using docbook-paged.css from the 2.2.1 release, the document is generated in under 0.2 seconds, whereas the current release takes over 1 minute.

I realise that vendor-ahf-landscape.scss and vendor-ahf-portrait.scss add almost 1MB to the resulting CSS file. I’m curious to understand more about the background of this change. Perhaps there’s a way to simplify the CSS for AHF or explore other optimisations?

ndw commented 4 days ago

For documents that don't use landscape (or maybe that only use one orientation) it might be possible to avoid loading that CSS. I suppose it might be possible also to only load the particular combinations that are used by the document, but that seems potentially much more difficult. I'll have to see if I can reproduce the problem and confirm that those CSS changes are the problem. That might be a bug worth reporting to AntennaHouse as well.

If someone with more CSS skill than I can propose a simpler solution, I'd be delighted. When I investigated the problem, I concluded that the only way to make it work was to generate the full combinatorial matrix of possibilities. One more reason to consider biting the bullet and implementing XSL FO stylesheets, I guess.

I wonder if @tgraham-antenna might have any insights.

tgraham-antenna commented 1 day ago

html.article-style.#{$pagesize} body matches on a body descendant of html..., and so on for the rest of the selectors. It will probably be more efficient to use html.article-style.#{$pagesize} > body, and so on, to indicate a direct child relationship where possible.

You might instead do html.article-style.#{$pagesize} > * to save having to match on the name.

You might also try things like html.article-style.#{$pagesize} > *:not(.portrait), where possible, to save more matching on names.

It's not clear to me why html.article-style.#{$pagesize} body is needed if body is not going to change the page layout.