View Single Post
Old 03-27-2026, 03:31 PM   #34
rfog
Guru
rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.
 
Posts: 709
Karma: 2383546
Join Date: Aug 2007
Location: Schiedam (The Netherlands)
Device: Lots of eInk devices and iOS stuff
Quote:
Originally Posted by QuietShelfLife View Post
@rfog That's essentially the approach — book CSS loads first, then app defaults fill in anything unspecified, and user settings override last. The issue JSWolf found is that our defaults were too aggressive in a couple of places (widows/orphans and line-height), overriding values the book already set. Fixing that now along with user-adjustable margins and line height. Should be in the next release.
Then you have a bug in your code. If a later import/mix CSS overwrites some settings, it is doing it wrong except if you want that overwritten.

A working algorithm could be as easy as start with an empty dictionary data structure with a list in each node and then fill it with each CSS. Then you start with your full master CSS as dictionary with the selector as key, and the declaration block as a list of pairs. And then follow the reverse: starting with your full dictionary, go across low-to-high priority ebook and UI customizations, and for each selector in the other CSS, evaluate the declaration block and for each pair, if they are valid ones, replace or add it in the master CSS. No error can happen. If an ebook CSS contains widows and orphans, they will overwrite your own master CSS, and if not, it will respect master ones. And same with any other declaration pair for each selector.
rfog is offline   Reply With Quote