aboutsummaryrefslogtreecommitdiff
path: root/README
blob: 843ffbf21affb802fa79f67f240b26de72f5bb9a (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
# badroff

A basic tty typesetting system. As the name implies, it is a bad
imitation of a basic idea of roff. Commands are structured like 
/^.\*$/, but they are not turing-complete or even fully handle boxes or 
glue and the like.  Breaking a line does not use hyphenation or the 
like, instead only breaking on spaces. Non-breaking spaces are 
included, and some ad-hoc centering and leaders, so that I could create 
a specific document (it, `phrase-circuit.src` is included as an example 
and as a test).

# Building

Just run `make` (parallelism does work, so `make -j8` is recommended) to
build the binary `badroff`.

To install, run `sudo make install`

# Licence

The entirety of this project is licenced under the GNU GPLv3.
Check the licence for more details.

# Architecture

`badroff.c` contains most of the ad-hoc logic, and `sb.c`, `buf.c`, and
`ll.c` have helper data types. `buf.c` is a buffer, intended to be used
on top of a file so that it can peek several bytes in without complex
interfacing with other components (it also makes getting n characters
out in a string easy). `ll.c` is a basic linked list for multiple
strings, and `sb.c` is a "string buffer": a bunch of strings get added
into the buffer and then decomposed into a single string.

`badroff.c` starts with some helpers which fill buffers from a file with
a couple of string manipulation helpers too. Then, the next section is
composed mainly of typesetting commands available in a badroff file.
`accumlines` is used with `endgroup` to create groupable statements
like collecting multiple lines into one or typesetting multiple lines
as if they were one. The final section is generic handling of commands,
cleaning up trailing whitespace and nonbreaking spaces, the normal
typesetting algorithm, classifying lines as command/non-command, and
mainloop.

# Bugs

It mostly segfaults on line overfill (i.e. trying to center oversized
text or unfoldable lines are completely unhandled). Error handling
should probably be used, but that is a nontrivial addition.

# Return Value

Returns 0 on success and 1 on syntax error.