CSL Modules

This is a Python script I hacked up to simplify maintenance of legal styles on the CitationStylist site. It can be installed in the usual way from the downloaded sources, with the command (under Linux, at least):

sudo python ./setup.py install


The installer will provide a command cslmodules.py. When run for the first time, the script will drop a cslmodules.cfg configuration file into the current directory. Paths and other parameters in the config file should be more or less self-explanatory.

For each style name set as a section in the config file, the script will look up the partner style specified for each dependent macro set under it. A prefix to the style names can be set in the config file. In the MLZ style naming convention, the section named oscola, for example, will look for the style named mlz-oscola.csl in the styles path set in the config file. Set the prefix parameter in the config file to an empty string for use with mainstream styles.

For each target macro, the script will look for the specific corresponding macro in both the calling and the called style. If the macro is found in both the calling (dependent) and the called (independent) styles, the macro and all macros called through it will be copied from the called to the calling style. Any macros with matching names in the called style will be overwritten. Unused macros will be purged from all calling styles, so use version control, make regular checkins, and be careful.

To allow small formatting variations between the dependent and independent styles for a macro set, macros that are identical apart from differences in text-case, font-style, font-variant, quotes, value, prefix, suffix or delimiter are not touched in the update.

Macros that are used across styles can be defined in a standard library "style" and pulled in from there by setting a placeholder in "dependent" styles. The library macros will be pulled first during a script run, so dependent code can rely on their presence.

With the --inspect option, a warning will issue against macros that are not prefixed with the "module" nickname or the name of the source style.

This is working out pretty well in the MLZ project, so I'm putting it up here in case it might prove useful to others. There are no restrictions on the code; do with it as you will.

Frank Bennett 2012.03.08