View Single Post
Old 06-23-2011, 01:28 AM   #154
capnm
Groupie
capnm knows the difference between 'who' and 'whom'capnm knows the difference between 'who' and 'whom'capnm knows the difference between 'who' and 'whom'capnm knows the difference between 'who' and 'whom'capnm knows the difference between 'who' and 'whom'capnm knows the difference between 'who' and 'whom'capnm knows the difference between 'who' and 'whom'capnm knows the difference between 'who' and 'whom'capnm knows the difference between 'who' and 'whom'capnm knows the difference between 'who' and 'whom'capnm knows the difference between 'who' and 'whom'
 
Posts: 156
Karma: 10001
Join Date: Feb 2011
Device: sony
Option 1:
You aim to just flag commercially published epubs (where this all started).
So you only look at the css files that have @page or body set in the css with margins (where you are right now).

This will skip all Calibre generated and many bespoke epubs.
It *might* produce unexpected/unwanted results on epubs with multiple @page declarations or multiple css files. (Pretty darn rare).

Option 2:
You want to take on modifying other epubs too.
To find the 'body' margins look in the xhtml for <body class="xxxxxx" > , then go to the stylesheet (oops, do we have the right stylesheet? better check the xhtml for the link) and find .xxxxx {.....} and get the margins.
Now, you can *probably* take a shortcut and assume that the .calibre rule in the (one and only) stylesheet is what you're looking for in Calibre generated epubs. (But I don't know for sure).
And while you're scanning all the xhtml, you can check for the inline @page statements that Calibre generates.

Then you can zero the body margins, inject an @page in the stylesheet with new L/R margins, and decide whether to strip out all the inline @pages or reset them all with new T/B margins, and hope it all works.

Option 3:
Some sensible solution I've overlooked.



I'm in favor of option 1, leaving Calibre (re)generation to Calibre.

Of course, if you choose option 1, what happens if you zero the margins completely, then change your mind, and want 5pt margins?
Maybe inject @page even for zero margins?
Then the epub would still meet the search criteria of having body or @page margins set in the css ...

Clear as mud?
capnm is offline   Reply With Quote