Stylesheets in Mokvino Web


Mokvino Web is a collection of scripts for GNU Awk, GNU Make and Mokvino which can be used to build and maintain websites.

There isn't a great deal of support for writing CSS stylesheets. If you want a simple mapping from source file, e.g., src/www/styles/foo.m5 to CSS file pub/www/styles/foo.css, use this:

# In src/www/styles/foo.m5
import(`m5web/css')\
write(WWWPREFIX`'VNAME`'CSS_SUFFIX, ``

body {
  background-color: white;
  color: black;
}

'')\

Make sure you also list the source file as one to be processed:

# In Makefile
DOCS += styles/foo

If you have a lot of stylesheets, you could define a user module module to simplify that:

# In etc/style.m5
import(`m5web/css')\
define(`CSSDOC', `pushdef(`VFILE', `VNAME'qindir(`CSS_LNK_SUFFIX'))\
write(WWWPREFIX`'VNAME`'CSS_SUFFIX,

``@charset "UTF-8";
@namespace url(http://www.w3.org/1999/xhtml);

'$$1')\
popdef(`VFILE')')\

Then you just write:

# In src/www/styles/foo.m5
load(`style')\
CSSDOC(``

body {
  background-color: white;
  color: black;
}

'')\

A macro is defined to simplify setting of colours:

'colours(```body''', ``\u0023000'', ``\u0023fff'', ``\u002300f'', ``\u0023551a8b'', ``\u0023f00'', ``\u0023c70'')`

The first parameter is a list of selectors to which a range of colour settings will be applied. The second parameter is the foreground colour, the third the background, the fourth the link colour, the fifth for visited links, the sixth for active links, and the seventh for hovering. Many of these can be omitted, taking on one of the earlier ones as defaults.

reluri is also made available by importing m5web/css.

To link a sheet styles/foo into a page, add to the head section the following:

lrel_css(``stylesheet'', `styles/foo')