blob: 73a9fe188422b828031d385e444ca3a97d28dda1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# Groff Preprocessors and Tools
This repository is home to an assortment of preprocessors and
macros for the [GNU Troff](http://www.gnu.org/software/groff/) typesetting
package.
I have written all of them except `sequence.pic` which is part of the
[UML Graph](http://www.umlgraph.org/) package and included here for convenience
only.
These scripts do not strive to be complete, well tested and fit for general usage - they
are merely quick and dirty hacks that accumulated on my hard drive :-).
## EBNF
`ebnf.sno` is a [CSNOBOL4](http://www.snobol4.org/csnobol4/) program that compiles
extended BNF descriptions into GNU pic code using macros from `syntax.pic`.
This effectively allows you to embed EBNF grammars in Groff source code and
have it rendered as (box and arrow) syntax diagrams.
Most EBNF constructs and some extensions are supported, but I'm too lazy to document
all of them now.
To build the sample `select-from.ebnf`, type something like:
cat samples/select-from.ebnf | ./ebnf.sno | pic | groff -Tps >select-from.ps
## HIGHLIGHT (SNOBOL4)
`highlight.sno` is a small preprocessor written in [CSNOBOL4](http://www.snobol4.org/csnobol4/)
that processes blocks of source code embedded in your Groff document with
[GNU Source-highlight](http://www.gnu.org/software/src-highlite/) to produce
syntax highlighted text.
The output is formatted according to `groff.outlang`.
Versions for the [mom macros](http://www.schaffter.ca/mom/) (`groff-mom.outlang`) and
for the classic ms macros (`groff-ms.outlang`) are provided.
Example (mom):
```groff
.QUOTE
.CODE
.HIGHLIGHT c
#include <stdio.h>
int main(int argc, char **argv)
{
printf("Hello world!\n");
return 0;
}
.HIGHLIGHT
.CODE OFF
.QUOTE OFF
```
## HIGHLIGHT (Lua)
`highlight.lua` is a reimplementation of `highlight.sno` in Lua 5.2 and may work
better on some operating systems.
In addition to the aforementioned syntax, the Lua version allows you to specify a filename after
the language identifier to process an external file:
```groff
.HIGHLIGHT c hello.c
```
## UML
`uml.sno` is a small preprocessor (again requires CSNOBOL4) that
renders an embedded diagram with [PlantUML](http://plantuml.sourceforge.net/)
and automatically emits the appropriate Mom `PDF_IMAGE` macro calls.
Naturally, this leaves around PDF images (`uml_tempX.pdf`) that you should remove
after generating your document.
## HTML Tables
`htbl.tes` is a quick and dirty [SciTECO](http://rhaberkorn.github.com/sciteco/) script
that can act as a drop-in replacement for the tbl preprocessor that generates
proper HTML tables when the Groff html output device is used.
With the original tbl preprocessor, tables are (and must be) rendered by the postscript
device and will be embedded as images into the HTML page.
|