Next: , Previous: , Up: A Tutorial on Style Sheets   [Contents][Index]


7.7.2 Implementation

Quite naturally the style will be called ChangeLog, hence:

style ChangeLog is
written by "Akim Demaille <demaille@inf.enst.fr>"
version is 1.0
requires a2ps 4.9.5

documentation is
   "This is a tutorial style sheet.\n"
end documentation
  ...
end style

A first interesting and easy entry is that of function names, between ‘(’ and ‘)’:

sequences are
  "(" Plain Label ")" Plain
end sequences

A small problem that may occur is that there can be several functions mentioned separated by commas, that we don’t want to highlight this way. Commas, here, are exceptions. Since regular expressions are not yet implemented in a2ps, there is a simple but stupid way to avoid that white spaces are all considered as part of a function name, namely defining two exceptions: one which captures a single comma, and a second, capturing a comma and its trailing space.

For the file names, the problem is a bit more delicate, since they may end with ‘:’, or when starts the list of functions. Then, we define two sequences, each one with one of the possible closers, the exceptions being attached to the first one:

sequences are
  "* " Plain Label_strong ":" Plain
     exceptions are
        ", " Plain, "," Plain
     end exceptions,
  "* " Plain Label_strong " " Plain
end sequences

Finally, let us say that some words have a higher importance in the core of text: those about removing or adding something.

keywords in Keyword_strong are
  add, added, remove, removed
end keywords

Since they may appear in lower or upper, of mixed case, the style will be defined as case insensitive.

Finally, we end up with this style sheet file, in which an optional highlighting of the mail address of the author is done. Saving the file is last step. But do not forget that a style sheet has both a name as nice as you may want (such as ‘Common Lisp’), and a key on which there are strict rules: the prefix must be alpha-numerical, lower case, with no more than 8 characters. Let’s chose chlog.ssh.

# This is a tutorial on a2ps' style sheets
style ChangeLog is
written by "Akim Demaille <demaille@inf.enst.fr>"
version is 1.0
requires a2ps 4.9.5

documentation is
   "Second level of high lighting covers emails."
end documentation

sequences are
  "(" Plain Label ")" Plain
     exceptions are
        ", " Plain, "," Plain
     end exceptions,
  "* " Plain Label_strong ":" Plain
     exceptions are
        ", " Plain, "," Plain
     end exceptions,
  "* " Plain Label_strong " " Plain
end sequences

keywords in Keyword_strong are
  add, added, remove, removed
end keywords

optional sequences are
   < Plain Keyword > Plain
end sequences
end style

As a last step, you may which to let a2ps check your style sheet, both its syntax, and common errors:

ubu $ a2ps -vsheet -E/tmp/chlog.ssh ChangeLog -P void
Long output deleted
Checking coherence of "ChangeLog" (/tmp/chlog.ssh)
"ChangeLog" (/tmp/chlog.ssh) is sane.
---------- End of Finalization of /tmp/chlog.ssh

It’s all set, your style sheet is ready!


Next: The Entry in sheets.map, Previous: Example and syntax, Up: A Tutorial on Style Sheets   [Contents][Index]