cssepubemmetepub3

How to add missing browser-specific css declaration properties and prefixes to epub


Publishers sometimes release Epub titles without including all of the required browser-specific css declaration properties and prefixes. For example, a title might include a -webkit-transform declaration but omit transform or vice versa.

There are a number of tools available to assist developer workflow in the creation of new content Stackoverflow: How to automatically add browser prefix to CSS3 properties?; however, I am looking for a way to parse an entire Epub and add any missing properties.


Solution

  • We will assume that all the relevant CSS is in .css files. You can open the epub by unzipping it, and this will expose the CSS files, wherever they might be. You can then simply run these through your favorite prefixing tool, then zip the book back up.

    The problem is that AFAIK prefixing tools typically expect the transform property and add the -webkit-transform counterpart. I am not sure these tools will work if only -webkit-transform is there and you want transform to be added. You'll have to check each tool to see if it provides this behavior. In the worst case, you could write your own plugin for a CSS transformation framework like rework to do what you need.