File last modified on August 18, 2022

CSS Validation

ALL CSS files in a title (excluding the templated epub3.css) must be validated through w3c's validator. While browser errors may occur this is to insure that standard CSS is valid.

AppleScript

Use the AppleScript app css-validator.app. css-validator does support drag and drop.

Terminal

Gist:

The above shell script assumes the required JARs were downloaded from w3c. It is strongly suggested to create a directory for scripts and jar files and run all scripts in a separate directory from the files, example:

Points to a directory where all CSS files go:

bash
1
CSS_DIR="${HOME}/validation/css"

Points to a directory for all the JAR files:

bash
1
CSS_JAR="${HOME}/scripts/css_jar"

to run the command execute bash cssvalidate.sh in the terminal. This file can be executable with:

bash
1
chmod +x cssvalidate.sh

Another option is to add this to your .bash_profile:

bash
1
cd && nano .bash_profile

add:

bash
1
alias cssvalid='bash ~/path/to/file/cssvalidate.sh'

make sure to do a .bash_profile reboot:

bash
1
. .bash_profile

now the shell command (cssvalid) will work in the terminal.

Whitespace

CSS files should be the smallest size possible and while we do not compress we do make sure the CSS is clean. One area to help in file size is the removal of whitespace, regex:

bash
1
## Find:
2
^[[:blank:]]*$\r
3
4
## Replace:

Semi-colon

For some reason a missing semi-colon may not show up when the CSS file is tested with a vaildator or the ePub is ran through epubcheck but after experiencing app crashes with Adobe Digital Editions that could be traced back to a simple missing semi-colon. It's a good practice to check your CSS file, regex:

bash
1
## Find:
2
[^{};, ^\n\t]( |)$
3
4
## Replace:
Last build: Thursday, 08/18/2022, 01:01:08 AM