Annotation of mandoc/mdoc_term.c, Revision 1.315
1.315 ! schwarze 1: /* $Id: mdoc_term.c,v 1.314 2015/04/02 21:36:50 schwarze Exp $ */
1.1 kristaps 2: /*
1.217 schwarze 3: * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.303 schwarze 4: * Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
1.256 schwarze 5: * Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
1.1 kristaps 6: *
7: * Permission to use, copy, modify, and distribute this software for any
1.6 kristaps 8: * purpose with or without fee is hereby granted, provided that the above
9: * copyright notice and this permission notice appear in all copies.
1.1 kristaps 10: *
1.314 schwarze 11: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
1.6 kristaps 12: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1.314 schwarze 13: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
1.6 kristaps 14: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1 kristaps 18: */
1.107 kristaps 19: #include "config.h"
20:
1.1 kristaps 21: #include <sys/types.h>
22:
23: #include <assert.h>
24: #include <ctype.h>
1.302 schwarze 25: #include <limits.h>
1.118 kristaps 26: #include <stdint.h>
1.1 kristaps 27: #include <stdio.h>
28: #include <stdlib.h>
29: #include <string.h>
30:
1.314 schwarze 31: #include "mandoc_aux.h"
1.125 kristaps 32: #include "mandoc.h"
1.314 schwarze 33: #include "roff.h"
34: #include "mdoc.h"
1.92 kristaps 35: #include "out.h"
1.1 kristaps 36: #include "term.h"
1.89 kristaps 37: #include "main.h"
1.1 kristaps 38:
39: struct termpair {
40: struct termpair *ppair;
1.31 kristaps 41: int count;
1.1 kristaps 42: };
43:
1.31 kristaps 44: #define DECL_ARGS struct termp *p, \
45: struct termpair *pair, \
1.264 schwarze 46: const struct mdoc_meta *meta, \
1.315 ! schwarze 47: struct roff_node *n
1.1 kristaps 48:
49: struct termact {
50: int (*pre)(DECL_ARGS);
51: void (*post)(DECL_ARGS);
52: };
53:
1.302 schwarze 54: static int a2width(const struct termp *, const char *);
1.96 kristaps 55:
56: static void print_bvspace(struct termp *,
1.315 ! schwarze 57: const struct roff_node *,
! 58: const struct roff_node *);
1.264 schwarze 59: static void print_mdoc_node(DECL_ARGS);
1.145 kristaps 60: static void print_mdoc_nodelist(DECL_ARGS);
1.144 kristaps 61: static void print_mdoc_head(struct termp *, const void *);
1.145 kristaps 62: static void print_mdoc_foot(struct termp *, const void *);
1.264 schwarze 63: static void synopsis_pre(struct termp *,
1.315 ! schwarze 64: const struct roff_node *);
1.96 kristaps 65:
1.31 kristaps 66: static void termp____post(DECL_ARGS);
1.203 kristaps 67: static void termp__t_post(DECL_ARGS);
1.31 kristaps 68: static void termp_bd_post(DECL_ARGS);
1.159 schwarze 69: static void termp_bk_post(DECL_ARGS);
1.31 kristaps 70: static void termp_bl_post(DECL_ARGS);
1.306 schwarze 71: static void termp_eo_post(DECL_ARGS);
1.241 schwarze 72: static void termp_fd_post(DECL_ARGS);
1.31 kristaps 73: static void termp_fo_post(DECL_ARGS);
74: static void termp_in_post(DECL_ARGS);
75: static void termp_it_post(DECL_ARGS);
76: static void termp_lb_post(DECL_ARGS);
1.164 schwarze 77: static void termp_nm_post(DECL_ARGS);
1.31 kristaps 78: static void termp_pf_post(DECL_ARGS);
1.188 kristaps 79: static void termp_quote_post(DECL_ARGS);
1.31 kristaps 80: static void termp_sh_post(DECL_ARGS);
81: static void termp_ss_post(DECL_ARGS);
82:
1.184 kristaps 83: static int termp__a_pre(DECL_ARGS);
1.203 kristaps 84: static int termp__t_pre(DECL_ARGS);
1.61 kristaps 85: static int termp_an_pre(DECL_ARGS);
1.31 kristaps 86: static int termp_ap_pre(DECL_ARGS);
87: static int termp_bd_pre(DECL_ARGS);
88: static int termp_bf_pre(DECL_ARGS);
1.159 schwarze 89: static int termp_bk_pre(DECL_ARGS);
1.115 kristaps 90: static int termp_bl_pre(DECL_ARGS);
1.69 kristaps 91: static int termp_bold_pre(DECL_ARGS);
1.31 kristaps 92: static int termp_bt_pre(DECL_ARGS);
1.211 kristaps 93: static int termp_bx_pre(DECL_ARGS);
1.31 kristaps 94: static int termp_cd_pre(DECL_ARGS);
95: static int termp_d1_pre(DECL_ARGS);
1.306 schwarze 96: static int termp_eo_pre(DECL_ARGS);
1.31 kristaps 97: static int termp_ex_pre(DECL_ARGS);
98: static int termp_fa_pre(DECL_ARGS);
1.188 kristaps 99: static int termp_fd_pre(DECL_ARGS);
1.31 kristaps 100: static int termp_fl_pre(DECL_ARGS);
101: static int termp_fn_pre(DECL_ARGS);
102: static int termp_fo_pre(DECL_ARGS);
103: static int termp_ft_pre(DECL_ARGS);
104: static int termp_in_pre(DECL_ARGS);
105: static int termp_it_pre(DECL_ARGS);
1.102 kristaps 106: static int termp_li_pre(DECL_ARGS);
1.260 schwarze 107: static int termp_ll_pre(DECL_ARGS);
1.31 kristaps 108: static int termp_lk_pre(DECL_ARGS);
109: static int termp_nd_pre(DECL_ARGS);
110: static int termp_nm_pre(DECL_ARGS);
111: static int termp_ns_pre(DECL_ARGS);
1.188 kristaps 112: static int termp_quote_pre(DECL_ARGS);
1.31 kristaps 113: static int termp_rs_pre(DECL_ARGS);
114: static int termp_rv_pre(DECL_ARGS);
115: static int termp_sh_pre(DECL_ARGS);
1.294 schwarze 116: static int termp_skip_pre(DECL_ARGS);
1.31 kristaps 117: static int termp_sm_pre(DECL_ARGS);
1.45 kristaps 118: static int termp_sp_pre(DECL_ARGS);
1.31 kristaps 119: static int termp_ss_pre(DECL_ARGS);
1.69 kristaps 120: static int termp_under_pre(DECL_ARGS);
1.31 kristaps 121: static int termp_ud_pre(DECL_ARGS);
1.110 kristaps 122: static int termp_vt_pre(DECL_ARGS);
1.31 kristaps 123: static int termp_xr_pre(DECL_ARGS);
124: static int termp_xx_pre(DECL_ARGS);
125:
1.70 kristaps 126: static const struct termact termacts[MDOC_MAX] = {
1.14 kristaps 127: { termp_ap_pre, NULL }, /* Ap */
1.1 kristaps 128: { NULL, NULL }, /* Dd */
129: { NULL, NULL }, /* Dt */
130: { NULL, NULL }, /* Os */
131: { termp_sh_pre, termp_sh_post }, /* Sh */
1.264 schwarze 132: { termp_ss_pre, termp_ss_post }, /* Ss */
133: { termp_sp_pre, NULL }, /* Pp */
1.241 schwarze 134: { termp_d1_pre, termp_bl_post }, /* D1 */
135: { termp_d1_pre, termp_bl_post }, /* Dl */
1.1 kristaps 136: { termp_bd_pre, termp_bd_post }, /* Bd */
137: { NULL, NULL }, /* Ed */
1.115 kristaps 138: { termp_bl_pre, termp_bl_post }, /* Bl */
1.1 kristaps 139: { NULL, NULL }, /* El */
140: { termp_it_pre, termp_it_post }, /* It */
1.264 schwarze 141: { termp_under_pre, NULL }, /* Ad */
1.282 schwarze 142: { termp_an_pre, NULL }, /* An */
1.69 kristaps 143: { termp_under_pre, NULL }, /* Ar */
1.1 kristaps 144: { termp_cd_pre, NULL }, /* Cd */
1.69 kristaps 145: { termp_bold_pre, NULL }, /* Cm */
1.264 schwarze 146: { NULL, NULL }, /* Dv */
147: { NULL, NULL }, /* Er */
148: { NULL, NULL }, /* Ev */
1.1 kristaps 149: { termp_ex_pre, NULL }, /* Ex */
1.264 schwarze 150: { termp_fa_pre, NULL }, /* Fa */
151: { termp_fd_pre, termp_fd_post }, /* Fd */
1.1 kristaps 152: { termp_fl_pre, NULL }, /* Fl */
1.264 schwarze 153: { termp_fn_pre, NULL }, /* Fn */
154: { termp_ft_pre, NULL }, /* Ft */
155: { termp_bold_pre, NULL }, /* Ic */
156: { termp_in_pre, termp_in_post }, /* In */
1.102 kristaps 157: { termp_li_pre, NULL }, /* Li */
1.264 schwarze 158: { termp_nd_pre, NULL }, /* Nd */
159: { termp_nm_pre, termp_nm_post }, /* Nm */
1.188 kristaps 160: { termp_quote_pre, termp_quote_post }, /* Op */
1.268 schwarze 161: { termp_ft_pre, NULL }, /* Ot */
1.69 kristaps 162: { termp_under_pre, NULL }, /* Pa */
1.1 kristaps 163: { termp_rv_pre, NULL }, /* Rv */
1.264 schwarze 164: { NULL, NULL }, /* St */
1.69 kristaps 165: { termp_under_pre, NULL }, /* Va */
1.143 kristaps 166: { termp_vt_pre, NULL }, /* Vt */
1.1 kristaps 167: { termp_xr_pre, NULL }, /* Xr */
1.184 kristaps 168: { termp__a_pre, termp____post }, /* %A */
1.84 kristaps 169: { termp_under_pre, termp____post }, /* %B */
1.1 kristaps 170: { NULL, termp____post }, /* %D */
1.84 kristaps 171: { termp_under_pre, termp____post }, /* %I */
1.69 kristaps 172: { termp_under_pre, termp____post }, /* %J */
1.1 kristaps 173: { NULL, termp____post }, /* %N */
174: { NULL, termp____post }, /* %O */
175: { NULL, termp____post }, /* %P */
176: { NULL, termp____post }, /* %R */
1.203 kristaps 177: { termp__t_pre, termp__t_post }, /* %T */
1.1 kristaps 178: { NULL, termp____post }, /* %V */
179: { NULL, NULL }, /* Ac */
1.188 kristaps 180: { termp_quote_pre, termp_quote_post }, /* Ao */
181: { termp_quote_pre, termp_quote_post }, /* Aq */
1.35 kristaps 182: { NULL, NULL }, /* At */
1.1 kristaps 183: { NULL, NULL }, /* Bc */
1.264 schwarze 184: { termp_bf_pre, NULL }, /* Bf */
1.188 kristaps 185: { termp_quote_pre, termp_quote_post }, /* Bo */
186: { termp_quote_pre, termp_quote_post }, /* Bq */
1.26 kristaps 187: { termp_xx_pre, NULL }, /* Bsx */
1.211 kristaps 188: { termp_bx_pre, NULL }, /* Bx */
1.294 schwarze 189: { termp_skip_pre, NULL }, /* Db */
1.1 kristaps 190: { NULL, NULL }, /* Dc */
1.188 kristaps 191: { termp_quote_pre, termp_quote_post }, /* Do */
192: { termp_quote_pre, termp_quote_post }, /* Dq */
1.112 kristaps 193: { NULL, NULL }, /* Ec */ /* FIXME: no space */
1.1 kristaps 194: { NULL, NULL }, /* Ef */
1.264 schwarze 195: { termp_under_pre, NULL }, /* Em */
1.306 schwarze 196: { termp_eo_pre, termp_eo_post }, /* Eo */
1.26 kristaps 197: { termp_xx_pre, NULL }, /* Fx */
1.176 kristaps 198: { termp_bold_pre, NULL }, /* Ms */
1.290 schwarze 199: { termp_li_pre, NULL }, /* No */
1.1 kristaps 200: { termp_ns_pre, NULL }, /* Ns */
1.26 kristaps 201: { termp_xx_pre, NULL }, /* Nx */
202: { termp_xx_pre, NULL }, /* Ox */
1.1 kristaps 203: { NULL, NULL }, /* Pc */
1.254 schwarze 204: { NULL, termp_pf_post }, /* Pf */
1.188 kristaps 205: { termp_quote_pre, termp_quote_post }, /* Po */
206: { termp_quote_pre, termp_quote_post }, /* Pq */
1.1 kristaps 207: { NULL, NULL }, /* Qc */
1.188 kristaps 208: { termp_quote_pre, termp_quote_post }, /* Ql */
209: { termp_quote_pre, termp_quote_post }, /* Qo */
210: { termp_quote_pre, termp_quote_post }, /* Qq */
1.1 kristaps 211: { NULL, NULL }, /* Re */
212: { termp_rs_pre, NULL }, /* Rs */
213: { NULL, NULL }, /* Sc */
1.188 kristaps 214: { termp_quote_pre, termp_quote_post }, /* So */
215: { termp_quote_pre, termp_quote_post }, /* Sq */
1.1 kristaps 216: { termp_sm_pre, NULL }, /* Sm */
1.69 kristaps 217: { termp_under_pre, NULL }, /* Sx */
218: { termp_bold_pre, NULL }, /* Sy */
1.1 kristaps 219: { NULL, NULL }, /* Tn */
1.26 kristaps 220: { termp_xx_pre, NULL }, /* Ux */
1.1 kristaps 221: { NULL, NULL }, /* Xc */
222: { NULL, NULL }, /* Xo */
1.264 schwarze 223: { termp_fo_pre, termp_fo_post }, /* Fo */
224: { NULL, NULL }, /* Fc */
1.188 kristaps 225: { termp_quote_pre, termp_quote_post }, /* Oo */
1.1 kristaps 226: { NULL, NULL }, /* Oc */
1.159 schwarze 227: { termp_bk_pre, termp_bk_post }, /* Bk */
1.1 kristaps 228: { NULL, NULL }, /* Ek */
229: { termp_bt_pre, NULL }, /* Bt */
230: { NULL, NULL }, /* Hf */
1.268 schwarze 231: { termp_under_pre, NULL }, /* Fr */
1.1 kristaps 232: { termp_ud_pre, NULL }, /* Ud */
1.37 kristaps 233: { NULL, termp_lb_post }, /* Lb */
1.264 schwarze 234: { termp_sp_pre, NULL }, /* Lp */
235: { termp_lk_pre, NULL }, /* Lk */
236: { termp_under_pre, NULL }, /* Mt */
237: { termp_quote_pre, termp_quote_post }, /* Brq */
238: { termp_quote_pre, termp_quote_post }, /* Bro */
239: { NULL, NULL }, /* Brc */
240: { NULL, termp____post }, /* %C */
1.294 schwarze 241: { termp_skip_pre, NULL }, /* Es */
1.268 schwarze 242: { termp_quote_pre, termp_quote_post }, /* En */
1.264 schwarze 243: { termp_xx_pre, NULL }, /* Dx */
244: { NULL, termp____post }, /* %Q */
1.76 kristaps 245: { termp_sp_pre, NULL }, /* br */
1.264 schwarze 246: { termp_sp_pre, NULL }, /* sp */
247: { NULL, termp____post }, /* %U */
248: { NULL, NULL }, /* Ta */
1.260 schwarze 249: { termp_ll_pre, NULL }, /* ll */
1.1 kristaps 250: };
251:
252:
1.70 kristaps 253: void
1.89 kristaps 254: terminal_mdoc(void *arg, const struct mdoc *mdoc)
1.1 kristaps 255: {
1.245 schwarze 256: const struct mdoc_meta *meta;
1.315 ! schwarze 257: struct roff_node *n;
1.89 kristaps 258: struct termp *p;
259:
260: p = (struct termp *)arg;
1.111 kristaps 261:
262: p->overstep = 0;
1.281 schwarze 263: p->rmargin = p->maxrmargin = p->defrmargin;
1.157 kristaps 264: p->tabwidth = term_len(p, 5);
1.70 kristaps 265:
1.281 schwarze 266: n = mdoc_node(mdoc)->child;
1.245 schwarze 267: meta = mdoc_meta(mdoc);
1.146 schwarze 268:
1.281 schwarze 269: if (p->synopsisonly) {
270: while (n != NULL) {
271: if (n->tok == MDOC_Sh && n->sec == SEC_SYNOPSIS) {
272: if (n->child->next->child != NULL)
273: print_mdoc_nodelist(p, NULL,
274: meta, n->child->next->child);
275: term_newln(p);
276: break;
277: }
278: n = n->next;
279: }
280: } else {
281: if (p->defindent == 0)
282: p->defindent = 5;
283: term_begin(p, print_mdoc_head, print_mdoc_foot, meta);
284: if (n != NULL) {
285: if (n->tok != MDOC_Sh)
286: term_vspace(p);
287: print_mdoc_nodelist(p, NULL, meta, n);
288: }
289: term_end(p);
1.271 schwarze 290: }
1.1 kristaps 291: }
292:
1.3 kristaps 293: static void
1.102 kristaps 294: print_mdoc_nodelist(DECL_ARGS)
1.1 kristaps 295: {
296:
1.304 schwarze 297: while (n != NULL) {
298: print_mdoc_node(p, pair, meta, n);
299: n = n->next;
300: }
1.1 kristaps 301: }
302:
1.3 kristaps 303: static void
1.102 kristaps 304: print_mdoc_node(DECL_ARGS)
1.1 kristaps 305: {
1.102 kristaps 306: int chld;
1.1 kristaps 307: struct termpair npair;
1.30 kristaps 308: size_t offset, rmargin;
1.1 kristaps 309:
1.70 kristaps 310: chld = 1;
1.29 kristaps 311: offset = p->offset;
1.30 kristaps 312: rmargin = p->rmargin;
1.310 schwarze 313: n->flags &= ~MDOC_ENDED;
1.305 schwarze 314: n->prev_font = p->fonti;
1.29 kristaps 315:
1.97 kristaps 316: memset(&npair, 0, sizeof(struct termpair));
1.1 kristaps 317: npair.ppair = pair;
1.172 kristaps 318:
319: /*
320: * Keeps only work until the end of a line. If a keep was
321: * invoked in a prior line, revert it to PREKEEP.
322: */
323:
1.307 schwarze 324: if (p->flags & TERMP_KEEP && n->flags & MDOC_LINE) {
325: p->flags &= ~TERMP_KEEP;
326: p->flags |= TERMP_PREKEEP;
1.172 kristaps 327: }
1.197 schwarze 328:
329: /*
1.217 schwarze 330: * After the keep flags have been set up, we may now
331: * produce output. Note that some pre-handlers do so.
332: */
333:
334: switch (n->type) {
1.314 schwarze 335: case ROFFT_TEXT:
1.217 schwarze 336: if (' ' == *n->string && MDOC_LINE & n->flags)
337: term_newln(p);
1.222 kristaps 338: if (MDOC_DELIMC & n->flags)
339: p->flags |= TERMP_NOSPACE;
1.217 schwarze 340: term_word(p, n->string);
1.222 kristaps 341: if (MDOC_DELIMO & n->flags)
342: p->flags |= TERMP_NOSPACE;
1.217 schwarze 343: break;
1.314 schwarze 344: case ROFFT_EQN:
1.284 schwarze 345: if ( ! (n->flags & MDOC_LINE))
346: p->flags |= TERMP_NOSPACE;
1.233 kristaps 347: term_eqn(p, n->eqn);
1.286 schwarze 348: if (n->next != NULL && ! (n->next->flags & MDOC_LINE))
1.285 schwarze 349: p->flags |= TERMP_NOSPACE;
1.217 schwarze 350: break;
1.314 schwarze 351: case ROFFT_TBL:
1.313 schwarze 352: if (p->tbl.cols == NULL)
353: term_newln(p);
1.217 schwarze 354: term_tbl(p, n->span);
355: break;
356: default:
1.295 schwarze 357: if (termacts[n->tok].pre &&
358: (n->end == ENDBODY_NOT || n->nchild))
1.217 schwarze 359: chld = (*termacts[n->tok].pre)
1.245 schwarze 360: (p, &npair, meta, n);
1.217 schwarze 361: break;
362: }
363:
1.86 kristaps 364: if (chld && n->child)
1.245 schwarze 365: print_mdoc_nodelist(p, &npair, meta, n->child);
1.1 kristaps 366:
1.244 schwarze 367: term_fontpopq(p,
1.310 schwarze 368: (ENDBODY_NOT == n->end ? n : n->body)->prev_font);
1.46 kristaps 369:
1.206 kristaps 370: switch (n->type) {
1.314 schwarze 371: case ROFFT_TEXT:
1.206 kristaps 372: break;
1.314 schwarze 373: case ROFFT_TBL:
1.216 kristaps 374: break;
1.314 schwarze 375: case ROFFT_EQN:
1.206 kristaps 376: break;
377: default:
378: if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags)
379: break;
1.245 schwarze 380: (void)(*termacts[n->tok].post)(p, &npair, meta, n);
1.162 schwarze 381:
382: /*
383: * Explicit end tokens not only call the post
384: * handler, but also tell the respective block
385: * that it must not call the post handler again.
386: */
1.165 kristaps 387: if (ENDBODY_NOT != n->end)
1.310 schwarze 388: n->body->flags |= MDOC_ENDED;
1.162 schwarze 389:
390: /*
391: * End of line terminating an implicit block
392: * while an explicit block is still open.
393: * Continue the explicit block without spacing.
394: */
395: if (ENDBODY_NOSPACE == n->end)
396: p->flags |= TERMP_NOSPACE;
1.206 kristaps 397: break;
1.162 schwarze 398: }
1.121 kristaps 399:
400: if (MDOC_EOS & n->flags)
401: p->flags |= TERMP_SENTENCE;
1.29 kristaps 402:
1.260 schwarze 403: if (MDOC_ll != n->tok) {
404: p->offset = offset;
405: p->rmargin = rmargin;
406: }
1.1 kristaps 407: }
408:
1.3 kristaps 409: static void
1.145 kristaps 410: print_mdoc_foot(struct termp *p, const void *arg)
1.1 kristaps 411: {
1.245 schwarze 412: const struct mdoc_meta *meta;
1.292 schwarze 413: size_t sz;
1.144 kristaps 414:
1.245 schwarze 415: meta = (const struct mdoc_meta *)arg;
1.1 kristaps 416:
1.102 kristaps 417: term_fontrepl(p, TERMFONT_NONE);
1.101 kristaps 418:
1.264 schwarze 419: /*
1.9 kristaps 420: * Output the footer in new-groff style, that is, three columns
421: * with the middle being the manual date and flanking columns
422: * being the operating system:
423: *
424: * SYSTEM DATE SYSTEM
425: */
426:
1.1 kristaps 427: term_vspace(p);
428:
1.9 kristaps 429: p->offset = 0;
1.292 schwarze 430: sz = term_strlen(p, meta->date);
431: p->rmargin = p->maxrmargin > sz ?
432: (p->maxrmargin + term_len(p, 1) - sz) / 2 : 0;
1.250 schwarze 433: p->trailspace = 1;
1.1 kristaps 434: p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
435:
1.245 schwarze 436: term_word(p, meta->os);
1.1 kristaps 437: term_flushln(p);
438:
1.9 kristaps 439: p->offset = p->rmargin;
1.292 schwarze 440: sz = term_strlen(p, meta->os);
441: p->rmargin = p->maxrmargin > sz ? p->maxrmargin - sz : 0;
1.234 schwarze 442: p->flags |= TERMP_NOSPACE;
1.9 kristaps 443:
1.245 schwarze 444: term_word(p, meta->date);
1.9 kristaps 445: term_flushln(p);
446:
1.1 kristaps 447: p->offset = p->rmargin;
448: p->rmargin = p->maxrmargin;
1.250 schwarze 449: p->trailspace = 0;
1.1 kristaps 450: p->flags &= ~TERMP_NOBREAK;
1.234 schwarze 451: p->flags |= TERMP_NOSPACE;
1.1 kristaps 452:
1.245 schwarze 453: term_word(p, meta->os);
1.1 kristaps 454: term_flushln(p);
455:
1.9 kristaps 456: p->offset = 0;
457: p->rmargin = p->maxrmargin;
458: p->flags = 0;
1.1 kristaps 459: }
460:
1.3 kristaps 461: static void
1.144 kristaps 462: print_mdoc_head(struct termp *p, const void *arg)
1.1 kristaps 463: {
1.266 schwarze 464: const struct mdoc_meta *meta;
1.267 schwarze 465: char *volume, *title;
466: size_t vollen, titlen;
1.144 kristaps 467:
1.245 schwarze 468: meta = (const struct mdoc_meta *)arg;
1.1 kristaps 469:
470: /*
471: * The header is strange. It has three components, which are
472: * really two with the first duplicated. It goes like this:
473: *
474: * IDENTIFIER TITLE IDENTIFIER
475: *
476: * The IDENTIFIER is NAME(SECTION), which is the command-name
477: * (if given, or "unknown" if not) followed by the manual page
478: * section. These are given in `Dt'. The TITLE is a free-form
479: * string depending on the manual volume. If not specified, it
480: * switches on the manual section.
481: */
1.235 schwarze 482:
1.245 schwarze 483: assert(meta->vol);
1.267 schwarze 484: if (NULL == meta->arch)
485: volume = mandoc_strdup(meta->vol);
486: else
487: mandoc_asprintf(&volume, "%s (%s)",
488: meta->vol, meta->arch);
489: vollen = term_strlen(p, volume);
1.1 kristaps 490:
1.275 schwarze 491: if (NULL == meta->msec)
492: title = mandoc_strdup(meta->title);
493: else
494: mandoc_asprintf(&title, "%s(%s)",
495: meta->title, meta->msec);
1.235 schwarze 496: titlen = term_strlen(p, title);
1.1 kristaps 497:
1.235 schwarze 498: p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
1.250 schwarze 499: p->trailspace = 1;
1.1 kristaps 500: p->offset = 0;
1.267 schwarze 501: p->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ?
502: (p->maxrmargin - vollen + term_len(p, 1)) / 2 :
1.292 schwarze 503: vollen < p->maxrmargin ? p->maxrmargin - vollen : 0;
1.1 kristaps 504:
505: term_word(p, title);
506: term_flushln(p);
507:
1.235 schwarze 508: p->flags |= TERMP_NOSPACE;
1.1 kristaps 509: p->offset = p->rmargin;
1.267 schwarze 510: p->rmargin = p->offset + vollen + titlen < p->maxrmargin ?
1.235 schwarze 511: p->maxrmargin - titlen : p->maxrmargin;
1.1 kristaps 512:
1.267 schwarze 513: term_word(p, volume);
1.1 kristaps 514: term_flushln(p);
515:
516: p->flags &= ~TERMP_NOBREAK;
1.250 schwarze 517: p->trailspace = 0;
1.235 schwarze 518: if (p->rmargin + titlen <= p->maxrmargin) {
519: p->flags |= TERMP_NOSPACE;
520: p->offset = p->rmargin;
521: p->rmargin = p->maxrmargin;
522: term_word(p, title);
523: term_flushln(p);
524: }
1.1 kristaps 525:
1.235 schwarze 526: p->flags &= ~TERMP_NOSPACE;
1.9 kristaps 527: p->offset = 0;
1.1 kristaps 528: p->rmargin = p->maxrmargin;
1.266 schwarze 529: free(title);
1.267 schwarze 530: free(volume);
1.1 kristaps 531: }
532:
1.302 schwarze 533: static int
1.157 kristaps 534: a2width(const struct termp *p, const char *v)
1.91 kristaps 535: {
1.92 kristaps 536: struct roffsu su;
1.1 kristaps 537:
1.300 schwarze 538: if (a2roffsu(v, &su, SCALE_MAX) < 2) {
1.157 kristaps 539: SCALE_HS_INIT(&su, term_strlen(p, v));
1.283 schwarze 540: su.scale /= term_strlen(p, "0");
1.302 schwarze 541: }
1.157 kristaps 542: return(term_hspan(p, &su));
1.1 kristaps 543: }
544:
1.108 kristaps 545: /*
546: * Determine how much space to print out before block elements of `It'
547: * (and thus `Bl') and `Bd'. And then go ahead and print that space,
548: * too.
549: */
1.54 kristaps 550: static void
1.264 schwarze 551: print_bvspace(struct termp *p,
1.315 ! schwarze 552: const struct roff_node *bl,
! 553: const struct roff_node *n)
1.1 kristaps 554: {
1.315 ! schwarze 555: const struct roff_node *nn;
1.236 schwarze 556:
557: assert(n);
1.1 kristaps 558:
559: term_newln(p);
1.150 kristaps 560:
1.202 kristaps 561: if (MDOC_Bd == bl->tok && bl->norm->Bd.comp)
1.150 kristaps 562: return;
1.202 kristaps 563: if (MDOC_Bl == bl->tok && bl->norm->Bl.comp)
1.54 kristaps 564: return;
565:
1.85 kristaps 566: /* Do not vspace directly after Ss/Sh. */
1.1 kristaps 567:
1.289 schwarze 568: nn = n;
569: while (nn->prev == NULL) {
570: do {
571: nn = nn->parent;
1.314 schwarze 572: if (nn->type == ROFFT_ROOT)
1.289 schwarze 573: return;
1.314 schwarze 574: } while (nn->type != ROFFT_BLOCK);
1.289 schwarze 575: if (nn->tok == MDOC_Sh || nn->tok == MDOC_Ss)
1.54 kristaps 576: return;
1.289 schwarze 577: if (nn->tok == MDOC_It &&
578: nn->parent->parent->norm->Bl.type != LIST_item)
579: break;
1.1 kristaps 580: }
581:
1.85 kristaps 582: /* A `-column' does not assert vspace within the list. */
1.54 kristaps 583:
1.202 kristaps 584: if (MDOC_Bl == bl->tok && LIST_column == bl->norm->Bl.type)
1.86 kristaps 585: if (n->prev && MDOC_It == n->prev->tok)
1.54 kristaps 586: return;
587:
1.85 kristaps 588: /* A `-diag' without body does not vspace. */
589:
1.202 kristaps 590: if (MDOC_Bl == bl->tok && LIST_diag == bl->norm->Bl.type)
1.86 kristaps 591: if (n->prev && MDOC_It == n->prev->tok) {
592: assert(n->prev->body);
593: if (NULL == n->prev->body->child)
1.55 kristaps 594: return;
595: }
596:
1.54 kristaps 597: term_vspace(p);
1.260 schwarze 598: }
599:
600:
601: static int
602: termp_ll_pre(DECL_ARGS)
603: {
604:
1.261 schwarze 605: term_setwidth(p, n->nchild ? n->child->string : NULL);
1.260 schwarze 606: return(0);
1.1 kristaps 607: }
608:
609: static int
610: termp_it_pre(DECL_ARGS)
611: {
1.302 schwarze 612: char buf[24];
1.315 ! schwarze 613: const struct roff_node *bl, *nn;
1.302 schwarze 614: size_t ncols, dcol;
615: int i, offset, width;
1.126 kristaps 616: enum mdoc_list type;
1.1 kristaps 617:
1.314 schwarze 618: if (n->type == ROFFT_BLOCK) {
1.151 kristaps 619: print_bvspace(p, n->parent->parent, n);
1.54 kristaps 620: return(1);
621: }
1.1 kristaps 622:
1.86 kristaps 623: bl = n->parent->parent->parent;
1.202 kristaps 624: type = bl->norm->Bl.type;
1.1 kristaps 625:
1.264 schwarze 626: /*
1.302 schwarze 627: * Defaults for specific list types.
628: */
629:
630: switch (type) {
631: case LIST_bullet:
632: /* FALLTHROUGH */
633: case LIST_dash:
634: /* FALLTHROUGH */
635: case LIST_hyphen:
636: /* FALLTHROUGH */
637: case LIST_enum:
638: width = term_len(p, 2);
639: break;
640: case LIST_hang:
641: width = term_len(p, 8);
642: break;
643: case LIST_column:
644: /* FALLTHROUGH */
645: case LIST_tag:
646: width = term_len(p, 10);
647: break;
648: default:
649: width = 0;
650: break;
651: }
652: offset = 0;
653:
654: /*
1.108 kristaps 655: * First calculate width and offset. This is pretty easy unless
656: * we're a -column list, in which case all prior columns must
657: * be accounted for.
658: */
659:
1.302 schwarze 660: if (bl->norm->Bl.offs != NULL) {
1.288 schwarze 661: offset = a2width(p, bl->norm->Bl.offs);
1.302 schwarze 662: if (offset < 0 && (size_t)(-offset) > p->offset)
663: offset = -p->offset;
664: else if (offset > SHRT_MAX)
665: offset = 0;
666: }
1.152 kristaps 667:
1.1 kristaps 668: switch (type) {
1.264 schwarze 669: case LIST_column:
1.314 schwarze 670: if (n->type == ROFFT_HEAD)
1.1 kristaps 671: break;
1.155 kristaps 672:
1.105 kristaps 673: /*
1.108 kristaps 674: * Imitate groff's column handling:
675: * - For each earlier column, add its width.
676: * - For less than 5 columns, add four more blanks per
677: * column.
678: * - For exactly 5 columns, add three more blank per
679: * column.
680: * - For more than 5 columns, add only one column.
1.105 kristaps 681: */
1.202 kristaps 682: ncols = bl->norm->Bl.ncols;
1.264 schwarze 683: dcol = ncols < 5 ? term_len(p, 4) :
684: ncols == 5 ? term_len(p, 3) : term_len(p, 1);
1.108 kristaps 685:
1.134 kristaps 686: /*
1.314 schwarze 687: * Calculate the offset by applying all prior ROFFT_BODY,
688: * so we stop at the ROFFT_HEAD (nn->prev == NULL).
1.134 kristaps 689: */
690:
1.264 schwarze 691: for (i = 0, nn = n->prev;
692: nn->prev && i < (int)ncols;
693: nn = nn->prev, i++)
694: offset += dcol + a2width(p,
695: bl->norm->Bl.cols[i]);
1.105 kristaps 696:
697: /*
1.108 kristaps 698: * When exceeding the declared number of columns, leave
699: * the remaining widths at 0. This will later be
700: * adjusted to the default width of 10, or, for the last
701: * column, stretched to the right margin.
1.58 kristaps 702: */
1.108 kristaps 703: if (i >= (int)ncols)
704: break;
1.58 kristaps 705:
1.105 kristaps 706: /*
1.108 kristaps 707: * Use the declared column widths, extended as explained
708: * in the preceding paragraph.
1.105 kristaps 709: */
1.202 kristaps 710: width = a2width(p, bl->norm->Bl.cols[i]) + dcol;
1.1 kristaps 711: break;
712: default:
1.202 kristaps 713: if (NULL == bl->norm->Bl.width)
1.108 kristaps 714: break;
715:
1.264 schwarze 716: /*
1.108 kristaps 717: * Note: buffer the width by 2, which is groff's magic
718: * number for buffering single arguments. See the above
719: * handling for column for how this changes.
720: */
1.202 kristaps 721: width = a2width(p, bl->norm->Bl.width) + term_len(p, 2);
1.302 schwarze 722: if (width < 0 && (size_t)(-width) > p->offset)
723: width = -p->offset;
724: else if (width > SHRT_MAX)
725: width = 0;
1.1 kristaps 726: break;
727: }
728:
1.264 schwarze 729: /*
1.17 kristaps 730: * Whitespace control. Inset bodies need an initial space,
731: * while diagonal bodies need two.
1.1 kristaps 732: */
733:
1.51 kristaps 734: p->flags |= TERMP_NOSPACE;
735:
1.1 kristaps 736: switch (type) {
1.264 schwarze 737: case LIST_diag:
1.314 schwarze 738: if (n->type == ROFFT_BODY)
1.62 kristaps 739: term_word(p, "\\ \\ ");
1.51 kristaps 740: break;
1.264 schwarze 741: case LIST_inset:
1.314 schwarze 742: if (n->type == ROFFT_BODY && n->parent->head->nchild)
1.51 kristaps 743: term_word(p, "\\ ");
1.1 kristaps 744: break;
745: default:
746: break;
747: }
748:
1.51 kristaps 749: p->flags |= TERMP_NOSPACE;
750:
1.1 kristaps 751: switch (type) {
1.264 schwarze 752: case LIST_diag:
1.314 schwarze 753: if (n->type == ROFFT_HEAD)
1.102 kristaps 754: term_fontpush(p, TERMFONT_BOLD);
1.1 kristaps 755: break;
756: default:
757: break;
758: }
759:
760: /*
1.109 kristaps 761: * Pad and break control. This is the tricky part. These flags
762: * are documented in term_flushln() in term.c. Note that we're
763: * going to unset all of these flags in termp_it_post() when we
764: * exit.
1.1 kristaps 765: */
766:
767: switch (type) {
1.264 schwarze 768: case LIST_enum:
1.242 schwarze 769: /*
770: * Weird special case.
1.302 schwarze 771: * Some very narrow lists actually hang.
1.242 schwarze 772: */
773: /* FALLTHROUGH */
1.264 schwarze 774: case LIST_bullet:
1.1 kristaps 775: /* FALLTHROUGH */
1.264 schwarze 776: case LIST_dash:
1.1 kristaps 777: /* FALLTHROUGH */
1.264 schwarze 778: case LIST_hyphen:
1.302 schwarze 779: if (width <= (int)term_len(p, 2))
780: p->flags |= TERMP_HANG;
1.314 schwarze 781: if (n->type != ROFFT_HEAD)
1.250 schwarze 782: break;
783: p->flags |= TERMP_NOBREAK;
784: p->trailspace = 1;
1.39 kristaps 785: break;
1.264 schwarze 786: case LIST_hang:
1.314 schwarze 787: if (n->type != ROFFT_HEAD)
1.59 kristaps 788: break;
789:
790: /*
791: * This is ugly. If `-hang' is specified and the body
792: * is a `Bl' or `Bd', then we want basically to nullify
793: * the "overstep" effect in term_flushln() and treat
794: * this as a `-ohang' list instead.
795: */
1.279 schwarze 796: if (NULL != n->next &&
1.278 schwarze 797: NULL != n->next->child &&
798: (MDOC_Bl == n->next->child->tok ||
799: MDOC_Bd == n->next->child->tok))
1.250 schwarze 800: break;
801:
1.263 schwarze 802: p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
1.250 schwarze 803: p->trailspace = 1;
1.39 kristaps 804: break;
1.264 schwarze 805: case LIST_tag:
1.314 schwarze 806: if (n->type != ROFFT_HEAD)
1.39 kristaps 807: break;
1.250 schwarze 808:
1.263 schwarze 809: p->flags |= TERMP_NOBREAK | TERMP_BRIND;
1.250 schwarze 810: p->trailspace = 2;
811:
1.86 kristaps 812: if (NULL == n->next || NULL == n->next->child)
1.39 kristaps 813: p->flags |= TERMP_DANGLE;
1.1 kristaps 814: break;
1.264 schwarze 815: case LIST_column:
1.314 schwarze 816: if (n->type == ROFFT_HEAD)
1.134 kristaps 817: break;
818:
1.250 schwarze 819: if (NULL == n->next) {
1.134 kristaps 820: p->flags &= ~TERMP_NOBREAK;
1.250 schwarze 821: p->trailspace = 0;
822: } else {
1.134 kristaps 823: p->flags |= TERMP_NOBREAK;
1.250 schwarze 824: p->trailspace = 1;
825: }
1.134 kristaps 826:
1.1 kristaps 827: break;
1.264 schwarze 828: case LIST_diag:
1.314 schwarze 829: if (n->type != ROFFT_HEAD)
1.250 schwarze 830: break;
1.263 schwarze 831: p->flags |= TERMP_NOBREAK | TERMP_BRIND;
1.250 schwarze 832: p->trailspace = 1;
1.1 kristaps 833: break;
834: default:
835: break;
836: }
837:
1.264 schwarze 838: /*
1.1 kristaps 839: * Margin control. Set-head-width lists have their right
840: * margins shortened. The body for these lists has the offset
841: * necessarily lengthened. Everybody gets the offset.
842: */
843:
844: p->offset += offset;
845:
846: switch (type) {
1.264 schwarze 847: case LIST_hang:
1.59 kristaps 848: /*
849: * Same stipulation as above, regarding `-hang'. We
850: * don't want to recalculate rmargin and offsets when
851: * using `Bd' or `Bl' within `-hang' overstep lists.
852: */
1.314 schwarze 853: if (n->type == ROFFT_HEAD &&
1.279 schwarze 854: NULL != n->next &&
1.278 schwarze 855: NULL != n->next->child &&
856: (MDOC_Bl == n->next->child->tok ||
857: MDOC_Bd == n->next->child->tok))
1.59 kristaps 858: break;
859: /* FALLTHROUGH */
1.264 schwarze 860: case LIST_bullet:
1.1 kristaps 861: /* FALLTHROUGH */
1.264 schwarze 862: case LIST_dash:
1.1 kristaps 863: /* FALLTHROUGH */
1.264 schwarze 864: case LIST_enum:
1.1 kristaps 865: /* FALLTHROUGH */
1.264 schwarze 866: case LIST_hyphen:
1.1 kristaps 867: /* FALLTHROUGH */
1.264 schwarze 868: case LIST_tag:
1.314 schwarze 869: if (n->type == ROFFT_HEAD)
1.1 kristaps 870: p->rmargin = p->offset + width;
1.292 schwarze 871: else
1.1 kristaps 872: p->offset += width;
873: break;
1.264 schwarze 874: case LIST_column:
1.49 kristaps 875: assert(width);
1.1 kristaps 876: p->rmargin = p->offset + width;
1.264 schwarze 877: /*
1.50 kristaps 878: * XXX - this behaviour is not documented: the
879: * right-most column is filled to the right margin.
880: */
1.314 schwarze 881: if (n->type == ROFFT_HEAD)
1.134 kristaps 882: break;
883: if (NULL == n->next && p->rmargin < p->maxrmargin)
1.50 kristaps 884: p->rmargin = p->maxrmargin;
1.1 kristaps 885: break;
886: default:
887: break;
888: }
889:
1.264 schwarze 890: /*
1.1 kristaps 891: * The dash, hyphen, bullet and enum lists all have a special
1.264 schwarze 892: * HEAD character (temporarily bold, in some cases).
1.1 kristaps 893: */
894:
1.314 schwarze 895: if (n->type == ROFFT_HEAD)
1.1 kristaps 896: switch (type) {
1.264 schwarze 897: case LIST_bullet:
1.102 kristaps 898: term_fontpush(p, TERMFONT_BOLD);
1.1 kristaps 899: term_word(p, "\\[bu]");
1.102 kristaps 900: term_fontpop(p);
1.1 kristaps 901: break;
1.264 schwarze 902: case LIST_dash:
1.1 kristaps 903: /* FALLTHROUGH */
1.264 schwarze 904: case LIST_hyphen:
1.102 kristaps 905: term_fontpush(p, TERMFONT_BOLD);
1.27 kristaps 906: term_word(p, "\\(hy");
1.102 kristaps 907: term_fontpop(p);
1.1 kristaps 908: break;
1.264 schwarze 909: case LIST_enum:
1.1 kristaps 910: (pair->ppair->ppair->count)++;
1.265 schwarze 911: (void)snprintf(buf, sizeof(buf), "%d.",
1.264 schwarze 912: pair->ppair->ppair->count);
1.1 kristaps 913: term_word(p, buf);
914: break;
915: default:
916: break;
917: }
918:
1.264 schwarze 919: /*
1.1 kristaps 920: * If we're not going to process our children, indicate so here.
921: */
922:
923: switch (type) {
1.264 schwarze 924: case LIST_bullet:
1.1 kristaps 925: /* FALLTHROUGH */
1.264 schwarze 926: case LIST_item:
1.1 kristaps 927: /* FALLTHROUGH */
1.264 schwarze 928: case LIST_dash:
1.1 kristaps 929: /* FALLTHROUGH */
1.264 schwarze 930: case LIST_hyphen:
1.1 kristaps 931: /* FALLTHROUGH */
1.264 schwarze 932: case LIST_enum:
1.314 schwarze 933: if (n->type == ROFFT_HEAD)
1.1 kristaps 934: return(0);
935: break;
1.264 schwarze 936: case LIST_column:
1.314 schwarze 937: if (n->type == ROFFT_HEAD)
1.1 kristaps 938: return(0);
939: break;
940: default:
941: break;
942: }
943:
944: return(1);
945: }
946:
947: static void
948: termp_it_post(DECL_ARGS)
949: {
1.126 kristaps 950: enum mdoc_list type;
1.1 kristaps 951:
1.314 schwarze 952: if (n->type == ROFFT_BLOCK)
1.1 kristaps 953: return;
954:
1.202 kristaps 955: type = n->parent->parent->parent->norm->Bl.type;
1.1 kristaps 956:
957: switch (type) {
1.264 schwarze 958: case LIST_item:
1.1 kristaps 959: /* FALLTHROUGH */
1.264 schwarze 960: case LIST_diag:
1.53 kristaps 961: /* FALLTHROUGH */
1.264 schwarze 962: case LIST_inset:
1.314 schwarze 963: if (n->type == ROFFT_BODY)
1.130 schwarze 964: term_newln(p);
1.1 kristaps 965: break;
1.264 schwarze 966: case LIST_column:
1.314 schwarze 967: if (n->type == ROFFT_BODY)
1.1 kristaps 968: term_flushln(p);
969: break;
970: default:
1.130 schwarze 971: term_newln(p);
1.1 kristaps 972: break;
973: }
974:
1.264 schwarze 975: /*
1.109 kristaps 976: * Now that our output is flushed, we can reset our tags. Since
977: * only `It' sets these flags, we're free to assume that nobody
978: * has munged them in the meanwhile.
979: */
980:
1.263 schwarze 981: p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
982: TERMP_DANGLE | TERMP_HANG);
1.250 schwarze 983: p->trailspace = 0;
1.1 kristaps 984: }
985:
986: static int
987: termp_nm_pre(DECL_ARGS)
988: {
1.296 schwarze 989: const char *cp;
1.1 kristaps 990:
1.314 schwarze 991: if (n->type == ROFFT_BLOCK) {
1.253 schwarze 992: p->flags |= TERMP_PREKEEP;
1.164 schwarze 993: return(1);
1.253 schwarze 994: }
1.164 schwarze 995:
1.314 schwarze 996: if (n->type == ROFFT_BODY) {
1.164 schwarze 997: if (NULL == n->child)
998: return(0);
1.234 schwarze 999: p->flags |= TERMP_NOSPACE;
1.296 schwarze 1000: cp = NULL;
1001: if (n->prev->child != NULL)
1002: cp = n->prev->child->string;
1003: if (cp == NULL)
1004: cp = meta->name;
1005: if (cp == NULL)
1006: p->offset += term_len(p, 6);
1007: else
1008: p->offset += term_len(p, 1) + term_strlen(p, cp);
1.164 schwarze 1009: return(1);
1010: }
1011:
1.245 schwarze 1012: if (NULL == n->child && NULL == meta->name)
1.164 schwarze 1013: return(0);
1.125 kristaps 1014:
1.314 schwarze 1015: if (n->type == ROFFT_HEAD)
1.177 schwarze 1016: synopsis_pre(p, n->parent);
1.102 kristaps 1017:
1.314 schwarze 1018: if (n->type == ROFFT_HEAD &&
1.278 schwarze 1019: NULL != n->next && NULL != n->next->child) {
1.263 schwarze 1020: p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_BRIND;
1.250 schwarze 1021: p->trailspace = 1;
1.185 schwarze 1022: p->rmargin = p->offset + term_len(p, 1);
1023: if (NULL == n->child) {
1.245 schwarze 1024: p->rmargin += term_strlen(p, meta->name);
1.314 schwarze 1025: } else if (n->child->type == ROFFT_TEXT) {
1.185 schwarze 1026: p->rmargin += term_strlen(p, n->child->string);
1027: if (n->child->next)
1028: p->flags |= TERMP_HANG;
1029: } else {
1030: p->rmargin += term_len(p, 5);
1031: p->flags |= TERMP_HANG;
1032: }
1.164 schwarze 1033: }
1034:
1.102 kristaps 1035: term_fontpush(p, TERMFONT_BOLD);
1.86 kristaps 1036: if (NULL == n->child)
1.245 schwarze 1037: term_word(p, meta->name);
1.1 kristaps 1038: return(1);
1039: }
1040:
1.164 schwarze 1041: static void
1042: termp_nm_post(DECL_ARGS)
1043: {
1044:
1.314 schwarze 1045: if (n->type == ROFFT_BLOCK) {
1.253 schwarze 1046: p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
1.314 schwarze 1047: } else if (n->type == ROFFT_HEAD &&
1.278 schwarze 1048: NULL != n->next && NULL != n->next->child) {
1.164 schwarze 1049: term_flushln(p);
1.263 schwarze 1050: p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG);
1.250 schwarze 1051: p->trailspace = 0;
1.314 schwarze 1052: } else if (n->type == ROFFT_BODY && n->child != NULL)
1.164 schwarze 1053: term_flushln(p);
1054: }
1055:
1.1 kristaps 1056: static int
1057: termp_fl_pre(DECL_ARGS)
1058: {
1059:
1.102 kristaps 1060: term_fontpush(p, TERMFONT_BOLD);
1.1 kristaps 1061: term_word(p, "\\-");
1.103 kristaps 1062:
1.280 schwarze 1063: if ( ! (n->nchild == 0 &&
1064: (n->next == NULL ||
1.314 schwarze 1065: n->next->type == ROFFT_TEXT ||
1.280 schwarze 1066: n->next->flags & MDOC_LINE)))
1.103 kristaps 1067: p->flags |= TERMP_NOSPACE;
1068:
1.1 kristaps 1069: return(1);
1070: }
1071:
1072: static int
1.184 kristaps 1073: termp__a_pre(DECL_ARGS)
1074: {
1075:
1076: if (n->prev && MDOC__A == n->prev->tok)
1077: if (NULL == n->next || MDOC__A != n->next->tok)
1078: term_word(p, "and");
1079:
1080: return(1);
1081: }
1082:
1083: static int
1.61 kristaps 1084: termp_an_pre(DECL_ARGS)
1085: {
1086:
1.282 schwarze 1087: if (n->norm->An.auth == AUTH_split) {
1088: p->flags &= ~TERMP_NOSPLIT;
1089: p->flags |= TERMP_SPLIT;
1090: return(0);
1091: }
1092: if (n->norm->An.auth == AUTH_nosplit) {
1093: p->flags &= ~TERMP_SPLIT;
1094: p->flags |= TERMP_NOSPLIT;
1095: return(0);
1096: }
1.264 schwarze 1097:
1.282 schwarze 1098: if (p->flags & TERMP_SPLIT)
1.61 kristaps 1099: term_newln(p);
1100:
1.282 schwarze 1101: if (n->sec == SEC_AUTHORS && ! (p->flags & TERMP_NOSPLIT))
1102: p->flags |= TERMP_SPLIT;
1.61 kristaps 1103:
1104: return(1);
1105: }
1106:
1107: static int
1.1 kristaps 1108: termp_ns_pre(DECL_ARGS)
1109: {
1110:
1.215 kristaps 1111: if ( ! (MDOC_LINE & n->flags))
1112: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1113: return(1);
1114: }
1115:
1116: static int
1117: termp_rs_pre(DECL_ARGS)
1118: {
1119:
1.86 kristaps 1120: if (SEC_SEE_ALSO != n->sec)
1.80 kristaps 1121: return(1);
1.314 schwarze 1122: if (n->type == ROFFT_BLOCK && n->prev != NULL)
1.1 kristaps 1123: term_vspace(p);
1124: return(1);
1125: }
1126:
1127: static int
1128: termp_rv_pre(DECL_ARGS)
1129: {
1.223 kristaps 1130: int nchild;
1.1 kristaps 1131:
1132: term_newln(p);
1133:
1.223 kristaps 1134: nchild = n->nchild;
1.273 schwarze 1135: if (nchild > 0) {
1136: term_word(p, "The");
1.224 kristaps 1137:
1.273 schwarze 1138: for (n = n->child; n; n = n->next) {
1139: term_fontpush(p, TERMFONT_BOLD);
1140: term_word(p, n->string);
1141: term_fontpop(p);
1.223 kristaps 1142:
1143: p->flags |= TERMP_NOSPACE;
1.273 schwarze 1144: term_word(p, "()");
1145:
1146: if (n->next == NULL)
1147: continue;
1148:
1149: if (nchild > 2) {
1150: p->flags |= TERMP_NOSPACE;
1151: term_word(p, ",");
1152: }
1153: if (n->next->next == NULL)
1154: term_word(p, "and");
1.223 kristaps 1155: }
1156:
1.273 schwarze 1157: if (nchild > 1)
1158: term_word(p, "functions return");
1159: else
1160: term_word(p, "function returns");
1161:
1162: term_word(p, "the value\\~0 if successful;");
1163: } else
1164: term_word(p, "Upon successful completion,"
1165: " the value\\~0 is returned;");
1.1 kristaps 1166:
1.273 schwarze 1167: term_word(p, "otherwise the value\\~\\-1 is returned"
1168: " and the global variable");
1.1 kristaps 1169:
1.102 kristaps 1170: term_fontpush(p, TERMFONT_UNDER);
1.1 kristaps 1171: term_word(p, "errno");
1.102 kristaps 1172: term_fontpop(p);
1.1 kristaps 1173:
1.264 schwarze 1174: term_word(p, "is set to indicate the error.");
1.131 kristaps 1175: p->flags |= TERMP_SENTENCE;
1.1 kristaps 1176:
1.68 kristaps 1177: return(0);
1.1 kristaps 1178: }
1179:
1180: static int
1181: termp_ex_pre(DECL_ARGS)
1182: {
1.224 kristaps 1183: int nchild;
1.1 kristaps 1184:
1.224 kristaps 1185: term_newln(p);
1.68 kristaps 1186: term_word(p, "The");
1.1 kristaps 1187:
1.224 kristaps 1188: nchild = n->nchild;
1189: for (n = n->child; n; n = n->next) {
1.102 kristaps 1190: term_fontpush(p, TERMFONT_BOLD);
1.224 kristaps 1191: term_word(p, n->string);
1.102 kristaps 1192: term_fontpop(p);
1.224 kristaps 1193:
1194: if (nchild > 2 && n->next) {
1195: p->flags |= TERMP_NOSPACE;
1.68 kristaps 1196: term_word(p, ",");
1.224 kristaps 1197: }
1198:
1199: if (n->next && NULL == n->next->next)
1200: term_word(p, "and");
1.68 kristaps 1201: }
1202:
1.224 kristaps 1203: if (nchild > 1)
1.273 schwarze 1204: term_word(p, "utilities exit\\~0");
1.68 kristaps 1205: else
1.273 schwarze 1206: term_word(p, "utility exits\\~0");
1.68 kristaps 1207:
1.273 schwarze 1208: term_word(p, "on success, and\\~>0 if an error occurs.");
1.224 kristaps 1209:
1.131 kristaps 1210: p->flags |= TERMP_SENTENCE;
1.68 kristaps 1211: return(0);
1.1 kristaps 1212: }
1213:
1214: static int
1215: termp_nd_pre(DECL_ARGS)
1216: {
1.25 kristaps 1217:
1.314 schwarze 1218: if (n->type == ROFFT_BODY)
1.297 schwarze 1219: term_word(p, "\\(en");
1.1 kristaps 1220: return(1);
1.115 kristaps 1221: }
1222:
1223: static int
1224: termp_bl_pre(DECL_ARGS)
1225: {
1226:
1.314 schwarze 1227: return(n->type != ROFFT_HEAD);
1.1 kristaps 1228: }
1229:
1230: static void
1231: termp_bl_post(DECL_ARGS)
1232: {
1233:
1.314 schwarze 1234: if (n->type == ROFFT_BLOCK)
1.1 kristaps 1235: term_newln(p);
1236: }
1237:
1238: static int
1239: termp_xr_pre(DECL_ARGS)
1240: {
1241:
1.225 kristaps 1242: if (NULL == (n = n->child))
1.113 kristaps 1243: return(0);
1244:
1.314 schwarze 1245: assert(n->type == ROFFT_TEXT);
1.225 kristaps 1246: term_word(p, n->string);
1.11 kristaps 1247:
1.264 schwarze 1248: if (NULL == (n = n->next))
1.1 kristaps 1249: return(0);
1.225 kristaps 1250:
1.1 kristaps 1251: p->flags |= TERMP_NOSPACE;
1252: term_word(p, "(");
1.222 kristaps 1253: p->flags |= TERMP_NOSPACE;
1.225 kristaps 1254:
1.314 schwarze 1255: assert(n->type == ROFFT_TEXT);
1.225 kristaps 1256: term_word(p, n->string);
1257:
1.222 kristaps 1258: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1259: term_word(p, ")");
1.86 kristaps 1260:
1.1 kristaps 1261: return(0);
1262: }
1263:
1.143 kristaps 1264: /*
1265: * This decides how to assert whitespace before any of the SYNOPSIS set
1266: * of macros (which, as in the case of Ft/Fo and Ft/Fn, may contain
1267: * macro combos).
1268: */
1269: static void
1.315 ! schwarze 1270: synopsis_pre(struct termp *p, const struct roff_node *n)
1.143 kristaps 1271: {
1.264 schwarze 1272: /*
1.143 kristaps 1273: * Obviously, if we're not in a SYNOPSIS or no prior macros
1274: * exist, do nothing.
1275: */
1.160 kristaps 1276: if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
1.143 kristaps 1277: return;
1278:
1279: /*
1280: * If we're the second in a pair of like elements, emit our
1281: * newline and return. UNLESS we're `Fo', `Fn', `Fn', in which
1282: * case we soldier on.
1283: */
1.264 schwarze 1284: if (n->prev->tok == n->tok &&
1285: MDOC_Ft != n->tok &&
1286: MDOC_Fo != n->tok &&
1287: MDOC_Fn != n->tok) {
1.143 kristaps 1288: term_newln(p);
1289: return;
1290: }
1291:
1292: /*
1293: * If we're one of the SYNOPSIS set and non-like pair-wise after
1294: * another (or Fn/Fo, which we've let slip through) then assert
1295: * vertical space, else only newline and move on.
1296: */
1297: switch (n->prev->tok) {
1.264 schwarze 1298: case MDOC_Fd:
1.143 kristaps 1299: /* FALLTHROUGH */
1.264 schwarze 1300: case MDOC_Fn:
1.143 kristaps 1301: /* FALLTHROUGH */
1.264 schwarze 1302: case MDOC_Fo:
1.143 kristaps 1303: /* FALLTHROUGH */
1.264 schwarze 1304: case MDOC_In:
1.143 kristaps 1305: /* FALLTHROUGH */
1.264 schwarze 1306: case MDOC_Vt:
1.143 kristaps 1307: term_vspace(p);
1308: break;
1.264 schwarze 1309: case MDOC_Ft:
1.143 kristaps 1310: if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
1311: term_vspace(p);
1312: break;
1313: }
1314: /* FALLTHROUGH */
1315: default:
1316: term_newln(p);
1317: break;
1318: }
1319: }
1320:
1.110 kristaps 1321: static int
1322: termp_vt_pre(DECL_ARGS)
1323: {
1324:
1.314 schwarze 1325: if (n->type == ROFFT_ELEM) {
1.143 kristaps 1326: synopsis_pre(p, n);
1.245 schwarze 1327: return(termp_under_pre(p, pair, meta, n));
1.314 schwarze 1328: } else if (n->type == ROFFT_BLOCK) {
1.143 kristaps 1329: synopsis_pre(p, n);
1330: return(1);
1.314 schwarze 1331: } else if (n->type == ROFFT_HEAD)
1.110 kristaps 1332: return(0);
1333:
1.245 schwarze 1334: return(termp_under_pre(p, pair, meta, n));
1.110 kristaps 1335: }
1336:
1.1 kristaps 1337: static int
1.69 kristaps 1338: termp_bold_pre(DECL_ARGS)
1.1 kristaps 1339: {
1340:
1.102 kristaps 1341: term_fontpush(p, TERMFONT_BOLD);
1.1 kristaps 1342: return(1);
1343: }
1344:
1.143 kristaps 1345: static int
1346: termp_fd_pre(DECL_ARGS)
1.1 kristaps 1347: {
1348:
1.143 kristaps 1349: synopsis_pre(p, n);
1.245 schwarze 1350: return(termp_bold_pre(p, pair, meta, n));
1.1 kristaps 1351: }
1352:
1.241 schwarze 1353: static void
1354: termp_fd_post(DECL_ARGS)
1355: {
1356:
1357: term_newln(p);
1358: }
1359:
1.1 kristaps 1360: static int
1361: termp_sh_pre(DECL_ARGS)
1362: {
1.85 kristaps 1363:
1.86 kristaps 1364: switch (n->type) {
1.314 schwarze 1365: case ROFFT_BLOCK:
1.293 schwarze 1366: /*
1367: * Vertical space before sections, except
1368: * when the previous section was empty.
1369: */
1370: if (n->prev == NULL ||
1371: MDOC_Sh != n->prev->tok ||
1372: (n->prev->body != NULL &&
1373: n->prev->body->child != NULL))
1374: term_vspace(p);
1.65 kristaps 1375: break;
1.314 schwarze 1376: case ROFFT_HEAD:
1.102 kristaps 1377: term_fontpush(p, TERMFONT_BOLD);
1.1 kristaps 1378: break;
1.314 schwarze 1379: case ROFFT_BODY:
1.238 schwarze 1380: p->offset = term_len(p, p->defindent);
1.239 schwarze 1381: if (SEC_AUTHORS == n->sec)
1382: p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT);
1.1 kristaps 1383: break;
1384: default:
1385: break;
1386: }
1387: return(1);
1388: }
1389:
1390: static void
1391: termp_sh_post(DECL_ARGS)
1392: {
1393:
1.86 kristaps 1394: switch (n->type) {
1.314 schwarze 1395: case ROFFT_HEAD:
1.1 kristaps 1396: term_newln(p);
1397: break;
1.314 schwarze 1398: case ROFFT_BODY:
1.1 kristaps 1399: term_newln(p);
1400: p->offset = 0;
1401: break;
1402: default:
1403: break;
1404: }
1405: }
1406:
1407: static int
1408: termp_bt_pre(DECL_ARGS)
1409: {
1410:
1411: term_word(p, "is currently in beta test.");
1.131 kristaps 1412: p->flags |= TERMP_SENTENCE;
1.81 kristaps 1413: return(0);
1.1 kristaps 1414: }
1415:
1416: static void
1417: termp_lb_post(DECL_ARGS)
1418: {
1419:
1.122 kristaps 1420: if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags)
1.81 kristaps 1421: term_newln(p);
1.1 kristaps 1422: }
1423:
1424: static int
1425: termp_ud_pre(DECL_ARGS)
1426: {
1427:
1428: term_word(p, "currently under development.");
1.131 kristaps 1429: p->flags |= TERMP_SENTENCE;
1.86 kristaps 1430: return(0);
1.1 kristaps 1431: }
1432:
1433: static int
1434: termp_d1_pre(DECL_ARGS)
1435: {
1436:
1.314 schwarze 1437: if (n->type != ROFFT_BLOCK)
1.1 kristaps 1438: return(1);
1439: term_newln(p);
1.238 schwarze 1440: p->offset += term_len(p, p->defindent + 1);
1.1 kristaps 1441: return(1);
1442: }
1443:
1444: static int
1445: termp_ft_pre(DECL_ARGS)
1446: {
1447:
1.141 kristaps 1448: /* NB: MDOC_LINE does not effect this! */
1.143 kristaps 1449: synopsis_pre(p, n);
1.102 kristaps 1450: term_fontpush(p, TERMFONT_UNDER);
1.1 kristaps 1451: return(1);
1452: }
1453:
1454: static int
1455: termp_fn_pre(DECL_ARGS)
1456: {
1.257 schwarze 1457: size_t rmargin = 0;
1.226 kristaps 1458: int pretty;
1459:
1460: pretty = MDOC_SYNPRETTY & n->flags;
1.1 kristaps 1461:
1.143 kristaps 1462: synopsis_pre(p, n);
1.139 kristaps 1463:
1.226 kristaps 1464: if (NULL == (n = n->child))
1465: return(0);
1466:
1.251 schwarze 1467: if (pretty) {
1468: rmargin = p->rmargin;
1.257 schwarze 1469: p->rmargin = p->offset + term_len(p, 4);
1.263 schwarze 1470: p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
1.251 schwarze 1471: }
1472:
1.314 schwarze 1473: assert(n->type == ROFFT_TEXT);
1.102 kristaps 1474: term_fontpush(p, TERMFONT_BOLD);
1.226 kristaps 1475: term_word(p, n->string);
1.102 kristaps 1476: term_fontpop(p);
1.1 kristaps 1477:
1.251 schwarze 1478: if (pretty) {
1479: term_flushln(p);
1.263 schwarze 1480: p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG);
1.251 schwarze 1481: p->offset = p->rmargin;
1482: p->rmargin = rmargin;
1483: }
1484:
1.1 kristaps 1485: p->flags |= TERMP_NOSPACE;
1486: term_word(p, "(");
1.222 kristaps 1487: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1488:
1.226 kristaps 1489: for (n = n->next; n; n = n->next) {
1.314 schwarze 1490: assert(n->type == ROFFT_TEXT);
1.102 kristaps 1491: term_fontpush(p, TERMFONT_UNDER);
1.255 schwarze 1492: if (pretty)
1493: p->flags |= TERMP_NBRWORD;
1.226 kristaps 1494: term_word(p, n->string);
1.102 kristaps 1495: term_fontpop(p);
1496:
1.226 kristaps 1497: if (n->next) {
1.222 kristaps 1498: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1499: term_word(p, ",");
1.222 kristaps 1500: }
1.1 kristaps 1501: }
1502:
1.222 kristaps 1503: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1504: term_word(p, ")");
1505:
1.226 kristaps 1506: if (pretty) {
1.222 kristaps 1507: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1508: term_word(p, ";");
1.251 schwarze 1509: term_flushln(p);
1.222 kristaps 1510: }
1.1 kristaps 1511:
1512: return(0);
1513: }
1514:
1515: static int
1516: termp_fa_pre(DECL_ARGS)
1517: {
1.315 ! schwarze 1518: const struct roff_node *nn;
1.1 kristaps 1519:
1.86 kristaps 1520: if (n->parent->tok != MDOC_Fo) {
1.102 kristaps 1521: term_fontpush(p, TERMFONT_UNDER);
1.1 kristaps 1522: return(1);
1523: }
1524:
1.86 kristaps 1525: for (nn = n->child; nn; nn = nn->next) {
1.102 kristaps 1526: term_fontpush(p, TERMFONT_UNDER);
1.258 schwarze 1527: p->flags |= TERMP_NBRWORD;
1.86 kristaps 1528: term_word(p, nn->string);
1.102 kristaps 1529: term_fontpop(p);
1530:
1.256 schwarze 1531: if (nn->next || (n->next && n->next->tok == MDOC_Fa)) {
1.222 kristaps 1532: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1533: term_word(p, ",");
1.222 kristaps 1534: }
1.1 kristaps 1535: }
1536:
1537: return(0);
1538: }
1539:
1540: static int
1541: termp_bd_pre(DECL_ARGS)
1542: {
1.272 schwarze 1543: size_t tabwidth, lm, len, rm, rmax;
1.315 ! schwarze 1544: struct roff_node *nn;
1.302 schwarze 1545: int offset;
1.1 kristaps 1546:
1.314 schwarze 1547: if (n->type == ROFFT_BLOCK) {
1.151 kristaps 1548: print_bvspace(p, n, n);
1.54 kristaps 1549: return(1);
1.314 schwarze 1550: } else if (n->type == ROFFT_HEAD)
1.116 kristaps 1551: return(0);
1.1 kristaps 1552:
1.288 schwarze 1553: /* Handle the -offset argument. */
1554:
1555: if (n->norm->Bd.offs == NULL ||
1556: ! strcmp(n->norm->Bd.offs, "left"))
1557: /* nothing */;
1558: else if ( ! strcmp(n->norm->Bd.offs, "indent"))
1559: p->offset += term_len(p, p->defindent + 1);
1560: else if ( ! strcmp(n->norm->Bd.offs, "indent-two"))
1561: p->offset += term_len(p, (p->defindent + 1) * 2);
1.302 schwarze 1562: else {
1563: offset = a2width(p, n->norm->Bd.offs);
1564: if (offset < 0 && (size_t)(-offset) > p->offset)
1565: p->offset = 0;
1566: else if (offset < SHRT_MAX)
1567: p->offset += offset;
1568: }
1.85 kristaps 1569:
1570: /*
1571: * If -ragged or -filled are specified, the block does nothing
1572: * but change the indentation. If -unfilled or -literal are
1573: * specified, text is printed exactly as entered in the display:
1574: * for macro lines, a newline is appended to the line. Blank
1575: * lines are allowed.
1576: */
1.264 schwarze 1577:
1578: if (DISP_literal != n->norm->Bd.type &&
1.272 schwarze 1579: DISP_unfilled != n->norm->Bd.type &&
1580: DISP_centered != n->norm->Bd.type)
1.1 kristaps 1581: return(1);
1582:
1.129 schwarze 1583: tabwidth = p->tabwidth;
1.208 kristaps 1584: if (DISP_literal == n->norm->Bd.type)
1585: p->tabwidth = term_len(p, 8);
1586:
1.272 schwarze 1587: lm = p->offset;
1.119 kristaps 1588: rm = p->rmargin;
1589: rmax = p->maxrmargin;
1.120 kristaps 1590: p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
1.118 kristaps 1591:
1.86 kristaps 1592: for (nn = n->child; nn; nn = nn->next) {
1.272 schwarze 1593: if (DISP_centered == n->norm->Bd.type) {
1.314 schwarze 1594: if (nn->type == ROFFT_TEXT) {
1.272 schwarze 1595: len = term_strlen(p, nn->string);
1596: p->offset = len >= rm ? 0 :
1597: lm + len >= rm ? rm - len :
1598: (lm + rm - len) / 2;
1599: } else
1600: p->offset = lm;
1601: }
1.245 schwarze 1602: print_mdoc_node(p, pair, meta, nn);
1.190 kristaps 1603: /*
1604: * If the printed node flushes its own line, then we
1605: * needn't do it here as well. This is hacky, but the
1606: * notion of selective eoln whitespace is pretty dumb
1607: * anyway, so don't sweat it.
1608: */
1609: switch (nn->tok) {
1.264 schwarze 1610: case MDOC_Sm:
1.193 kristaps 1611: /* FALLTHROUGH */
1.264 schwarze 1612: case MDOC_br:
1.190 kristaps 1613: /* FALLTHROUGH */
1.264 schwarze 1614: case MDOC_sp:
1.190 kristaps 1615: /* FALLTHROUGH */
1.264 schwarze 1616: case MDOC_Bl:
1.196 kristaps 1617: /* FALLTHROUGH */
1.264 schwarze 1618: case MDOC_D1:
1.196 kristaps 1619: /* FALLTHROUGH */
1.264 schwarze 1620: case MDOC_Dl:
1.190 kristaps 1621: /* FALLTHROUGH */
1.264 schwarze 1622: case MDOC_Lp:
1.190 kristaps 1623: /* FALLTHROUGH */
1.264 schwarze 1624: case MDOC_Pp:
1.190 kristaps 1625: continue;
1626: default:
1627: break;
1628: }
1.299 schwarze 1629: if (p->flags & TERMP_NONEWLINE ||
1630: (nn->next && ! (nn->next->flags & MDOC_LINE)))
1.180 schwarze 1631: continue;
1632: term_flushln(p);
1633: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1634: }
1.147 kristaps 1635:
1.129 schwarze 1636: p->tabwidth = tabwidth;
1.119 kristaps 1637: p->rmargin = rm;
1638: p->maxrmargin = rmax;
1.1 kristaps 1639: return(0);
1640: }
1641:
1642: static void
1643: termp_bd_post(DECL_ARGS)
1644: {
1.119 kristaps 1645: size_t rm, rmax;
1.1 kristaps 1646:
1.314 schwarze 1647: if (n->type != ROFFT_BODY)
1.1 kristaps 1648: return;
1.118 kristaps 1649:
1.119 kristaps 1650: rm = p->rmargin;
1651: rmax = p->maxrmargin;
1.118 kristaps 1652:
1.264 schwarze 1653: if (DISP_literal == n->norm->Bd.type ||
1654: DISP_unfilled == n->norm->Bd.type)
1.120 kristaps 1655: p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
1.118 kristaps 1656:
1.60 kristaps 1657: p->flags |= TERMP_NOSPACE;
1.130 schwarze 1658: term_newln(p);
1.118 kristaps 1659:
1.119 kristaps 1660: p->rmargin = rm;
1661: p->maxrmargin = rmax;
1.1 kristaps 1662: }
1663:
1.211 kristaps 1664: static int
1665: termp_bx_pre(DECL_ARGS)
1.1 kristaps 1666: {
1667:
1.211 kristaps 1668: if (NULL != (n = n->child)) {
1669: term_word(p, n->string);
1670: p->flags |= TERMP_NOSPACE;
1671: term_word(p, "BSD");
1672: } else {
1673: term_word(p, "BSD");
1674: return(0);
1675: }
1676:
1677: if (NULL != (n = n->next)) {
1678: p->flags |= TERMP_NOSPACE;
1.213 kristaps 1679: term_word(p, "-");
1.1 kristaps 1680: p->flags |= TERMP_NOSPACE;
1.213 kristaps 1681: term_word(p, n->string);
1.211 kristaps 1682: }
1683:
1684: return(0);
1.1 kristaps 1685: }
1686:
1687: static int
1.26 kristaps 1688: termp_xx_pre(DECL_ARGS)
1.1 kristaps 1689: {
1.26 kristaps 1690: const char *pp;
1.218 schwarze 1691: int flags;
1.1 kristaps 1692:
1.26 kristaps 1693: pp = NULL;
1.86 kristaps 1694: switch (n->tok) {
1.264 schwarze 1695: case MDOC_Bsx:
1.194 schwarze 1696: pp = "BSD/OS";
1.26 kristaps 1697: break;
1.264 schwarze 1698: case MDOC_Dx:
1.100 kristaps 1699: pp = "DragonFly";
1.26 kristaps 1700: break;
1.264 schwarze 1701: case MDOC_Fx:
1.26 kristaps 1702: pp = "FreeBSD";
1703: break;
1.264 schwarze 1704: case MDOC_Nx:
1.26 kristaps 1705: pp = "NetBSD";
1706: break;
1.264 schwarze 1707: case MDOC_Ox:
1.26 kristaps 1708: pp = "OpenBSD";
1709: break;
1.264 schwarze 1710: case MDOC_Ux:
1.26 kristaps 1711: pp = "UNIX";
1712: break;
1713: default:
1.246 schwarze 1714: abort();
1715: /* NOTREACHED */
1.26 kristaps 1716: }
1.1 kristaps 1717:
1.26 kristaps 1718: term_word(p, pp);
1.214 kristaps 1719: if (n->child) {
1.218 schwarze 1720: flags = p->flags;
1.214 kristaps 1721: p->flags |= TERMP_KEEP;
1722: term_word(p, n->child->string);
1.218 schwarze 1723: p->flags = flags;
1.214 kristaps 1724: }
1725: return(0);
1.1 kristaps 1726: }
1727:
1728: static void
1729: termp_pf_post(DECL_ARGS)
1730: {
1731:
1.298 schwarze 1732: if ( ! (n->next == NULL || n->next->flags & MDOC_LINE))
1733: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1734: }
1735:
1736: static int
1737: termp_ss_pre(DECL_ARGS)
1738: {
1739:
1.86 kristaps 1740: switch (n->type) {
1.314 schwarze 1741: case ROFFT_BLOCK:
1.1 kristaps 1742: term_newln(p);
1.86 kristaps 1743: if (n->prev)
1.1 kristaps 1744: term_vspace(p);
1745: break;
1.314 schwarze 1746: case ROFFT_HEAD:
1.102 kristaps 1747: term_fontpush(p, TERMFONT_BOLD);
1.238 schwarze 1748: p->offset = term_len(p, (p->defindent+1)/2);
1.1 kristaps 1749: break;
1.314 schwarze 1750: case ROFFT_BODY:
1.274 schwarze 1751: p->offset = term_len(p, p->defindent);
1752: break;
1.1 kristaps 1753: default:
1754: break;
1755: }
1756:
1757: return(1);
1758: }
1759:
1760: static void
1761: termp_ss_post(DECL_ARGS)
1762: {
1763:
1.314 schwarze 1764: if (n->type == ROFFT_HEAD || n->type == ROFFT_BODY)
1.1 kristaps 1765: term_newln(p);
1766: }
1767:
1768: static int
1769: termp_cd_pre(DECL_ARGS)
1770: {
1771:
1.143 kristaps 1772: synopsis_pre(p, n);
1.102 kristaps 1773: term_fontpush(p, TERMFONT_BOLD);
1.1 kristaps 1774: return(1);
1775: }
1776:
1777: static int
1778: termp_in_pre(DECL_ARGS)
1779: {
1.142 schwarze 1780:
1.143 kristaps 1781: synopsis_pre(p, n);
1.1 kristaps 1782:
1.160 kristaps 1783: if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags) {
1.138 kristaps 1784: term_fontpush(p, TERMFONT_BOLD);
1.22 kristaps 1785: term_word(p, "#include");
1.138 kristaps 1786: term_word(p, "<");
1787: } else {
1788: term_word(p, "<");
1789: term_fontpush(p, TERMFONT_UNDER);
1790: }
1.22 kristaps 1791:
1.1 kristaps 1792: p->flags |= TERMP_NOSPACE;
1793: return(1);
1794: }
1795:
1796: static void
1797: termp_in_post(DECL_ARGS)
1798: {
1799:
1.160 kristaps 1800: if (MDOC_SYNPRETTY & n->flags)
1.138 kristaps 1801: term_fontpush(p, TERMFONT_BOLD);
1802:
1.79 kristaps 1803: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1804: term_word(p, ">");
1805:
1.160 kristaps 1806: if (MDOC_SYNPRETTY & n->flags)
1.138 kristaps 1807: term_fontpop(p);
1.1 kristaps 1808: }
1809:
1810: static int
1.45 kristaps 1811: termp_sp_pre(DECL_ARGS)
1812: {
1.300 schwarze 1813: struct roffsu su;
1.312 schwarze 1814: int i, len;
1.45 kristaps 1815:
1.86 kristaps 1816: switch (n->tok) {
1.264 schwarze 1817: case MDOC_sp:
1.300 schwarze 1818: if (n->child) {
1819: if ( ! a2roffsu(n->child->string, &su, SCALE_VS))
1820: su.scale = 1.0;
1821: len = term_vspan(p, &su);
1822: } else
1823: len = 1;
1.76 kristaps 1824: break;
1.264 schwarze 1825: case MDOC_br:
1.76 kristaps 1826: len = 0;
1827: break;
1828: default:
1829: len = 1;
1830: break;
1.45 kristaps 1831: }
1832:
1833: if (0 == len)
1834: term_newln(p);
1.312 schwarze 1835: else if (len < 0)
1836: p->skipvsp -= len;
1837: else
1838: for (i = 0; i < len; i++)
1839: term_vspace(p);
1.45 kristaps 1840:
1841: return(0);
1842: }
1843:
1844: static int
1.294 schwarze 1845: termp_skip_pre(DECL_ARGS)
1.268 schwarze 1846: {
1847:
1848: return(0);
1849: }
1850:
1851: static int
1.188 kristaps 1852: termp_quote_pre(DECL_ARGS)
1.1 kristaps 1853: {
1854:
1.314 schwarze 1855: if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
1.1 kristaps 1856: return(1);
1857:
1.188 kristaps 1858: switch (n->tok) {
1.264 schwarze 1859: case MDOC_Ao:
1.188 kristaps 1860: /* FALLTHROUGH */
1.264 schwarze 1861: case MDOC_Aq:
1.303 schwarze 1862: term_word(p, n->nchild == 1 &&
1863: n->child->tok == MDOC_Mt ? "<" : "\\(la");
1.188 kristaps 1864: break;
1.264 schwarze 1865: case MDOC_Bro:
1.188 kristaps 1866: /* FALLTHROUGH */
1.264 schwarze 1867: case MDOC_Brq:
1.188 kristaps 1868: term_word(p, "{");
1869: break;
1.264 schwarze 1870: case MDOC_Oo:
1.188 kristaps 1871: /* FALLTHROUGH */
1.264 schwarze 1872: case MDOC_Op:
1.188 kristaps 1873: /* FALLTHROUGH */
1.264 schwarze 1874: case MDOC_Bo:
1.188 kristaps 1875: /* FALLTHROUGH */
1.264 schwarze 1876: case MDOC_Bq:
1.188 kristaps 1877: term_word(p, "[");
1878: break;
1.264 schwarze 1879: case MDOC_Do:
1.188 kristaps 1880: /* FALLTHROUGH */
1.264 schwarze 1881: case MDOC_Dq:
1.311 schwarze 1882: term_word(p, "\\(Lq");
1.188 kristaps 1883: break;
1.268 schwarze 1884: case MDOC_En:
1885: if (NULL == n->norm->Es ||
1886: NULL == n->norm->Es->child)
1887: return(1);
1888: term_word(p, n->norm->Es->child->string);
1889: break;
1.264 schwarze 1890: case MDOC_Po:
1.188 kristaps 1891: /* FALLTHROUGH */
1.264 schwarze 1892: case MDOC_Pq:
1.188 kristaps 1893: term_word(p, "(");
1894: break;
1.264 schwarze 1895: case MDOC__T:
1.205 kristaps 1896: /* FALLTHROUGH */
1.264 schwarze 1897: case MDOC_Qo:
1.188 kristaps 1898: /* FALLTHROUGH */
1.264 schwarze 1899: case MDOC_Qq:
1.188 kristaps 1900: term_word(p, "\"");
1901: break;
1.264 schwarze 1902: case MDOC_Ql:
1.188 kristaps 1903: /* FALLTHROUGH */
1.264 schwarze 1904: case MDOC_So:
1.188 kristaps 1905: /* FALLTHROUGH */
1.264 schwarze 1906: case MDOC_Sq:
1.249 schwarze 1907: term_word(p, "\\(oq");
1.188 kristaps 1908: break;
1909: default:
1910: abort();
1911: /* NOTREACHED */
1912: }
1.1 kristaps 1913:
1914: p->flags |= TERMP_NOSPACE;
1915: return(1);
1916: }
1917:
1918: static void
1.188 kristaps 1919: termp_quote_post(DECL_ARGS)
1.1 kristaps 1920: {
1921:
1.314 schwarze 1922: if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
1.1 kristaps 1923: return;
1924:
1.306 schwarze 1925: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1926:
1.188 kristaps 1927: switch (n->tok) {
1.264 schwarze 1928: case MDOC_Ao:
1.188 kristaps 1929: /* FALLTHROUGH */
1.264 schwarze 1930: case MDOC_Aq:
1.303 schwarze 1931: term_word(p, n->nchild == 1 &&
1932: n->child->tok == MDOC_Mt ? ">" : "\\(ra");
1.188 kristaps 1933: break;
1.264 schwarze 1934: case MDOC_Bro:
1.188 kristaps 1935: /* FALLTHROUGH */
1.264 schwarze 1936: case MDOC_Brq:
1.188 kristaps 1937: term_word(p, "}");
1938: break;
1.264 schwarze 1939: case MDOC_Oo:
1.188 kristaps 1940: /* FALLTHROUGH */
1.264 schwarze 1941: case MDOC_Op:
1.188 kristaps 1942: /* FALLTHROUGH */
1.264 schwarze 1943: case MDOC_Bo:
1.188 kristaps 1944: /* FALLTHROUGH */
1.264 schwarze 1945: case MDOC_Bq:
1.188 kristaps 1946: term_word(p, "]");
1947: break;
1.264 schwarze 1948: case MDOC_Do:
1.188 kristaps 1949: /* FALLTHROUGH */
1.264 schwarze 1950: case MDOC_Dq:
1.311 schwarze 1951: term_word(p, "\\(Rq");
1.268 schwarze 1952: break;
1953: case MDOC_En:
1.306 schwarze 1954: if (n->norm->Es == NULL ||
1955: n->norm->Es->child == NULL ||
1956: n->norm->Es->child->next == NULL)
1957: p->flags &= ~TERMP_NOSPACE;
1958: else
1.268 schwarze 1959: term_word(p, n->norm->Es->child->next->string);
1.188 kristaps 1960: break;
1.264 schwarze 1961: case MDOC_Po:
1.188 kristaps 1962: /* FALLTHROUGH */
1.264 schwarze 1963: case MDOC_Pq:
1.188 kristaps 1964: term_word(p, ")");
1965: break;
1.264 schwarze 1966: case MDOC__T:
1.205 kristaps 1967: /* FALLTHROUGH */
1.264 schwarze 1968: case MDOC_Qo:
1.188 kristaps 1969: /* FALLTHROUGH */
1.264 schwarze 1970: case MDOC_Qq:
1.188 kristaps 1971: term_word(p, "\"");
1972: break;
1.264 schwarze 1973: case MDOC_Ql:
1.188 kristaps 1974: /* FALLTHROUGH */
1.264 schwarze 1975: case MDOC_So:
1.188 kristaps 1976: /* FALLTHROUGH */
1.264 schwarze 1977: case MDOC_Sq:
1.249 schwarze 1978: term_word(p, "\\(cq");
1.188 kristaps 1979: break;
1980: default:
1981: abort();
1982: /* NOTREACHED */
1983: }
1.306 schwarze 1984: }
1985:
1986: static int
1987: termp_eo_pre(DECL_ARGS)
1988: {
1989:
1.314 schwarze 1990: if (n->type != ROFFT_BODY)
1.306 schwarze 1991: return(1);
1992:
1993: if (n->end == ENDBODY_NOT &&
1994: n->parent->head->child == NULL &&
1995: n->child != NULL &&
1996: n->child->end != ENDBODY_NOT)
1997: term_word(p, "\\&");
1998: else if (n->end != ENDBODY_NOT ? n->child != NULL :
1.309 schwarze 1999: n->parent->head->child != NULL && (n->child != NULL ||
2000: (n->parent->tail != NULL && n->parent->tail->child != NULL)))
1.306 schwarze 2001: p->flags |= TERMP_NOSPACE;
2002:
2003: return(1);
2004: }
2005:
2006: static void
2007: termp_eo_post(DECL_ARGS)
2008: {
2009: int body, tail;
2010:
1.314 schwarze 2011: if (n->type != ROFFT_BODY)
1.306 schwarze 2012: return;
2013:
2014: if (n->end != ENDBODY_NOT) {
2015: p->flags &= ~TERMP_NOSPACE;
2016: return;
2017: }
2018:
2019: body = n->child != NULL || n->parent->head->child != NULL;
2020: tail = n->parent->tail != NULL && n->parent->tail->child != NULL;
2021:
2022: if (body && tail)
2023: p->flags |= TERMP_NOSPACE;
2024: else if ( ! (body || tail))
2025: term_word(p, "\\&");
2026: else if ( ! tail)
2027: p->flags &= ~TERMP_NOSPACE;
1.1 kristaps 2028: }
2029:
2030: static int
2031: termp_fo_pre(DECL_ARGS)
2032: {
1.257 schwarze 2033: size_t rmargin = 0;
1.256 schwarze 2034: int pretty;
2035:
2036: pretty = MDOC_SYNPRETTY & n->flags;
1.1 kristaps 2037:
1.314 schwarze 2038: if (n->type == ROFFT_BLOCK) {
1.143 kristaps 2039: synopsis_pre(p, n);
1.141 kristaps 2040: return(1);
1.314 schwarze 2041: } else if (n->type == ROFFT_BODY) {
1.256 schwarze 2042: if (pretty) {
2043: rmargin = p->rmargin;
1.257 schwarze 2044: p->rmargin = p->offset + term_len(p, 4);
1.263 schwarze 2045: p->flags |= TERMP_NOBREAK | TERMP_BRIND |
2046: TERMP_HANG;
1.256 schwarze 2047: }
1.33 kristaps 2048: p->flags |= TERMP_NOSPACE;
1.1 kristaps 2049: term_word(p, "(");
1.222 kristaps 2050: p->flags |= TERMP_NOSPACE;
1.256 schwarze 2051: if (pretty) {
2052: term_flushln(p);
1.263 schwarze 2053: p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
2054: TERMP_HANG);
1.256 schwarze 2055: p->offset = p->rmargin;
2056: p->rmargin = rmargin;
2057: }
1.1 kristaps 2058: return(1);
1.256 schwarze 2059: }
1.141 kristaps 2060:
1.169 kristaps 2061: if (NULL == n->child)
2062: return(0);
2063:
1.141 kristaps 2064: /* XXX: we drop non-initial arguments as per groff. */
1.1 kristaps 2065:
1.141 kristaps 2066: assert(n->child->string);
1.102 kristaps 2067: term_fontpush(p, TERMFONT_BOLD);
1.141 kristaps 2068: term_word(p, n->child->string);
1.1 kristaps 2069: return(0);
2070: }
2071:
2072: static void
2073: termp_fo_post(DECL_ARGS)
2074: {
2075:
1.314 schwarze 2076: if (n->type != ROFFT_BODY)
1.143 kristaps 2077: return;
2078:
1.222 kristaps 2079: p->flags |= TERMP_NOSPACE;
1.143 kristaps 2080: term_word(p, ")");
2081:
1.222 kristaps 2082: if (MDOC_SYNPRETTY & n->flags) {
2083: p->flags |= TERMP_NOSPACE;
1.143 kristaps 2084: term_word(p, ";");
1.256 schwarze 2085: term_flushln(p);
1.222 kristaps 2086: }
1.1 kristaps 2087: }
2088:
2089: static int
2090: termp_bf_pre(DECL_ARGS)
2091: {
2092:
1.314 schwarze 2093: if (n->type == ROFFT_HEAD)
1.1 kristaps 2094: return(0);
1.314 schwarze 2095: else if (n->type != ROFFT_BODY)
1.1 kristaps 2096: return(1);
2097:
1.264 schwarze 2098: if (FONT_Em == n->norm->Bf.font)
1.102 kristaps 2099: term_fontpush(p, TERMFONT_UNDER);
1.264 schwarze 2100: else if (FONT_Sy == n->norm->Bf.font)
1.102 kristaps 2101: term_fontpush(p, TERMFONT_BOLD);
1.264 schwarze 2102: else
1.102 kristaps 2103: term_fontpush(p, TERMFONT_NONE);
1.1 kristaps 2104:
2105: return(1);
2106: }
2107:
2108: static int
2109: termp_sm_pre(DECL_ARGS)
2110: {
2111:
1.269 schwarze 2112: if (NULL == n->child)
2113: p->flags ^= TERMP_NONOSPACE;
2114: else if (0 == strcmp("on", n->child->string))
1.1 kristaps 2115: p->flags &= ~TERMP_NONOSPACE;
1.269 schwarze 2116: else
1.1 kristaps 2117: p->flags |= TERMP_NONOSPACE;
1.269 schwarze 2118:
2119: if (p->col && ! (TERMP_NONOSPACE & p->flags))
2120: p->flags &= ~TERMP_NOSPACE;
1.1 kristaps 2121:
2122: return(0);
2123: }
2124:
2125: static int
2126: termp_ap_pre(DECL_ARGS)
2127: {
2128:
2129: p->flags |= TERMP_NOSPACE;
1.188 kristaps 2130: term_word(p, "'");
1.1 kristaps 2131: p->flags |= TERMP_NOSPACE;
2132: return(1);
2133: }
2134:
2135: static void
2136: termp____post(DECL_ARGS)
2137: {
1.184 kristaps 2138:
2139: /*
2140: * Handle lists of authors. In general, print each followed by
2141: * a comma. Don't print the comma if there are only two
2142: * authors.
2143: */
2144: if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok)
2145: if (NULL == n->next->next || MDOC__A != n->next->next->tok)
2146: if (NULL == n->prev || MDOC__A != n->prev->tok)
2147: return;
1.1 kristaps 2148:
1.95 kristaps 2149: /* TODO: %U. */
2150:
1.187 kristaps 2151: if (NULL == n->parent || MDOC_Rs != n->parent->tok)
2152: return;
2153:
1.222 kristaps 2154: p->flags |= TERMP_NOSPACE;
1.186 kristaps 2155: if (NULL == n->next) {
2156: term_word(p, ".");
2157: p->flags |= TERMP_SENTENCE;
2158: } else
2159: term_word(p, ",");
1.1 kristaps 2160: }
2161:
2162: static int
1.102 kristaps 2163: termp_li_pre(DECL_ARGS)
2164: {
2165:
2166: term_fontpush(p, TERMFONT_NONE);
2167: return(1);
2168: }
2169:
2170: static int
1.1 kristaps 2171: termp_lk_pre(DECL_ARGS)
2172: {
1.315 ! schwarze 2173: const struct roff_node *link, *descr;
1.1 kristaps 2174:
1.240 schwarze 2175: if (NULL == (link = n->child))
2176: return(0);
1.181 kristaps 2177:
1.240 schwarze 2178: if (NULL != (descr = link->next)) {
2179: term_fontpush(p, TERMFONT_UNDER);
2180: while (NULL != descr) {
2181: term_word(p, descr->string);
2182: descr = descr->next;
2183: }
2184: p->flags |= TERMP_NOSPACE;
2185: term_word(p, ":");
2186: term_fontpop(p);
2187: }
1.1 kristaps 2188:
1.102 kristaps 2189: term_fontpush(p, TERMFONT_BOLD);
1.240 schwarze 2190: term_word(p, link->string);
1.102 kristaps 2191: term_fontpop(p);
1.12 kristaps 2192:
1.1 kristaps 2193: return(0);
2194: }
2195:
1.159 schwarze 2196: static int
2197: termp_bk_pre(DECL_ARGS)
2198: {
2199:
1.161 schwarze 2200: switch (n->type) {
1.314 schwarze 2201: case ROFFT_BLOCK:
1.166 kristaps 2202: break;
1.314 schwarze 2203: case ROFFT_HEAD:
1.161 schwarze 2204: return(0);
1.314 schwarze 2205: case ROFFT_BODY:
1.200 schwarze 2206: if (n->parent->args || 0 == n->prev->nchild)
2207: p->flags |= TERMP_PREKEEP;
1.166 kristaps 2208: break;
1.161 schwarze 2209: default:
2210: abort();
1.166 kristaps 2211: /* NOTREACHED */
1.161 schwarze 2212: }
1.166 kristaps 2213:
2214: return(1);
1.159 schwarze 2215: }
2216:
2217: static void
2218: termp_bk_post(DECL_ARGS)
2219: {
2220:
1.314 schwarze 2221: if (n->type == ROFFT_BODY)
1.161 schwarze 2222: p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
1.203 kristaps 2223: }
2224:
2225: static void
2226: termp__t_post(DECL_ARGS)
2227: {
2228:
2229: /*
2230: * If we're in an `Rs' and there's a journal present, then quote
2231: * us instead of underlining us (for disambiguation).
2232: */
1.217 schwarze 2233: if (n->parent && MDOC_Rs == n->parent->tok &&
1.264 schwarze 2234: n->parent->norm->Rs.quote_T)
1.245 schwarze 2235: termp_quote_post(p, pair, meta, n);
1.203 kristaps 2236:
1.245 schwarze 2237: termp____post(p, pair, meta, n);
1.203 kristaps 2238: }
2239:
2240: static int
2241: termp__t_pre(DECL_ARGS)
2242: {
2243:
2244: /*
2245: * If we're in an `Rs' and there's a journal present, then quote
2246: * us instead of underlining us (for disambiguation).
2247: */
2248: if (n->parent && MDOC_Rs == n->parent->tok &&
1.264 schwarze 2249: n->parent->norm->Rs.quote_T)
1.245 schwarze 2250: return(termp_quote_pre(p, pair, meta, n));
1.203 kristaps 2251:
2252: term_fontpush(p, TERMFONT_UNDER);
2253: return(1);
1.159 schwarze 2254: }
1.1 kristaps 2255:
2256: static int
1.69 kristaps 2257: termp_under_pre(DECL_ARGS)
1.1 kristaps 2258: {
2259:
1.102 kristaps 2260: term_fontpush(p, TERMFONT_UNDER);
1.84 kristaps 2261: return(1);
2262: }
CVSweb