Annotation of docbook2mdoc/macro.h, Revision 1.7
1.7 ! schwarze 1: /* $Id: macro.h,v 1.6 2019/05/01 15:05:39 schwarze Exp $ */
1.1 schwarze 2: /*
3: * Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
4: *
5: * Permission to use, copy, modify, and distribute this software for any
6: * purpose with or without fee is hereby granted, provided that the above
7: * copyright notice and this permission notice appear in all copies.
8: *
9: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
10: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
12: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16: */
17:
18: /*
19: * The interface of the macro line formatter,
20: * a part of the mdoc(7) formatter.
21: */
22:
23: enum linestate {
24: LINE_NEW = 0, /* At the beginning of a new line. */
25: LINE_TEXT, /* In the middle of a text line. */
26: LINE_MACRO /* In the middle of a macro line. */
27: };
28:
1.5 schwarze 29: enum parastate {
30: PARA_HAVE, /* Just printed .Pp or equivalent. */
31: PARA_MID, /* In the middle of a paragraph. */
32: PARA_WANT /* Need .Pp before printing anything else. */
33: };
34:
1.1 schwarze 35: struct format {
36: int level; /* Header level, starting at 1. */
1.6 schwarze 37: int nofill; /* Level of no-fill block nesting. */
1.4 schwarze 38: int flags;
39: #define FMT_NOSPC (1 << 0) /* Suppress space before next node. */
40: #define FMT_ARG (1 << 1) /* May add argument to current macro. */
41: #define FMT_CHILD (1 << 2) /* Expect a single child macro. */
42: #define FMT_IMPL (1 << 3) /* Partial implicit block is open. */
1.1 schwarze 43: enum linestate linestate;
1.5 schwarze 44: enum parastate parastate;
1.1 schwarze 45: };
46:
47: #define ARG_SPACE 1 /* Insert whitespace before this argument. */
48: #define ARG_SINGLE 2 /* Quote argument if it contains whitespace. */
49: #define ARG_QUOTED 4 /* We are already in a quoted argument. */
50: #define ARG_UPPER 8 /* Covert argument to upper case. */
51:
52:
53: void macro_open(struct format *, const char *);
54: void macro_close(struct format *);
55: void macro_line(struct format *, const char *);
56:
57: void macro_addarg(struct format *, const char *, int);
58: void macro_argline(struct format *, const char *, const char *);
59: void macro_addnode(struct format *, struct pnode *, int);
60: void macro_nodeline(struct format *, const char *, struct pnode *, int);
1.2 schwarze 61:
1.7 ! schwarze 62: void para_check(struct format *);
1.2 schwarze 63: void print_text(struct format *, const char *, int);
64: void print_textnode(struct format *, struct pnode *);
CVSweb