]> git.cameronkatri.com Git - mandoc.git/blob - libmdoc.h
implement tagging for .Er
[mandoc.git] / libmdoc.h
1 /* $Id: libmdoc.h,v 1.105 2015/04/23 15:35:59 schwarze Exp $ */
2 /*
3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #define MACRO_PROT_ARGS struct roff_man *mdoc, \
20 int tok, \
21 int line, \
22 int ppos, \
23 int *pos, \
24 char *buf
25
26 struct mdoc_macro {
27 void (*fp)(MACRO_PROT_ARGS);
28 int flags;
29 #define MDOC_CALLABLE (1 << 0)
30 #define MDOC_PARSED (1 << 1)
31 #define MDOC_EXPLICIT (1 << 2)
32 #define MDOC_PROLOGUE (1 << 3)
33 #define MDOC_IGNDELIM (1 << 4)
34 #define MDOC_JOIN (1 << 5)
35 };
36
37 enum margserr {
38 ARGS_ERROR,
39 ARGS_EOLN, /* end-of-line */
40 ARGS_WORD, /* normal word */
41 ARGS_PUNCT, /* series of punctuation */
42 ARGS_QWORD, /* quoted word */
43 ARGS_PHRASE, /* Ta'd phrase (-column) */
44 ARGS_PPHRASE, /* tabbed phrase (-column) */
45 ARGS_PEND /* last phrase (-column) */
46 };
47
48 /*
49 * A punctuation delimiter is opening, closing, or "middle mark"
50 * punctuation. These govern spacing.
51 * Opening punctuation (e.g., the opening parenthesis) suppresses the
52 * following space; closing punctuation (e.g., the closing parenthesis)
53 * suppresses the leading space; middle punctuation (e.g., the vertical
54 * bar) can do either. The middle punctuation delimiter bends the rules
55 * depending on usage.
56 */
57 enum mdelim {
58 DELIM_NONE = 0,
59 DELIM_OPEN,
60 DELIM_MIDDLE,
61 DELIM_CLOSE,
62 DELIM_MAX
63 };
64
65 extern const struct mdoc_macro *const mdoc_macros;
66
67 __BEGIN_DECLS
68
69 void mdoc_macro(MACRO_PROT_ARGS);
70 void mdoc_elem_alloc(struct roff_man *, int, int,
71 int, struct mdoc_arg *);
72 struct roff_node *mdoc_block_alloc(struct roff_man *, int, int,
73 int, struct mdoc_arg *);
74 void mdoc_tail_alloc(struct roff_man *, int, int, int);
75 struct roff_node *mdoc_endbody_alloc(struct roff_man *, int, int, int,
76 struct roff_node *, enum mdoc_endbody);
77 void mdoc_node_relink(struct roff_man *, struct roff_node *);
78 int mdoc_hash_find(const char *);
79 const char *mdoc_a2att(const char *);
80 const char *mdoc_a2lib(const char *);
81 const char *mdoc_a2st(const char *);
82 const char *mdoc_a2arch(const char *);
83 void mdoc_argv(struct roff_man *, int, int,
84 struct mdoc_arg **, int *, char *);
85 enum margserr mdoc_args(struct roff_man *, int,
86 int *, char *, int, char **);
87 enum mdelim mdoc_isdelim(const char *);
88
89 __END_DECLS