]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_term.c
1 /* $Id: mdoc_term.c,v 1.60 2009/07/24 11:54:54 kristaps Exp $ */
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
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.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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.
17 #include <sys/types.h>
29 /* FIXME: macro arguments can be escaped. */
32 #define TTYPE_CMD_FLAG 1
33 #define TTYPE_CMD_ARG 2
34 #define TTYPE_SECTION 3
35 #define TTYPE_FUNC_DECL 4
36 #define TTYPE_VAR_DECL 5
37 #define TTYPE_FUNC_TYPE 6
38 #define TTYPE_FUNC_NAME 7
39 #define TTYPE_FUNC_ARG 8
41 #define TTYPE_SSECTION 10
44 #define TTYPE_CONFIG 13
46 #define TTYPE_INCLUDE 15
48 #define TTYPE_SYMBOL 17
50 #define TTYPE_LINK_ANCHOR 19
51 #define TTYPE_LINK_TEXT 20
52 #define TTYPE_REF_JOURNAL 21
53 #define TTYPE_REF_TITLE 22
57 const int ttypes
[TTYPE_NMAX
] = {
58 TERMP_BOLD
, /* TTYPE_PROG */
59 TERMP_BOLD
, /* TTYPE_CMD_FLAG */
60 TERMP_UNDER
, /* TTYPE_CMD_ARG */
61 TERMP_BOLD
, /* TTYPE_SECTION */
62 TERMP_BOLD
, /* TTYPE_FUNC_DECL */
63 TERMP_UNDER
, /* TTYPE_VAR_DECL */
64 TERMP_UNDER
, /* TTYPE_FUNC_TYPE */
65 TERMP_BOLD
, /* TTYPE_FUNC_NAME */
66 TERMP_UNDER
, /* TTYPE_FUNC_ARG */
67 TERMP_UNDER
, /* TTYPE_LINK */
68 TERMP_BOLD
, /* TTYPE_SSECTION */
69 TERMP_UNDER
, /* TTYPE_FILE */
70 TERMP_UNDER
, /* TTYPE_EMPH */
71 TERMP_BOLD
, /* TTYPE_CONFIG */
72 TERMP_BOLD
, /* TTYPE_CMD */
73 TERMP_BOLD
, /* TTYPE_INCLUDE */
74 TERMP_BOLD
, /* TTYPE_SYMB */
75 TERMP_BOLD
, /* TTYPE_SYMBOL */
76 TERMP_BOLD
, /* TTYPE_DIAG */
77 TERMP_UNDER
, /* TTYPE_LINK_ANCHOR */
78 TERMP_BOLD
, /* TTYPE_LINK_TEXT */
79 TERMP_UNDER
, /* TTYPE_REF_JOURNAL */
80 TERMP_UNDER
, /* TTYPE_REF_TITLE */
81 TERMP_BOLD
/* TTYPE_LIST */
85 struct termpair
*ppair
;
90 #define DECL_ARGS struct termp *p, \
91 struct termpair *pair, \
92 const struct mdoc_meta *meta, \
93 const struct mdoc_node *node
96 int (*pre
)(DECL_ARGS
);
97 void (*post
)(DECL_ARGS
);
100 static void termp____post(DECL_ARGS
);
101 static void termp_aq_post(DECL_ARGS
);
102 static void termp_bd_post(DECL_ARGS
);
103 static void termp_bl_post(DECL_ARGS
);
104 static void termp_bq_post(DECL_ARGS
);
105 static void termp_brq_post(DECL_ARGS
);
106 static void termp_bx_post(DECL_ARGS
);
107 static void termp_d1_post(DECL_ARGS
);
108 static void termp_dq_post(DECL_ARGS
);
109 static void termp_fd_post(DECL_ARGS
);
110 static void termp_fn_post(DECL_ARGS
);
111 static void termp_fo_post(DECL_ARGS
);
112 static void termp_ft_post(DECL_ARGS
);
113 static void termp_in_post(DECL_ARGS
);
114 static void termp_it_post(DECL_ARGS
);
115 static void termp_lb_post(DECL_ARGS
);
116 static void termp_op_post(DECL_ARGS
);
117 static void termp_pf_post(DECL_ARGS
);
118 static void termp_pq_post(DECL_ARGS
);
119 static void termp_qq_post(DECL_ARGS
);
120 static void termp_sh_post(DECL_ARGS
);
121 static void termp_sq_post(DECL_ARGS
);
122 static void termp_ss_post(DECL_ARGS
);
123 static void termp_vt_post(DECL_ARGS
);
125 static int termp__j_pre(DECL_ARGS
);
126 static int termp__t_pre(DECL_ARGS
);
127 static int termp_ap_pre(DECL_ARGS
);
128 static int termp_aq_pre(DECL_ARGS
);
129 static int termp_ar_pre(DECL_ARGS
);
130 static int termp_bd_pre(DECL_ARGS
);
131 static int termp_bf_pre(DECL_ARGS
);
132 static int termp_bq_pre(DECL_ARGS
);
133 static int termp_br_pre(DECL_ARGS
);
134 static int termp_brq_pre(DECL_ARGS
);
135 static int termp_bt_pre(DECL_ARGS
);
136 static int termp_cd_pre(DECL_ARGS
);
137 static int termp_cm_pre(DECL_ARGS
);
138 static int termp_d1_pre(DECL_ARGS
);
139 static int termp_dq_pre(DECL_ARGS
);
140 static int termp_em_pre(DECL_ARGS
);
141 static int termp_ex_pre(DECL_ARGS
);
142 static int termp_fa_pre(DECL_ARGS
);
143 static int termp_fd_pre(DECL_ARGS
);
144 static int termp_fl_pre(DECL_ARGS
);
145 static int termp_fn_pre(DECL_ARGS
);
146 static int termp_fo_pre(DECL_ARGS
);
147 static int termp_ft_pre(DECL_ARGS
);
148 static int termp_ic_pre(DECL_ARGS
);
149 static int termp_in_pre(DECL_ARGS
);
150 static int termp_it_pre(DECL_ARGS
);
151 static int termp_lk_pre(DECL_ARGS
);
152 static int termp_ms_pre(DECL_ARGS
);
153 static int termp_mt_pre(DECL_ARGS
);
154 static int termp_nd_pre(DECL_ARGS
);
155 static int termp_nm_pre(DECL_ARGS
);
156 static int termp_ns_pre(DECL_ARGS
);
157 static int termp_op_pre(DECL_ARGS
);
158 static int termp_pa_pre(DECL_ARGS
);
159 static int termp_pf_pre(DECL_ARGS
);
160 static int termp_pp_pre(DECL_ARGS
);
161 static int termp_pq_pre(DECL_ARGS
);
162 static int termp_qq_pre(DECL_ARGS
);
163 static int termp_rs_pre(DECL_ARGS
);
164 static int termp_rv_pre(DECL_ARGS
);
165 static int termp_sh_pre(DECL_ARGS
);
166 static int termp_sm_pre(DECL_ARGS
);
167 static int termp_sp_pre(DECL_ARGS
);
168 static int termp_sq_pre(DECL_ARGS
);
169 static int termp_ss_pre(DECL_ARGS
);
170 static int termp_sx_pre(DECL_ARGS
);
171 static int termp_sy_pre(DECL_ARGS
);
172 static int termp_ud_pre(DECL_ARGS
);
173 static int termp_va_pre(DECL_ARGS
);
174 static int termp_vt_pre(DECL_ARGS
);
175 static int termp_xr_pre(DECL_ARGS
);
176 static int termp_xx_pre(DECL_ARGS
);
178 static const struct termact termacts
[MDOC_MAX
] = {
179 { termp_ap_pre
, NULL
}, /* Ap */
180 { NULL
, NULL
}, /* Dd */
181 { NULL
, NULL
}, /* Dt */
182 { NULL
, NULL
}, /* Os */
183 { termp_sh_pre
, termp_sh_post
}, /* Sh */
184 { termp_ss_pre
, termp_ss_post
}, /* Ss */
185 { termp_pp_pre
, NULL
}, /* Pp */
186 { termp_d1_pre
, termp_d1_post
}, /* D1 */
187 { termp_d1_pre
, termp_d1_post
}, /* Dl */
188 { termp_bd_pre
, termp_bd_post
}, /* Bd */
189 { NULL
, NULL
}, /* Ed */
190 { NULL
, termp_bl_post
}, /* Bl */
191 { NULL
, NULL
}, /* El */
192 { termp_it_pre
, termp_it_post
}, /* It */
193 { NULL
, NULL
}, /* Ad */
194 { NULL
, NULL
}, /* An */
195 { termp_ar_pre
, NULL
}, /* Ar */
196 { termp_cd_pre
, NULL
}, /* Cd */
197 { termp_cm_pre
, NULL
}, /* Cm */
198 { NULL
, NULL
}, /* Dv */
199 { NULL
, NULL
}, /* Er */
200 { NULL
, NULL
}, /* Ev */
201 { termp_ex_pre
, NULL
}, /* Ex */
202 { termp_fa_pre
, NULL
}, /* Fa */
203 { termp_fd_pre
, termp_fd_post
}, /* Fd */
204 { termp_fl_pre
, NULL
}, /* Fl */
205 { termp_fn_pre
, termp_fn_post
}, /* Fn */
206 { termp_ft_pre
, termp_ft_post
}, /* Ft */
207 { termp_ic_pre
, NULL
}, /* Ic */
208 { termp_in_pre
, termp_in_post
}, /* In */
209 { NULL
, NULL
}, /* Li */
210 { termp_nd_pre
, NULL
}, /* Nd */
211 { termp_nm_pre
, NULL
}, /* Nm */
212 { termp_op_pre
, termp_op_post
}, /* Op */
213 { NULL
, NULL
}, /* Ot */
214 { termp_pa_pre
, NULL
}, /* Pa */
215 { termp_rv_pre
, NULL
}, /* Rv */
216 { NULL
, NULL
}, /* St */
217 { termp_va_pre
, NULL
}, /* Va */
218 { termp_vt_pre
, termp_vt_post
}, /* Vt */
219 { termp_xr_pre
, NULL
}, /* Xr */
220 { NULL
, termp____post
}, /* %A */
221 { NULL
, termp____post
}, /* %B */
222 { NULL
, termp____post
}, /* %D */
223 { NULL
, termp____post
}, /* %I */
224 { termp__j_pre
, termp____post
}, /* %J */
225 { NULL
, termp____post
}, /* %N */
226 { NULL
, termp____post
}, /* %O */
227 { NULL
, termp____post
}, /* %P */
228 { NULL
, termp____post
}, /* %R */
229 { termp__t_pre
, termp____post
}, /* %T */
230 { NULL
, termp____post
}, /* %V */
231 { NULL
, NULL
}, /* Ac */
232 { termp_aq_pre
, termp_aq_post
}, /* Ao */
233 { termp_aq_pre
, termp_aq_post
}, /* Aq */
234 { NULL
, NULL
}, /* At */
235 { NULL
, NULL
}, /* Bc */
236 { termp_bf_pre
, NULL
}, /* Bf */
237 { termp_bq_pre
, termp_bq_post
}, /* Bo */
238 { termp_bq_pre
, termp_bq_post
}, /* Bq */
239 { termp_xx_pre
, NULL
}, /* Bsx */
240 { NULL
, termp_bx_post
}, /* Bx */
241 { NULL
, NULL
}, /* Db */
242 { NULL
, NULL
}, /* Dc */
243 { termp_dq_pre
, termp_dq_post
}, /* Do */
244 { termp_dq_pre
, termp_dq_post
}, /* Dq */
245 { NULL
, NULL
}, /* Ec */
246 { NULL
, NULL
}, /* Ef */
247 { termp_em_pre
, NULL
}, /* Em */
248 { NULL
, NULL
}, /* Eo */
249 { termp_xx_pre
, NULL
}, /* Fx */
250 { termp_ms_pre
, NULL
}, /* Ms */
251 { NULL
, NULL
}, /* No */
252 { termp_ns_pre
, NULL
}, /* Ns */
253 { termp_xx_pre
, NULL
}, /* Nx */
254 { termp_xx_pre
, NULL
}, /* Ox */
255 { NULL
, NULL
}, /* Pc */
256 { termp_pf_pre
, termp_pf_post
}, /* Pf */
257 { termp_pq_pre
, termp_pq_post
}, /* Po */
258 { termp_pq_pre
, termp_pq_post
}, /* Pq */
259 { NULL
, NULL
}, /* Qc */
260 { termp_sq_pre
, termp_sq_post
}, /* Ql */
261 { termp_qq_pre
, termp_qq_post
}, /* Qo */
262 { termp_qq_pre
, termp_qq_post
}, /* Qq */
263 { NULL
, NULL
}, /* Re */
264 { termp_rs_pre
, NULL
}, /* Rs */
265 { NULL
, NULL
}, /* Sc */
266 { termp_sq_pre
, termp_sq_post
}, /* So */
267 { termp_sq_pre
, termp_sq_post
}, /* Sq */
268 { termp_sm_pre
, NULL
}, /* Sm */
269 { termp_sx_pre
, NULL
}, /* Sx */
270 { termp_sy_pre
, NULL
}, /* Sy */
271 { NULL
, NULL
}, /* Tn */
272 { termp_xx_pre
, NULL
}, /* Ux */
273 { NULL
, NULL
}, /* Xc */
274 { NULL
, NULL
}, /* Xo */
275 { termp_fo_pre
, termp_fo_post
}, /* Fo */
276 { NULL
, NULL
}, /* Fc */
277 { termp_op_pre
, termp_op_post
}, /* Oo */
278 { NULL
, NULL
}, /* Oc */
279 { NULL
, NULL
}, /* Bk */
280 { NULL
, NULL
}, /* Ek */
281 { termp_bt_pre
, NULL
}, /* Bt */
282 { NULL
, NULL
}, /* Hf */
283 { NULL
, NULL
}, /* Fr */
284 { termp_ud_pre
, NULL
}, /* Ud */
285 { NULL
, termp_lb_post
}, /* Lb */
286 { termp_pp_pre
, NULL
}, /* Lp */
287 { termp_lk_pre
, NULL
}, /* Lk */
288 { termp_mt_pre
, NULL
}, /* Mt */
289 { termp_brq_pre
, termp_brq_post
}, /* Brq */
290 { termp_brq_pre
, termp_brq_post
}, /* Bro */
291 { NULL
, NULL
}, /* Brc */
292 { NULL
, NULL
}, /* %C */
293 { NULL
, NULL
}, /* Es */
294 { NULL
, NULL
}, /* En */
295 { termp_xx_pre
, NULL
}, /* Dx */
296 { NULL
, NULL
}, /* %Q */
297 { termp_br_pre
, NULL
}, /* br */
298 { termp_sp_pre
, NULL
}, /* sp */
302 extern size_t strlcpy(char *, const char *, size_t);
303 extern size_t strlcat(char *, const char *, size_t);
306 static int arg_hasattr(int, const struct mdoc_node
*);
307 static int arg_getattrs(const int *, int *, size_t,
308 const struct mdoc_node
*);
309 static int arg_getattr(int, const struct mdoc_node
*);
310 static size_t arg_offset(const struct mdoc_argv
*);
311 static size_t arg_width(const struct mdoc_argv
*, int);
312 static int arg_listtype(const struct mdoc_node
*);
313 static void fmt_block_vspace(struct termp
*,
314 const struct mdoc_node
*,
315 const struct mdoc_node
*);
316 static void print_node(DECL_ARGS
);
317 static void print_head(struct termp
*,
318 const struct mdoc_meta
*);
319 static void print_body(DECL_ARGS
);
320 static void print_foot(struct termp
*,
321 const struct mdoc_meta
*);
325 mdoc_run(struct termp
*p
, const struct mdoc
*m
)
328 * Main output function. When this is called, assume that the
329 * tree is properly formed.
331 print_head(p
, mdoc_meta(m
));
332 assert(mdoc_node(m
));
333 assert(MDOC_ROOT
== mdoc_node(m
)->type
);
334 if (mdoc_node(m
)->child
)
335 print_body(p
, NULL
, mdoc_meta(m
), mdoc_node(m
)->child
);
336 print_foot(p
, mdoc_meta(m
));
342 print_body(DECL_ARGS
)
345 print_node(p
, pair
, meta
, node
);
348 print_body(p
, pair
, meta
, node
->next
);
353 print_node(DECL_ARGS
)
356 struct termpair npair
;
357 size_t offset
, rmargin
;
361 rmargin
= p
->rmargin
;
368 * Note on termpair. This allows a pre function to set a termp
369 * flag that is automatically unset after the body, but before
370 * the post function. Thus, if a pre uses a termpair flag, it
371 * must be reapplied in the post for use.
374 if (MDOC_TEXT
!= node
->type
) {
375 if (termacts
[node
->tok
].pre
)
376 if ( ! (*termacts
[node
->tok
].pre
)(p
, &npair
, meta
, node
))
378 } else /* MDOC_TEXT == node->type */
379 term_word(p
, node
->string
);
383 p
->flags
|= npair
.flag
;
385 if (dochild
&& node
->child
)
386 print_body(p
, &npair
, meta
, node
->child
);
388 p
->flags
&= ~npair
.flag
;
390 /* Post-processing. */
392 if (MDOC_TEXT
!= node
->type
)
393 if (termacts
[node
->tok
].post
)
394 (*termacts
[node
->tok
].post
)(p
, &npair
, meta
, node
);
397 p
->rmargin
= rmargin
;
402 print_foot(struct termp
*p
, const struct mdoc_meta
*meta
)
408 * Output the footer in new-groff style, that is, three columns
409 * with the middle being the manual date and flanking columns
410 * being the operating system:
415 if (NULL
== (buf
= malloc(p
->rmargin
)))
417 if (NULL
== (os
= malloc(p
->rmargin
)))
420 tm
= localtime(&meta
->date
);
422 if (0 == strftime(buf
, p
->rmargin
, "%B %e, %Y", tm
))
425 (void)strlcpy(os
, meta
->os
, p
->rmargin
);
430 p
->rmargin
= (p
->maxrmargin
- strlen(buf
) + 1) / 2;
431 p
->flags
|= TERMP_NOSPACE
| TERMP_NOBREAK
;
436 p
->offset
= p
->rmargin
;
437 p
->rmargin
= p
->maxrmargin
- strlen(os
);
438 p
->flags
|= TERMP_NOLPAD
| TERMP_NOSPACE
;
443 p
->offset
= p
->rmargin
;
444 p
->rmargin
= p
->maxrmargin
;
445 p
->flags
&= ~TERMP_NOBREAK
;
446 p
->flags
|= TERMP_NOLPAD
| TERMP_NOSPACE
;
452 p
->rmargin
= p
->maxrmargin
;
461 print_head(struct termp
*p
, const struct mdoc_meta
*meta
)
465 p
->rmargin
= p
->maxrmargin
;
468 if (NULL
== (buf
= malloc(p
->rmargin
)))
470 if (NULL
== (title
= malloc(p
->rmargin
)))
474 * The header is strange. It has three components, which are
475 * really two with the first duplicated. It goes like this:
477 * IDENTIFIER TITLE IDENTIFIER
479 * The IDENTIFIER is NAME(SECTION), which is the command-name
480 * (if given, or "unknown" if not) followed by the manual page
481 * section. These are given in `Dt'. The TITLE is a free-form
482 * string depending on the manual volume. If not specified, it
483 * switches on the manual section.
487 (void)strlcpy(buf
, meta
->vol
, p
->rmargin
);
490 (void)strlcat(buf
, " (", p
->rmargin
);
491 (void)strlcat(buf
, meta
->arch
, p
->rmargin
);
492 (void)strlcat(buf
, ")", p
->rmargin
);
495 (void)snprintf(title
, p
->rmargin
, "%s(%d)",
496 meta
->title
, meta
->msec
);
499 p
->rmargin
= (p
->maxrmargin
- strlen(buf
) + 1) / 2;
500 p
->flags
|= TERMP_NOBREAK
| TERMP_NOSPACE
;
505 p
->offset
= p
->rmargin
;
506 p
->rmargin
= p
->maxrmargin
- strlen(title
);
507 p
->flags
|= TERMP_NOLPAD
| TERMP_NOSPACE
;
512 p
->offset
= p
->rmargin
;
513 p
->rmargin
= p
->maxrmargin
;
514 p
->flags
&= ~TERMP_NOBREAK
;
515 p
->flags
|= TERMP_NOLPAD
| TERMP_NOSPACE
;
521 p
->rmargin
= p
->maxrmargin
;
522 p
->flags
&= ~TERMP_NOSPACE
;
530 arg_width(const struct mdoc_argv
*arg
, int pos
)
535 assert(pos
< (int)arg
->sz
&& pos
>= 0);
536 assert(arg
->value
[pos
]);
540 if (0 == (len
= (int)strlen(p
)))
543 for (i
= 0; i
< len
- 1; i
++)
544 if ( ! isdigit((u_char
)p
[i
]))
548 if ('n' == p
[len
- 1] || 'm' == p
[len
- 1])
549 return((size_t)atoi(p
) + 2);
551 return((size_t)len
+ 2);
556 arg_listtype(const struct mdoc_node
*n
)
560 assert(MDOC_BLOCK
== n
->type
);
562 len
= (int)(n
->args
? n
->args
->argc
: 0);
564 for (i
= 0; i
< len
; i
++)
565 switch (n
->args
->argv
[i
].arg
) {
587 return(n
->args
->argv
[i
].arg
);
597 arg_offset(const struct mdoc_argv
*arg
)
605 if (0 == strcmp(p
, "left"))
607 if (0 == strcmp(p
, "indent"))
609 if (0 == strcmp(p
, "indent-two"))
610 return((INDENT
+ 1) * 2);
612 if (0 == (len
= (int)strlen(p
)))
615 for (i
= 0; i
< len
- 1; i
++)
616 if ( ! isdigit((u_char
)p
[i
]))
620 if ('n' == p
[len
- 1] || 'm' == p
[len
- 1])
621 return((size_t)atoi(p
));
628 arg_hasattr(int arg
, const struct mdoc_node
*n
)
631 return(-1 != arg_getattr(arg
, n
));
636 arg_getattr(int v
, const struct mdoc_node
*n
)
640 return(arg_getattrs(&v
, &val
, 1, n
) ? val
: -1);
645 arg_getattrs(const int *keys
, int *vals
,
646 size_t sz
, const struct mdoc_node
*n
)
653 for (k
= i
= 0; i
< (int)n
->args
->argc
; i
++)
654 for (j
= 0; j
< (int)sz
; j
++)
655 if (n
->args
->argv
[i
].arg
== keys
[j
]) {
665 fmt_block_vspace(struct termp
*p
,
666 const struct mdoc_node
*bl
,
667 const struct mdoc_node
*node
)
669 const struct mdoc_node
*n
;
673 if (MDOC_Bl
== bl
->tok
&& arg_hasattr(MDOC_Compact
, bl
))
677 * Search through our prior nodes. If we follow a `Ss' or `Sh',
681 for (n
= node
; n
; n
= n
->parent
) {
682 if (MDOC_BLOCK
!= n
->type
)
684 if (MDOC_Ss
== n
->tok
)
686 if (MDOC_Sh
== n
->tok
)
694 * XXX - not documented: a `-column' does not ever assert vspace
698 if (MDOC_Bl
== bl
->tok
&& arg_hasattr(MDOC_Column
, bl
))
699 if (node
->prev
&& MDOC_It
== node
->prev
->tok
)
703 * XXX - not documented: a `-diag' without a body does not
704 * assert a vspace prior to the next element.
706 if (MDOC_Bl
== bl
->tok
&& arg_hasattr(MDOC_Diag
, bl
))
707 if (node
->prev
&& MDOC_It
== node
->prev
->tok
) {
708 assert(node
->prev
->body
);
709 if (NULL
== node
->prev
->body
->child
)
719 termp_dq_pre(DECL_ARGS
)
722 if (MDOC_BODY
!= node
->type
)
725 term_word(p
, "\\(lq");
726 p
->flags
|= TERMP_NOSPACE
;
733 termp_dq_post(DECL_ARGS
)
736 if (MDOC_BODY
!= node
->type
)
739 p
->flags
|= TERMP_NOSPACE
;
740 term_word(p
, "\\(rq");
746 termp_it_pre(DECL_ARGS
)
748 const struct mdoc_node
*bl
, *n
;
750 int i
, type
, keys
[3], vals
[3];
751 size_t width
, offset
;
753 if (MDOC_BLOCK
== node
->type
) {
754 fmt_block_vspace(p
, node
->parent
->parent
, node
);
758 bl
= node
->parent
->parent
->parent
;
760 /* Save parent attributes. */
762 pair
->flag
= p
->flags
;
764 /* Get list width and offset. */
766 keys
[0] = MDOC_Width
;
767 keys
[1] = MDOC_Offset
;
768 keys
[2] = MDOC_Column
;
770 vals
[0] = vals
[1] = vals
[2] = -1;
774 (void)arg_getattrs(keys
, vals
, 3, bl
);
776 type
= arg_listtype(bl
);
779 /* Calculate real width and offset. */
783 if (MDOC_BODY
== node
->type
)
786 * Work around groff's column handling. The offset is
787 * equal to the sum of all widths leading to the current
788 * column (plus the -offset value). If this column
789 * exceeds the stated number of columns, the width is
790 * set as 0, else it's the stated column width (later
791 * the 0 will be adjusted to default 10 or, if in the
792 * last column case, set to stretch to the margin).
794 for (i
= 0, n
= node
->prev
; n
&& n
&&
795 i
< (int)bl
->args
[vals
[2]].argv
->sz
;
798 (&bl
->args
->argv
[vals
[2]], i
);
800 /* Whether exceeds maximum column. */
801 if (i
< (int)bl
->args
[vals
[2]].argv
->sz
)
802 width
= arg_width(&bl
->args
->argv
[vals
[2]], i
);
807 offset
+= arg_offset(&bl
->args
->argv
[vals
[1]]);
811 width
= arg_width(&bl
->args
->argv
[vals
[0]], 0);
813 offset
+= arg_offset(&bl
->args
->argv
[vals
[1]]);
818 * List-type can override the width in the case of fixed-head
819 * values (bullet, dash/hyphen, enum). Tags need a non-zero
820 * offset. FIXME: double-check that correct.
851 * Whitespace control. Inset bodies need an initial space,
852 * while diagonal bodies need two.
855 p
->flags
|= TERMP_NOSPACE
;
859 term_word(p
, "\\ \\ ");
862 if (MDOC_BODY
== node
->type
)
869 p
->flags
|= TERMP_NOSPACE
;
872 * Style flags. Diagnostic heads need TTYPE_DIAG.
877 if (MDOC_HEAD
== node
->type
)
878 p
->flags
|= ttypes
[TTYPE_DIAG
];
885 * Pad and break control. This is the tricker part. Lists with
886 * set right-margins for the head get TERMP_NOBREAK because, if
887 * they overrun the margin, they wrap to the new margin.
888 * Correspondingly, the body for these types don't left-pad, as
889 * the head will pad out to to the right.
900 if (MDOC_HEAD
== node
->type
)
901 p
->flags
|= TERMP_NOBREAK
;
903 p
->flags
|= TERMP_NOLPAD
;
906 if (MDOC_HEAD
== node
->type
)
907 p
->flags
|= TERMP_NOBREAK
;
909 p
->flags
|= TERMP_NOLPAD
;
911 if (MDOC_HEAD
!= node
->type
)
915 * This is ugly. If `-hang' is specified and the body
916 * is a `Bl' or `Bd', then we want basically to nullify
917 * the "overstep" effect in term_flushln() and treat
918 * this as a `-ohang' list instead.
920 if (node
->next
->child
&&
921 (MDOC_Bl
== node
->next
->child
->tok
||
922 MDOC_Bd
== node
->next
->child
->tok
)) {
923 p
->flags
&= ~TERMP_NOBREAK
;
924 p
->flags
&= ~TERMP_NOLPAD
;
926 p
->flags
|= TERMP_HANG
;
929 if (MDOC_HEAD
== node
->type
)
930 p
->flags
|= TERMP_NOBREAK
| TERMP_TWOSPACE
;
932 p
->flags
|= TERMP_NOLPAD
;
934 if (MDOC_HEAD
!= node
->type
)
936 if (NULL
== node
->next
|| NULL
== node
->next
->child
)
937 p
->flags
|= TERMP_DANGLE
;
940 if (MDOC_HEAD
== node
->type
) {
942 if (MDOC_BODY
== node
->next
->type
)
943 p
->flags
&= ~TERMP_NOBREAK
;
945 p
->flags
|= TERMP_NOBREAK
;
947 p
->flags
|= TERMP_NOLPAD
;
951 if (MDOC_HEAD
== node
->type
)
952 p
->flags
|= TERMP_NOBREAK
;
959 * Margin control. Set-head-width lists have their right
960 * margins shortened. The body for these lists has the offset
961 * necessarily lengthened. Everybody gets the offset.
969 * Same stipulation as above, regarding `-hang'. We
970 * don't want to recalculate rmargin and offsets when
971 * using `Bd' or `Bl' within `-hang' overstep lists.
973 if (MDOC_HEAD
== node
->type
&& node
->next
->child
&&
974 (MDOC_Bl
== node
->next
->child
->tok
||
975 MDOC_Bd
== node
->next
->child
->tok
))
988 if (MDOC_HEAD
== node
->type
)
989 p
->rmargin
= p
->offset
+ width
;
995 p
->rmargin
= p
->offset
+ width
;
997 * XXX - this behaviour is not documented: the
998 * right-most column is filled to the right margin.
1000 if (MDOC_HEAD
== node
->type
&&
1001 MDOC_BODY
== node
->next
->type
)
1002 p
->rmargin
= p
->maxrmargin
;
1009 * The dash, hyphen, bullet and enum lists all have a special
1010 * HEAD character (temporarily bold, in some cases).
1013 if (MDOC_HEAD
== node
->type
)
1016 p
->flags
|= TERMP_BOLD
;
1017 term_word(p
, "\\[bu]");
1018 p
->flags
&= ~TERMP_BOLD
;
1023 p
->flags
|= TERMP_BOLD
;
1024 term_word(p
, "\\(hy");
1025 p
->flags
&= ~TERMP_BOLD
;
1028 (pair
->ppair
->ppair
->count
)++;
1029 (void)snprintf(buf
, sizeof(buf
), "%d.",
1030 pair
->ppair
->ppair
->count
);
1038 * If we're not going to process our children, indicate so here.
1051 if (MDOC_HEAD
== node
->type
)
1055 if (MDOC_BODY
== node
->type
)
1068 termp_it_post(DECL_ARGS
)
1072 if (MDOC_BODY
!= node
->type
&& MDOC_HEAD
!= node
->type
)
1075 type
= arg_listtype(node
->parent
->parent
->parent
);
1084 if (MDOC_BODY
== node
->type
)
1088 if (MDOC_HEAD
== node
->type
)
1096 p
->flags
= pair
->flag
;
1102 termp_nm_pre(DECL_ARGS
)
1105 if (SEC_SYNOPSIS
== node
->sec
)
1108 pair
->flag
|= ttypes
[TTYPE_PROG
];
1109 p
->flags
|= ttypes
[TTYPE_PROG
];
1111 if (NULL
== node
->child
)
1112 term_word(p
, meta
->name
);
1120 termp_fl_pre(DECL_ARGS
)
1123 pair
->flag
|= ttypes
[TTYPE_CMD_FLAG
];
1124 p
->flags
|= ttypes
[TTYPE_CMD_FLAG
];
1125 term_word(p
, "\\-");
1126 p
->flags
|= TERMP_NOSPACE
;
1133 termp_ar_pre(DECL_ARGS
)
1136 pair
->flag
|= ttypes
[TTYPE_CMD_ARG
];
1143 termp_ns_pre(DECL_ARGS
)
1146 p
->flags
|= TERMP_NOSPACE
;
1153 termp_pp_pre(DECL_ARGS
)
1163 termp_rs_pre(DECL_ARGS
)
1166 if (MDOC_BLOCK
== node
->type
&& node
->prev
)
1174 termp_rv_pre(DECL_ARGS
)
1178 i
= arg_getattr(MDOC_Std
, node
);
1180 assert(node
->args
->argv
[i
].sz
);
1183 term_word(p
, "The");
1185 p
->flags
|= ttypes
[TTYPE_FUNC_NAME
];
1186 term_word(p
, *node
->args
->argv
[i
].value
);
1187 p
->flags
&= ~ttypes
[TTYPE_FUNC_NAME
];
1188 p
->flags
|= TERMP_NOSPACE
;
1190 term_word(p
, "() function returns the value 0 if successful;");
1191 term_word(p
, "otherwise the value -1 is returned and the");
1192 term_word(p
, "global variable");
1194 p
->flags
|= ttypes
[TTYPE_VAR_DECL
];
1195 term_word(p
, "errno");
1196 p
->flags
&= ~ttypes
[TTYPE_VAR_DECL
];
1198 term_word(p
, "is set to indicate the error.");
1206 termp_ex_pre(DECL_ARGS
)
1210 i
= arg_getattr(MDOC_Std
, node
);
1212 assert(node
->args
->argv
[i
].sz
);
1214 term_word(p
, "The");
1215 p
->flags
|= ttypes
[TTYPE_PROG
];
1216 term_word(p
, *node
->args
->argv
[i
].value
);
1217 p
->flags
&= ~ttypes
[TTYPE_PROG
];
1218 term_word(p
, "utility exits 0 on success, and >0 if an error occurs.");
1226 termp_nd_pre(DECL_ARGS
)
1229 if (MDOC_BODY
!= node
->type
)
1232 #if defined(__OpenBSD__) || defined(__linux__)
1233 term_word(p
, "\\(en");
1235 term_word(p
, "\\(em");
1243 termp_bl_post(DECL_ARGS
)
1246 if (MDOC_BLOCK
== node
->type
)
1253 termp_op_post(DECL_ARGS
)
1256 if (MDOC_BODY
!= node
->type
)
1258 p
->flags
|= TERMP_NOSPACE
;
1259 term_word(p
, "\\(rB");
1265 termp_xr_pre(DECL_ARGS
)
1267 const struct mdoc_node
*n
;
1269 assert(node
->child
&& MDOC_TEXT
== node
->child
->type
);
1272 term_word(p
, n
->string
);
1273 if (NULL
== (n
= n
->next
))
1275 p
->flags
|= TERMP_NOSPACE
;
1277 p
->flags
|= TERMP_NOSPACE
;
1278 term_word(p
, n
->string
);
1279 p
->flags
|= TERMP_NOSPACE
;
1287 termp_vt_pre(DECL_ARGS
)
1290 /* FIXME: this can be "type name". */
1291 pair
->flag
|= ttypes
[TTYPE_VAR_DECL
];
1298 termp_vt_post(DECL_ARGS
)
1301 if (node
->sec
!= SEC_SYNOPSIS
)
1303 if (node
->next
&& MDOC_Vt
== node
->next
->tok
)
1305 else if (node
->next
)
1312 termp_fd_pre(DECL_ARGS
)
1315 pair
->flag
|= ttypes
[TTYPE_FUNC_DECL
];
1322 termp_fd_post(DECL_ARGS
)
1325 if (node
->sec
!= SEC_SYNOPSIS
)
1329 if (node
->next
&& MDOC_Fd
!= node
->next
->tok
)
1336 termp_sh_pre(DECL_ARGS
)
1339 switch (node
->type
) {
1342 pair
->flag
|= ttypes
[TTYPE_SECTION
];
1356 termp_sh_post(DECL_ARGS
)
1359 switch (node
->type
) {
1375 termp_op_pre(DECL_ARGS
)
1378 switch (node
->type
) {
1380 term_word(p
, "\\(lB");
1381 p
->flags
|= TERMP_NOSPACE
;
1392 termp_bt_pre(DECL_ARGS
)
1395 term_word(p
, "is currently in beta test.");
1402 termp_lb_post(DECL_ARGS
)
1411 termp_ud_pre(DECL_ARGS
)
1414 term_word(p
, "currently under development.");
1421 termp_d1_pre(DECL_ARGS
)
1424 if (MDOC_BLOCK
!= node
->type
)
1427 p
->offset
+= (INDENT
+ 1);
1434 termp_d1_post(DECL_ARGS
)
1437 if (MDOC_BLOCK
!= node
->type
)
1445 termp_aq_pre(DECL_ARGS
)
1448 if (MDOC_BODY
!= node
->type
)
1450 term_word(p
, "\\(la");
1451 p
->flags
|= TERMP_NOSPACE
;
1458 termp_aq_post(DECL_ARGS
)
1461 if (MDOC_BODY
!= node
->type
)
1463 p
->flags
|= TERMP_NOSPACE
;
1464 term_word(p
, "\\(ra");
1470 termp_ft_pre(DECL_ARGS
)
1473 if (SEC_SYNOPSIS
== node
->sec
)
1474 if (node
->prev
&& MDOC_Fo
== node
->prev
->tok
)
1476 pair
->flag
|= ttypes
[TTYPE_FUNC_TYPE
];
1483 termp_ft_post(DECL_ARGS
)
1486 if (SEC_SYNOPSIS
== node
->sec
)
1493 termp_fn_pre(DECL_ARGS
)
1495 const struct mdoc_node
*n
;
1497 assert(node
->child
&& MDOC_TEXT
== node
->child
->type
);
1499 /* FIXME: can be "type funcname" "type varname"... */
1501 p
->flags
|= ttypes
[TTYPE_FUNC_NAME
];
1502 term_word(p
, node
->child
->string
);
1503 p
->flags
&= ~ttypes
[TTYPE_FUNC_NAME
];
1505 p
->flags
|= TERMP_NOSPACE
;
1508 for (n
= node
->child
->next
; n
; n
= n
->next
) {
1509 p
->flags
|= ttypes
[TTYPE_FUNC_ARG
];
1510 term_word(p
, n
->string
);
1511 p
->flags
&= ~ttypes
[TTYPE_FUNC_ARG
];
1518 if (SEC_SYNOPSIS
== node
->sec
)
1527 termp_fn_post(DECL_ARGS
)
1530 if (node
->sec
== SEC_SYNOPSIS
&& node
->next
)
1537 termp_sx_pre(DECL_ARGS
)
1540 pair
->flag
|= ttypes
[TTYPE_LINK
];
1547 termp_fa_pre(DECL_ARGS
)
1549 struct mdoc_node
*n
;
1551 if (node
->parent
->tok
!= MDOC_Fo
) {
1552 pair
->flag
|= ttypes
[TTYPE_FUNC_ARG
];
1556 for (n
= node
->child
; n
; n
= n
->next
) {
1557 p
->flags
|= ttypes
[TTYPE_FUNC_ARG
];
1558 term_word(p
, n
->string
);
1559 p
->flags
&= ~ttypes
[TTYPE_FUNC_ARG
];
1564 if (node
->child
&& node
->next
&& node
->next
->tok
== MDOC_Fa
)
1573 termp_va_pre(DECL_ARGS
)
1576 pair
->flag
|= ttypes
[TTYPE_VAR_DECL
];
1583 termp_bd_pre(DECL_ARGS
)
1588 * This is fairly tricky due primarily to crappy documentation.
1589 * If -ragged or -filled are specified, the block does nothing
1590 * but change the indentation.
1592 * If, on the other hand, -unfilled or -literal are specified,
1593 * then the game changes. Text is printed exactly as entered in
1594 * the display: if a macro line, a newline is appended to the
1595 * line. Blank lines are allowed.
1598 if (MDOC_BLOCK
== node
->type
) {
1599 fmt_block_vspace(p
, node
, node
);
1601 } else if (MDOC_BODY
!= node
->type
)
1604 assert(node
->parent
->args
);
1606 for (type
= -1, i
= 0; -1 == type
&&
1607 i
< (int)node
->parent
->args
->argc
; i
++) {
1608 switch (node
->parent
->args
->argv
[i
].arg
) {
1613 case (MDOC_Unfilled
):
1615 case (MDOC_Literal
):
1616 type
= node
->parent
->args
->argv
[i
].arg
;
1625 i
= arg_getattr(MDOC_Offset
, node
->parent
);
1627 p
->offset
+= arg_offset(&node
->parent
->args
->argv
[i
]);
1630 case (MDOC_Literal
):
1632 case (MDOC_Unfilled
):
1638 for (node
= node
->child
; node
; node
= node
->next
) {
1639 p
->flags
|= TERMP_NOSPACE
;
1640 print_node(p
, pair
, meta
, node
);
1651 termp_bd_post(DECL_ARGS
)
1654 if (MDOC_BODY
!= node
->type
)
1656 p
->flags
|= TERMP_NOSPACE
;
1663 termp_qq_pre(DECL_ARGS
)
1666 if (MDOC_BODY
!= node
->type
)
1669 p
->flags
|= TERMP_NOSPACE
;
1676 termp_qq_post(DECL_ARGS
)
1679 if (MDOC_BODY
!= node
->type
)
1681 p
->flags
|= TERMP_NOSPACE
;
1688 termp_bx_post(DECL_ARGS
)
1692 p
->flags
|= TERMP_NOSPACE
;
1693 term_word(p
, "BSD");
1699 termp_xx_pre(DECL_ARGS
)
1704 switch (node
->tok
) {
1709 pp
= "DragonFlyBSD";
1735 termp_sq_pre(DECL_ARGS
)
1738 if (MDOC_BODY
!= node
->type
)
1740 term_word(p
, "\\(oq");
1741 p
->flags
|= TERMP_NOSPACE
;
1748 termp_sq_post(DECL_ARGS
)
1751 if (MDOC_BODY
!= node
->type
)
1753 p
->flags
|= TERMP_NOSPACE
;
1754 term_word(p
, "\\(aq");
1760 termp_pa_pre(DECL_ARGS
)
1763 pair
->flag
|= ttypes
[TTYPE_FILE
];
1770 termp_pf_pre(DECL_ARGS
)
1773 p
->flags
|= TERMP_IGNDELIM
;
1780 termp_pf_post(DECL_ARGS
)
1783 p
->flags
&= ~TERMP_IGNDELIM
;
1784 p
->flags
|= TERMP_NOSPACE
;
1790 termp_ss_pre(DECL_ARGS
)
1793 switch (node
->type
) {
1800 pair
->flag
|= ttypes
[TTYPE_SSECTION
];
1801 p
->offset
= HALFINDENT
;
1813 termp_ss_post(DECL_ARGS
)
1816 if (MDOC_HEAD
== node
->type
)
1823 termp_em_pre(DECL_ARGS
)
1826 pair
->flag
|= ttypes
[TTYPE_EMPH
];
1833 termp_cd_pre(DECL_ARGS
)
1836 pair
->flag
|= ttypes
[TTYPE_CONFIG
];
1844 termp_cm_pre(DECL_ARGS
)
1847 pair
->flag
|= ttypes
[TTYPE_CMD_FLAG
];
1854 termp_ic_pre(DECL_ARGS
)
1857 pair
->flag
|= ttypes
[TTYPE_CMD
];
1864 termp_in_pre(DECL_ARGS
)
1867 pair
->flag
|= ttypes
[TTYPE_INCLUDE
];
1868 p
->flags
|= ttypes
[TTYPE_INCLUDE
];
1870 if (SEC_SYNOPSIS
== node
->sec
)
1871 term_word(p
, "#include");
1874 p
->flags
|= TERMP_NOSPACE
;
1881 termp_in_post(DECL_ARGS
)
1884 p
->flags
|= TERMP_NOSPACE
| ttypes
[TTYPE_INCLUDE
];
1886 p
->flags
&= ~ttypes
[TTYPE_INCLUDE
];
1888 if (SEC_SYNOPSIS
!= node
->sec
)
1893 * XXX Not entirely correct. If `.In foo bar' is specified in
1894 * the SYNOPSIS section, then it produces a single break after
1895 * the <foo>; mandoc asserts a vertical space. Since this
1896 * construction is rarely used, I think it's fine.
1898 if (node
->next
&& MDOC_In
!= node
->next
->tok
)
1905 termp_sp_pre(DECL_ARGS
)
1909 if (NULL
== node
->child
) {
1914 len
= atoi(node
->child
->string
);
1917 for (i
= 0; i
< len
; i
++)
1926 termp_br_pre(DECL_ARGS
)
1936 termp_brq_pre(DECL_ARGS
)
1939 if (MDOC_BODY
!= node
->type
)
1941 term_word(p
, "\\(lC");
1942 p
->flags
|= TERMP_NOSPACE
;
1949 termp_brq_post(DECL_ARGS
)
1952 if (MDOC_BODY
!= node
->type
)
1954 p
->flags
|= TERMP_NOSPACE
;
1955 term_word(p
, "\\(rC");
1961 termp_bq_pre(DECL_ARGS
)
1964 if (MDOC_BODY
!= node
->type
)
1966 term_word(p
, "\\(lB");
1967 p
->flags
|= TERMP_NOSPACE
;
1974 termp_bq_post(DECL_ARGS
)
1977 if (MDOC_BODY
!= node
->type
)
1979 p
->flags
|= TERMP_NOSPACE
;
1980 term_word(p
, "\\(rB");
1986 termp_pq_pre(DECL_ARGS
)
1989 if (MDOC_BODY
!= node
->type
)
1991 term_word(p
, "\\&(");
1992 p
->flags
|= TERMP_NOSPACE
;
1999 termp_pq_post(DECL_ARGS
)
2002 if (MDOC_BODY
!= node
->type
)
2010 termp_fo_pre(DECL_ARGS
)
2012 const struct mdoc_node
*n
;
2014 if (MDOC_BODY
== node
->type
) {
2015 p
->flags
|= TERMP_NOSPACE
;
2017 p
->flags
|= TERMP_NOSPACE
;
2019 } else if (MDOC_HEAD
!= node
->type
)
2022 p
->flags
|= ttypes
[TTYPE_FUNC_NAME
];
2023 for (n
= node
->child
; n
; n
= n
->next
) {
2024 assert(MDOC_TEXT
== n
->type
);
2025 term_word(p
, n
->string
);
2027 p
->flags
&= ~ttypes
[TTYPE_FUNC_NAME
];
2035 termp_fo_post(DECL_ARGS
)
2038 if (MDOC_BODY
!= node
->type
)
2040 p
->flags
|= TERMP_NOSPACE
;
2042 p
->flags
|= TERMP_NOSPACE
;
2050 termp_bf_pre(DECL_ARGS
)
2052 const struct mdoc_node
*n
;
2054 if (MDOC_HEAD
== node
->type
)
2056 else if (MDOC_BLOCK
!= node
->type
)
2059 if (NULL
== (n
= node
->head
->child
)) {
2060 if (arg_hasattr(MDOC_Emphasis
, node
))
2061 pair
->flag
|= ttypes
[TTYPE_EMPH
];
2062 else if (arg_hasattr(MDOC_Symbolic
, node
))
2063 pair
->flag
|= ttypes
[TTYPE_SYMB
];
2068 assert(MDOC_TEXT
== n
->type
);
2069 if (0 == strcmp("Em", n
->string
))
2070 pair
->flag
|= ttypes
[TTYPE_EMPH
];
2071 else if (0 == strcmp("Sy", n
->string
))
2072 pair
->flag
|= ttypes
[TTYPE_SYMB
];
2080 termp_sy_pre(DECL_ARGS
)
2083 pair
->flag
|= ttypes
[TTYPE_SYMB
];
2090 termp_ms_pre(DECL_ARGS
)
2093 pair
->flag
|= ttypes
[TTYPE_SYMBOL
];
2101 termp_sm_pre(DECL_ARGS
)
2104 assert(node
->child
&& MDOC_TEXT
== node
->child
->type
);
2105 if (0 == strcmp("on", node
->child
->string
)) {
2106 p
->flags
&= ~TERMP_NONOSPACE
;
2107 p
->flags
&= ~TERMP_NOSPACE
;
2109 p
->flags
|= TERMP_NONOSPACE
;
2117 termp_ap_pre(DECL_ARGS
)
2120 p
->flags
|= TERMP_NOSPACE
;
2121 term_word(p
, "\\(aq");
2122 p
->flags
|= TERMP_NOSPACE
;
2129 termp__j_pre(DECL_ARGS
)
2132 pair
->flag
|= ttypes
[TTYPE_REF_JOURNAL
];
2139 termp__t_pre(DECL_ARGS
)
2142 pair
->flag
|= ttypes
[TTYPE_REF_TITLE
];
2149 termp____post(DECL_ARGS
)
2152 p
->flags
|= TERMP_NOSPACE
;
2153 term_word(p
, node
->next
? "," : ".");
2159 termp_lk_pre(DECL_ARGS
)
2161 const struct mdoc_node
*n
;
2163 assert(node
->child
);
2166 if (NULL
== n
->next
) {
2167 pair
->flag
|= ttypes
[TTYPE_LINK_ANCHOR
];
2171 p
->flags
|= ttypes
[TTYPE_LINK_ANCHOR
];
2172 term_word(p
, n
->string
);
2173 p
->flags
|= TERMP_NOSPACE
;
2175 p
->flags
&= ~ttypes
[TTYPE_LINK_ANCHOR
];
2177 p
->flags
|= ttypes
[TTYPE_LINK_TEXT
];
2178 for (n
= n
->next
; n
; n
= n
->next
)
2179 term_word(p
, n
->string
);
2181 p
->flags
&= ~ttypes
[TTYPE_LINK_TEXT
];
2188 termp_mt_pre(DECL_ARGS
)
2191 pair
->flag
|= ttypes
[TTYPE_LINK_ANCHOR
];