Annotation of mandoc/man_term.c, Revision 1.181
1.181 ! schwarze 1: /* $Id: man_term.c,v 1.180 2015/04/18 16:06:40 schwarze Exp $ */
1.1 kristaps 2: /*
1.128 schwarze 3: * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
1.168 schwarze 4: * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
1.1 kristaps 5: *
6: * Permission to use, copy, modify, and distribute this software for any
1.8 kristaps 7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
1.1 kristaps 9: *
1.171 schwarze 10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
1.8 kristaps 11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1.171 schwarze 12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
1.8 kristaps 13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1 kristaps 17: */
1.55 kristaps 18: #include "config.h"
19:
1.28 kristaps 20: #include <sys/types.h>
21:
1.1 kristaps 22: #include <assert.h>
1.18 kristaps 23: #include <ctype.h>
1.164 schwarze 24: #include <limits.h>
1.1 kristaps 25: #include <stdio.h>
26: #include <stdlib.h>
27: #include <string.h>
28:
1.171 schwarze 29: #include "mandoc_aux.h"
1.71 kristaps 30: #include "mandoc.h"
1.171 schwarze 31: #include "roff.h"
32: #include "man.h"
1.40 kristaps 33: #include "out.h"
1.1 kristaps 34: #include "term.h"
1.36 kristaps 35: #include "main.h"
1.1 kristaps 36:
1.116 schwarze 37: #define MAXMARGINS 64 /* maximum number of indented scopes */
1.18 kristaps 38:
1.24 kristaps 39: struct mtermp {
40: int fl;
1.19 kristaps 41: #define MANT_LITERAL (1 << 0)
1.163 schwarze 42: int lmargin[MAXMARGINS]; /* margins (incl. vis. page) */
1.116 schwarze 43: int lmargincur; /* index of current margin */
44: int lmarginsz; /* actual number of nested margins */
45: size_t offset; /* default offset to visible page */
1.134 schwarze 46: int pardist; /* vert. space before par., unit: [v] */
1.24 kristaps 47: };
1.19 kristaps 48:
1.146 schwarze 49: #define DECL_ARGS struct termp *p, \
1.24 kristaps 50: struct mtermp *mt, \
1.172 schwarze 51: struct roff_node *n, \
1.173 schwarze 52: const struct roff_meta *meta
1.1 kristaps 53:
54: struct termact {
55: int (*pre)(DECL_ARGS);
56: void (*post)(DECL_ARGS);
1.56 kristaps 57: int flags;
58: #define MAN_NOTEXT (1 << 0) /* Never has text children. */
1.1 kristaps 59: };
60:
1.52 kristaps 61: static void print_man_nodelist(DECL_ARGS);
1.45 kristaps 62: static void print_man_node(DECL_ARGS);
1.173 schwarze 63: static void print_man_head(struct termp *,
64: const struct roff_meta *);
65: static void print_man_foot(struct termp *,
66: const struct roff_meta *);
1.146 schwarze 67: static void print_bvspace(struct termp *,
1.172 schwarze 68: const struct roff_node *, int);
1.39 kristaps 69:
1.1 kristaps 70: static int pre_B(DECL_ARGS);
1.19 kristaps 71: static int pre_HP(DECL_ARGS);
1.1 kristaps 72: static int pre_I(DECL_ARGS);
1.4 kristaps 73: static int pre_IP(DECL_ARGS);
1.127 kristaps 74: static int pre_OP(DECL_ARGS);
1.134 schwarze 75: static int pre_PD(DECL_ARGS);
1.1 kristaps 76: static int pre_PP(DECL_ARGS);
1.26 kristaps 77: static int pre_RS(DECL_ARGS);
1.1 kristaps 78: static int pre_SH(DECL_ARGS);
79: static int pre_SS(DECL_ARGS);
80: static int pre_TP(DECL_ARGS);
1.137 schwarze 81: static int pre_UR(DECL_ARGS);
1.127 kristaps 82: static int pre_alternate(DECL_ARGS);
83: static int pre_ft(DECL_ARGS);
1.29 kristaps 84: static int pre_ign(DECL_ARGS);
1.83 kristaps 85: static int pre_in(DECL_ARGS);
1.84 kristaps 86: static int pre_literal(DECL_ARGS);
1.143 schwarze 87: static int pre_ll(DECL_ARGS);
1.19 kristaps 88: static int pre_sp(DECL_ARGS);
1.1 kristaps 89:
1.22 kristaps 90: static void post_IP(DECL_ARGS);
1.20 kristaps 91: static void post_HP(DECL_ARGS);
1.26 kristaps 92: static void post_RS(DECL_ARGS);
1.1 kristaps 93: static void post_SH(DECL_ARGS);
94: static void post_SS(DECL_ARGS);
1.21 kristaps 95: static void post_TP(DECL_ARGS);
1.137 schwarze 96: static void post_UR(DECL_ARGS);
1.1 kristaps 97:
1.32 kristaps 98: static const struct termact termacts[MAN_MAX] = {
1.82 kristaps 99: { pre_sp, NULL, MAN_NOTEXT }, /* br */
1.56 kristaps 100: { NULL, NULL, 0 }, /* TH */
101: { pre_SH, post_SH, 0 }, /* SH */
102: { pre_SS, post_SS, 0 }, /* SS */
103: { pre_TP, post_TP, 0 }, /* TP */
104: { pre_PP, NULL, 0 }, /* LP */
105: { pre_PP, NULL, 0 }, /* PP */
106: { pre_PP, NULL, 0 }, /* P */
107: { pre_IP, post_IP, 0 }, /* IP */
1.146 schwarze 108: { pre_HP, post_HP, 0 }, /* HP */
1.56 kristaps 109: { NULL, NULL, 0 }, /* SM */
110: { pre_B, NULL, 0 }, /* SB */
1.88 kristaps 111: { pre_alternate, NULL, 0 }, /* BI */
112: { pre_alternate, NULL, 0 }, /* IB */
113: { pre_alternate, NULL, 0 }, /* BR */
114: { pre_alternate, NULL, 0 }, /* RB */
1.56 kristaps 115: { NULL, NULL, 0 }, /* R */
116: { pre_B, NULL, 0 }, /* B */
117: { pre_I, NULL, 0 }, /* I */
1.88 kristaps 118: { pre_alternate, NULL, 0 }, /* IR */
119: { pre_alternate, NULL, 0 }, /* RI */
1.56 kristaps 120: { pre_sp, NULL, MAN_NOTEXT }, /* sp */
1.84 kristaps 121: { pre_literal, NULL, 0 }, /* nf */
122: { pre_literal, NULL, 0 }, /* fi */
1.56 kristaps 123: { NULL, NULL, 0 }, /* RE */
124: { pre_RS, post_RS, 0 }, /* RS */
125: { pre_ign, NULL, 0 }, /* DT */
1.158 schwarze 126: { pre_ign, NULL, MAN_NOTEXT }, /* UC */
1.134 schwarze 127: { pre_PD, NULL, MAN_NOTEXT }, /* PD */
1.70 joerg 128: { pre_ign, NULL, 0 }, /* AT */
1.83 kristaps 129: { pre_in, NULL, MAN_NOTEXT }, /* in */
1.89 kristaps 130: { pre_ft, NULL, MAN_NOTEXT }, /* ft */
1.127 kristaps 131: { pre_OP, NULL, 0 }, /* OP */
1.129 schwarze 132: { pre_literal, NULL, 0 }, /* EX */
133: { pre_literal, NULL, 0 }, /* EE */
1.137 schwarze 134: { pre_UR, post_UR, 0 }, /* UR */
135: { NULL, NULL, 0 }, /* UE */
1.143 schwarze 136: { pre_ll, NULL, MAN_NOTEXT }, /* ll */
1.1 kristaps 137: };
138:
139:
1.31 kristaps 140: void
1.180 schwarze 141: terminal_man(void *arg, const struct roff_man *man)
1.1 kristaps 142: {
1.36 kristaps 143: struct termp *p;
1.172 schwarze 144: struct roff_node *n;
1.36 kristaps 145: struct mtermp mt;
146:
147: p = (struct termp *)arg;
1.58 kristaps 148: p->overstep = 0;
1.151 schwarze 149: p->rmargin = p->maxrmargin = p->defrmargin;
1.77 kristaps 150: p->tabwidth = term_len(p, 5);
1.36 kristaps 151:
1.116 schwarze 152: memset(&mt, 0, sizeof(struct mtermp));
1.122 schwarze 153: mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
154: mt.offset = term_len(p, p->defindent);
1.134 schwarze 155: mt.pardist = 1;
1.24 kristaps 156:
1.181 ! schwarze 157: n = man->first->child;
1.151 schwarze 158: if (p->synopsisonly) {
159: while (n != NULL) {
160: if (n->tok == MAN_SH &&
1.171 schwarze 161: n->child->child->type == ROFFT_TEXT &&
1.151 schwarze 162: !strcmp(n->child->child->string, "SYNOPSIS")) {
163: if (n->child->next->child != NULL)
164: print_man_nodelist(p, &mt,
1.181 ! schwarze 165: n->child->next->child,
! 166: &man->meta);
1.151 schwarze 167: term_newln(p);
168: break;
169: }
170: n = n->next;
171: }
172: } else {
173: if (p->defindent == 0)
174: p->defindent = 7;
1.181 ! schwarze 175: term_begin(p, print_man_head, print_man_foot, &man->meta);
1.151 schwarze 176: p->flags |= TERMP_NOSPACE;
177: if (n != NULL)
1.181 ! schwarze 178: print_man_nodelist(p, &mt, n, &man->meta);
1.151 schwarze 179: term_end(p);
180: }
1.1 kristaps 181: }
182:
1.111 kristaps 183: /*
184: * Printing leading vertical space before a block.
185: * This is used for the paragraph macros.
186: * The rules are pretty simple, since there's very little nesting going
187: * on here. Basically, if we're the first within another block (SS/SH),
188: * then don't emit vertical space. If we are (RS), then do. If not the
189: * first, print it.
190: */
1.39 kristaps 191: static void
1.172 schwarze 192: print_bvspace(struct termp *p, const struct roff_node *n, int pardist)
1.18 kristaps 193: {
1.134 schwarze 194: int i;
1.111 kristaps 195:
1.39 kristaps 196: term_newln(p);
1.101 schwarze 197:
1.111 kristaps 198: if (n->body && n->body->child)
1.171 schwarze 199: if (n->body->child->type == ROFFT_TBL)
1.111 kristaps 200: return;
201:
1.171 schwarze 202: if (n->parent->type == ROFFT_ROOT || n->parent->tok != MAN_RS)
1.111 kristaps 203: if (NULL == n->prev)
204: return;
1.18 kristaps 205:
1.134 schwarze 206: for (i = 0; i < pardist; i++)
207: term_vspace(p);
1.18 kristaps 208: }
209:
1.146 schwarze 210:
1.1 kristaps 211: static int
1.29 kristaps 212: pre_ign(DECL_ARGS)
213: {
214:
1.143 schwarze 215: return(0);
216: }
217:
218: static int
219: pre_ll(DECL_ARGS)
220: {
221:
1.144 schwarze 222: term_setwidth(p, n->nchild ? n->child->string : NULL);
1.29 kristaps 223: return(0);
224: }
225:
226: static int
1.1 kristaps 227: pre_I(DECL_ARGS)
228: {
229:
1.52 kristaps 230: term_fontrepl(p, TERMFONT_UNDER);
1.19 kristaps 231: return(1);
232: }
233:
1.3 kristaps 234: static int
1.84 kristaps 235: pre_literal(DECL_ARGS)
1.19 kristaps 236: {
237:
1.81 kristaps 238: term_newln(p);
1.88 kristaps 239:
1.129 schwarze 240: if (MAN_nf == n->tok || MAN_EX == n->tok)
1.84 kristaps 241: mt->fl |= MANT_LITERAL;
1.88 kristaps 242: else
1.84 kristaps 243: mt->fl &= ~MANT_LITERAL;
244:
1.117 schwarze 245: /*
246: * Unlike .IP and .TP, .HP does not have a HEAD.
247: * So in case a second call to term_flushln() is needed,
248: * indentation has to be set up explicitly.
249: */
250: if (MAN_HP == n->parent->tok && p->rmargin < p->maxrmargin) {
1.121 schwarze 251: p->offset = p->rmargin;
1.117 schwarze 252: p->rmargin = p->maxrmargin;
1.139 schwarze 253: p->trailspace = 0;
1.145 schwarze 254: p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
1.117 schwarze 255: p->flags |= TERMP_NOSPACE;
256: }
257:
1.99 schwarze 258: return(0);
1.19 kristaps 259: }
260:
261: static int
1.134 schwarze 262: pre_PD(DECL_ARGS)
263: {
1.160 schwarze 264: struct roffsu su;
1.134 schwarze 265:
266: n = n->child;
1.160 schwarze 267: if (n == NULL) {
1.134 schwarze 268: mt->pardist = 1;
269: return(0);
270: }
1.171 schwarze 271: assert(n->type == ROFFT_TEXT);
1.160 schwarze 272: if (a2roffsu(n->string, &su, SCALE_VS))
273: mt->pardist = term_vspan(p, &su);
1.134 schwarze 274: return(0);
275: }
276:
277: static int
1.88 kristaps 278: pre_alternate(DECL_ARGS)
1.3 kristaps 279: {
1.88 kristaps 280: enum termfont font[2];
1.172 schwarze 281: struct roff_node *nn;
1.88 kristaps 282: int savelit, i;
1.3 kristaps 283:
1.88 kristaps 284: switch (n->tok) {
1.146 schwarze 285: case MAN_RB:
1.88 kristaps 286: font[0] = TERMFONT_NONE;
287: font[1] = TERMFONT_BOLD;
288: break;
1.146 schwarze 289: case MAN_RI:
1.88 kristaps 290: font[0] = TERMFONT_NONE;
291: font[1] = TERMFONT_UNDER;
292: break;
1.146 schwarze 293: case MAN_BR:
1.88 kristaps 294: font[0] = TERMFONT_BOLD;
295: font[1] = TERMFONT_NONE;
296: break;
1.146 schwarze 297: case MAN_BI:
1.88 kristaps 298: font[0] = TERMFONT_BOLD;
299: font[1] = TERMFONT_UNDER;
300: break;
1.146 schwarze 301: case MAN_IR:
1.88 kristaps 302: font[0] = TERMFONT_UNDER;
303: font[1] = TERMFONT_NONE;
304: break;
1.146 schwarze 305: case MAN_IB:
1.88 kristaps 306: font[0] = TERMFONT_UNDER;
307: font[1] = TERMFONT_BOLD;
308: break;
309: default:
310: abort();
311: }
1.35 kristaps 312:
1.88 kristaps 313: savelit = MANT_LITERAL & mt->fl;
314: mt->fl &= ~MANT_LITERAL;
1.35 kristaps 315:
1.88 kristaps 316: for (i = 0, nn = n->child; nn; nn = nn->next, i = 1 - i) {
317: term_fontrepl(p, font[i]);
318: if (savelit && NULL == nn->next)
319: mt->fl |= MANT_LITERAL;
1.179 schwarze 320: assert(nn->type == ROFFT_TEXT);
321: term_word(p, nn->string);
322: if (nn->flags & MAN_EOS)
323: p->flags |= TERMP_SENTENCE;
1.88 kristaps 324: if (nn->next)
1.4 kristaps 325: p->flags |= TERMP_NOSPACE;
1.3 kristaps 326: }
327:
328: return(0);
329: }
330:
1.1 kristaps 331: static int
332: pre_B(DECL_ARGS)
333: {
334:
1.52 kristaps 335: term_fontrepl(p, TERMFONT_BOLD);
1.1 kristaps 336: return(1);
1.127 kristaps 337: }
338:
339: static int
340: pre_OP(DECL_ARGS)
341: {
342:
343: term_word(p, "[");
344: p->flags |= TERMP_NOSPACE;
345:
346: if (NULL != (n = n->child)) {
347: term_fontrepl(p, TERMFONT_BOLD);
348: term_word(p, n->string);
349: }
350: if (NULL != n && NULL != n->next) {
351: term_fontrepl(p, TERMFONT_UNDER);
352: term_word(p, n->next->string);
353: }
354:
355: term_fontrepl(p, TERMFONT_NONE);
356: p->flags |= TERMP_NOSPACE;
357: term_word(p, "]");
358: return(0);
1.89 kristaps 359: }
360:
361: static int
362: pre_ft(DECL_ARGS)
363: {
364: const char *cp;
365:
366: if (NULL == n->child) {
367: term_fontlast(p);
368: return(0);
369: }
370:
371: cp = n->child->string;
372: switch (*cp) {
1.146 schwarze 373: case '4':
1.89 kristaps 374: /* FALLTHROUGH */
1.146 schwarze 375: case '3':
1.89 kristaps 376: /* FALLTHROUGH */
1.146 schwarze 377: case 'B':
1.89 kristaps 378: term_fontrepl(p, TERMFONT_BOLD);
379: break;
1.146 schwarze 380: case '2':
1.89 kristaps 381: /* FALLTHROUGH */
1.146 schwarze 382: case 'I':
1.89 kristaps 383: term_fontrepl(p, TERMFONT_UNDER);
384: break;
1.146 schwarze 385: case 'P':
1.89 kristaps 386: term_fontlast(p);
387: break;
1.146 schwarze 388: case '1':
1.89 kristaps 389: /* FALLTHROUGH */
1.146 schwarze 390: case 'C':
1.89 kristaps 391: /* FALLTHROUGH */
1.146 schwarze 392: case 'R':
1.89 kristaps 393: term_fontrepl(p, TERMFONT_NONE);
394: break;
395: default:
396: break;
397: }
398: return(0);
1.83 kristaps 399: }
400:
401: static int
402: pre_in(DECL_ARGS)
403: {
1.163 schwarze 404: struct roffsu su;
405: const char *cp;
1.83 kristaps 406: size_t v;
1.163 schwarze 407: int less;
1.83 kristaps 408:
409: term_newln(p);
410:
411: if (NULL == n->child) {
412: p->offset = mt->offset;
413: return(0);
414: }
415:
416: cp = n->child->string;
417: less = 0;
418:
419: if ('-' == *cp)
420: less = -1;
421: else if ('+' == *cp)
422: less = 1;
423: else
424: cp--;
425:
1.163 schwarze 426: if ( ! a2roffsu(++cp, &su, SCALE_EN))
1.83 kristaps 427: return(0);
428:
1.175 schwarze 429: v = (term_hspan(p, &su) + 11) / 24;
1.83 kristaps 430:
431: if (less < 0)
432: p->offset -= p->offset > v ? v : p->offset;
433: else if (less > 0)
434: p->offset += v;
1.146 schwarze 435: else
1.83 kristaps 436: p->offset = v;
1.164 schwarze 437: if (p->offset > SHRT_MAX)
438: p->offset = term_len(p, p->defindent);
1.95 kristaps 439:
1.83 kristaps 440: return(0);
1.1 kristaps 441: }
442:
443: static int
1.19 kristaps 444: pre_sp(DECL_ARGS)
445: {
1.162 schwarze 446: struct roffsu su;
1.163 schwarze 447: int i, len;
1.112 kristaps 448:
449: if ((NULL == n->prev && n->parent)) {
1.132 schwarze 450: switch (n->parent->tok) {
1.146 schwarze 451: case MAN_SH:
1.132 schwarze 452: /* FALLTHROUGH */
1.146 schwarze 453: case MAN_SS:
1.132 schwarze 454: /* FALLTHROUGH */
1.146 schwarze 455: case MAN_PP:
1.132 schwarze 456: /* FALLTHROUGH */
1.146 schwarze 457: case MAN_LP:
1.132 schwarze 458: /* FALLTHROUGH */
1.146 schwarze 459: case MAN_P:
1.132 schwarze 460: /* FALLTHROUGH */
1.112 kristaps 461: return(0);
1.132 schwarze 462: default:
463: break;
464: }
1.112 kristaps 465: }
1.19 kristaps 466:
1.163 schwarze 467: if (n->tok == MAN_br)
1.82 kristaps 468: len = 0;
1.163 schwarze 469: else if (n->child == NULL)
470: len = 1;
471: else {
472: if ( ! a2roffsu(n->child->string, &su, SCALE_VS))
1.162 schwarze 473: su.scale = 1.0;
474: len = term_vspan(p, &su);
1.82 kristaps 475: }
1.38 kristaps 476:
1.163 schwarze 477: if (len == 0)
1.19 kristaps 478: term_newln(p);
1.163 schwarze 479: else if (len < 0)
480: p->skipvsp -= len;
1.131 schwarze 481: else
482: for (i = 0; i < len; i++)
483: term_vspace(p);
1.19 kristaps 484:
1.15 kristaps 485: return(0);
486: }
487:
488: static int
1.19 kristaps 489: pre_HP(DECL_ARGS)
490: {
1.163 schwarze 491: struct roffsu su;
1.172 schwarze 492: const struct roff_node *nn;
1.163 schwarze 493: int len;
1.19 kristaps 494:
1.20 kristaps 495: switch (n->type) {
1.171 schwarze 496: case ROFFT_BLOCK:
1.134 schwarze 497: print_bvspace(p, n, mt->pardist);
1.24 kristaps 498: return(1);
1.171 schwarze 499: case ROFFT_BODY:
1.20 kristaps 500: break;
501: default:
502: return(0);
503: }
504:
1.130 schwarze 505: if ( ! (MANT_LITERAL & mt->fl)) {
1.145 schwarze 506: p->flags |= TERMP_NOBREAK | TERMP_BRIND;
1.139 schwarze 507: p->trailspace = 2;
1.130 schwarze 508: }
509:
1.24 kristaps 510: /* Calculate offset. */
511:
1.163 schwarze 512: if ((nn = n->parent->head->child) != NULL &&
513: a2roffsu(nn->string, &su, SCALE_EN)) {
1.175 schwarze 514: len = term_hspan(p, &su) / 24;
1.164 schwarze 515: if (len < 0 && (size_t)(-len) > mt->offset)
516: len = -mt->offset;
517: else if (len > SHRT_MAX)
518: len = term_len(p, p->defindent);
1.163 schwarze 519: mt->lmargin[mt->lmargincur] = len;
520: } else
521: len = mt->lmargin[mt->lmargincur];
1.24 kristaps 522:
1.26 kristaps 523: p->offset = mt->offset;
1.164 schwarze 524: p->rmargin = mt->offset + len;
1.19 kristaps 525: return(1);
526: }
527:
1.20 kristaps 528: static void
529: post_HP(DECL_ARGS)
530: {
531:
532: switch (n->type) {
1.171 schwarze 533: case ROFFT_BODY:
1.136 schwarze 534: term_newln(p);
1.174 schwarze 535:
536: /*
537: * Compatibility with a groff bug.
538: * The .HP macro uses the undocumented .tag request
539: * which causes a line break and cancels no-space
540: * mode even if there isn't any output.
541: */
542:
543: if (n->child == NULL)
544: term_vspace(p);
545:
1.145 schwarze 546: p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
1.139 schwarze 547: p->trailspace = 0;
1.26 kristaps 548: p->offset = mt->offset;
1.20 kristaps 549: p->rmargin = p->maxrmargin;
550: break;
551: default:
552: break;
553: }
554: }
555:
1.19 kristaps 556: static int
1.1 kristaps 557: pre_PP(DECL_ARGS)
558: {
559:
1.19 kristaps 560: switch (n->type) {
1.171 schwarze 561: case ROFFT_BLOCK:
1.122 schwarze 562: mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
1.134 schwarze 563: print_bvspace(p, n, mt->pardist);
1.19 kristaps 564: break;
565: default:
1.26 kristaps 566: p->offset = mt->offset;
1.19 kristaps 567: break;
568: }
569:
1.171 schwarze 570: return(n->type != ROFFT_HEAD);
1.1 kristaps 571: }
572:
573: static int
1.4 kristaps 574: pre_IP(DECL_ARGS)
575: {
1.163 schwarze 576: struct roffsu su;
1.172 schwarze 577: const struct roff_node *nn;
1.163 schwarze 578: int len, savelit;
1.18 kristaps 579:
1.22 kristaps 580: switch (n->type) {
1.171 schwarze 581: case ROFFT_BODY:
1.22 kristaps 582: p->flags |= TERMP_NOSPACE;
583: break;
1.171 schwarze 584: case ROFFT_HEAD:
1.22 kristaps 585: p->flags |= TERMP_NOBREAK;
1.139 schwarze 586: p->trailspace = 1;
1.22 kristaps 587: break;
1.171 schwarze 588: case ROFFT_BLOCK:
1.134 schwarze 589: print_bvspace(p, n, mt->pardist);
1.23 kristaps 590: /* FALLTHROUGH */
1.22 kristaps 591: default:
592: return(1);
593: }
1.18 kristaps 594:
1.94 schwarze 595: /* Calculate the offset from the optional second argument. */
1.163 schwarze 596: if ((nn = n->parent->head->child) != NULL &&
597: (nn = nn->next) != NULL &&
598: a2roffsu(nn->string, &su, SCALE_EN)) {
1.175 schwarze 599: len = term_hspan(p, &su) / 24;
1.163 schwarze 600: if (len < 0 && (size_t)(-len) > mt->offset)
601: len = -mt->offset;
1.164 schwarze 602: else if (len > SHRT_MAX)
603: len = term_len(p, p->defindent);
604: mt->lmargin[mt->lmargincur] = len;
1.163 schwarze 605: } else
606: len = mt->lmargin[mt->lmargincur];
1.4 kristaps 607:
1.22 kristaps 608: switch (n->type) {
1.171 schwarze 609: case ROFFT_HEAD:
1.26 kristaps 610: p->offset = mt->offset;
611: p->rmargin = mt->offset + len;
1.18 kristaps 612:
1.94 schwarze 613: savelit = MANT_LITERAL & mt->fl;
614: mt->fl &= ~MANT_LITERAL;
615:
616: if (n->child)
1.135 schwarze 617: print_man_node(p, mt, n->child, meta);
1.94 schwarze 618:
619: if (savelit)
620: mt->fl |= MANT_LITERAL;
621:
1.22 kristaps 622: return(0);
1.171 schwarze 623: case ROFFT_BODY:
1.26 kristaps 624: p->offset = mt->offset + len;
1.156 schwarze 625: p->rmargin = p->maxrmargin;
1.23 kristaps 626: break;
1.22 kristaps 627: default:
628: break;
1.18 kristaps 629: }
630:
1.22 kristaps 631: return(1);
632: }
1.18 kristaps 633:
1.22 kristaps 634: static void
635: post_IP(DECL_ARGS)
636: {
1.4 kristaps 637:
1.22 kristaps 638: switch (n->type) {
1.171 schwarze 639: case ROFFT_HEAD:
1.22 kristaps 640: term_flushln(p);
641: p->flags &= ~TERMP_NOBREAK;
1.139 schwarze 642: p->trailspace = 0;
1.22 kristaps 643: p->rmargin = p->maxrmargin;
644: break;
1.171 schwarze 645: case ROFFT_BODY:
1.94 schwarze 646: term_newln(p);
1.138 schwarze 647: p->offset = mt->offset;
1.22 kristaps 648: break;
649: default:
650: break;
651: }
1.4 kristaps 652: }
653:
654: static int
1.1 kristaps 655: pre_TP(DECL_ARGS)
656: {
1.163 schwarze 657: struct roffsu su;
1.172 schwarze 658: struct roff_node *nn;
1.163 schwarze 659: int len, savelit;
1.1 kristaps 660:
1.21 kristaps 661: switch (n->type) {
1.171 schwarze 662: case ROFFT_HEAD:
1.21 kristaps 663: p->flags |= TERMP_NOBREAK;
1.139 schwarze 664: p->trailspace = 1;
1.21 kristaps 665: break;
1.171 schwarze 666: case ROFFT_BODY:
1.21 kristaps 667: p->flags |= TERMP_NOSPACE;
1.23 kristaps 668: break;
1.171 schwarze 669: case ROFFT_BLOCK:
1.134 schwarze 670: print_bvspace(p, n, mt->pardist);
1.23 kristaps 671: /* FALLTHROUGH */
672: default:
673: return(1);
674: }
675:
676: /* Calculate offset. */
677:
1.163 schwarze 678: if ((nn = n->parent->head->child) != NULL &&
679: nn->string != NULL && ! (MAN_LINE & nn->flags) &&
680: a2roffsu(nn->string, &su, SCALE_EN)) {
1.175 schwarze 681: len = term_hspan(p, &su) / 24;
1.163 schwarze 682: if (len < 0 && (size_t)(-len) > mt->offset)
683: len = -mt->offset;
1.164 schwarze 684: else if (len > SHRT_MAX)
685: len = term_len(p, p->defindent);
686: mt->lmargin[mt->lmargincur] = len;
1.163 schwarze 687: } else
688: len = mt->lmargin[mt->lmargincur];
1.23 kristaps 689:
690: switch (n->type) {
1.171 schwarze 691: case ROFFT_HEAD:
1.26 kristaps 692: p->offset = mt->offset;
693: p->rmargin = mt->offset + len;
1.23 kristaps 694:
1.94 schwarze 695: savelit = MANT_LITERAL & mt->fl;
696: mt->fl &= ~MANT_LITERAL;
697:
1.23 kristaps 698: /* Don't print same-line elements. */
1.141 schwarze 699: nn = n->child;
700: while (NULL != nn && 0 == (MAN_LINE & nn->flags))
701: nn = nn->next;
702:
703: while (NULL != nn) {
704: print_man_node(p, mt, nn, meta);
705: nn = nn->next;
706: }
1.24 kristaps 707:
1.94 schwarze 708: if (savelit)
709: mt->fl |= MANT_LITERAL;
1.23 kristaps 710: return(0);
1.171 schwarze 711: case ROFFT_BODY:
1.26 kristaps 712: p->offset = mt->offset + len;
1.156 schwarze 713: p->rmargin = p->maxrmargin;
1.139 schwarze 714: p->trailspace = 0;
1.130 schwarze 715: p->flags &= ~TERMP_NOBREAK;
1.21 kristaps 716: break;
717: default:
718: break;
719: }
1.16 kristaps 720:
1.21 kristaps 721: return(1);
722: }
1.1 kristaps 723:
1.21 kristaps 724: static void
725: post_TP(DECL_ARGS)
726: {
1.1 kristaps 727:
1.21 kristaps 728: switch (n->type) {
1.171 schwarze 729: case ROFFT_HEAD:
1.21 kristaps 730: term_flushln(p);
731: break;
1.171 schwarze 732: case ROFFT_BODY:
1.94 schwarze 733: term_newln(p);
1.138 schwarze 734: p->offset = mt->offset;
1.21 kristaps 735: break;
736: default:
737: break;
738: }
1.1 kristaps 739: }
740:
741: static int
742: pre_SS(DECL_ARGS)
743: {
1.134 schwarze 744: int i;
1.1 kristaps 745:
1.19 kristaps 746: switch (n->type) {
1.171 schwarze 747: case ROFFT_BLOCK:
1.113 kristaps 748: mt->fl &= ~MANT_LITERAL;
1.122 schwarze 749: mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
750: mt->offset = term_len(p, p->defindent);
1.158 schwarze 751:
752: /*
753: * No vertical space before the first subsection
754: * and after an empty subsection.
755: */
756:
757: do {
758: n = n->prev;
1.170 schwarze 759: } while (n != NULL && n->tok != MAN_MAX &&
760: termacts[n->tok].flags & MAN_NOTEXT);
1.158 schwarze 761: if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL))
1.24 kristaps 762: break;
1.158 schwarze 763:
1.134 schwarze 764: for (i = 0; i < mt->pardist; i++)
765: term_vspace(p);
1.19 kristaps 766: break;
1.171 schwarze 767: case ROFFT_HEAD:
1.52 kristaps 768: term_fontrepl(p, TERMFONT_BOLD);
1.133 schwarze 769: p->offset = term_len(p, 3);
1.176 schwarze 770: p->rmargin = mt->offset;
771: p->trailspace = mt->offset;
772: p->flags |= TERMP_NOBREAK | TERMP_BRIND;
1.19 kristaps 773: break;
1.171 schwarze 774: case ROFFT_BODY:
1.26 kristaps 775: p->offset = mt->offset;
1.176 schwarze 776: p->rmargin = p->maxrmargin;
777: p->trailspace = 0;
778: p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
1.24 kristaps 779: break;
1.19 kristaps 780: default:
781: break;
782: }
783:
1.1 kristaps 784: return(1);
785: }
786:
787: static void
788: post_SS(DECL_ARGS)
789: {
1.146 schwarze 790:
1.19 kristaps 791: switch (n->type) {
1.171 schwarze 792: case ROFFT_HEAD:
1.19 kristaps 793: term_newln(p);
794: break;
1.171 schwarze 795: case ROFFT_BODY:
1.24 kristaps 796: term_newln(p);
797: break;
1.19 kristaps 798: default:
799: break;
800: }
1.1 kristaps 801: }
802:
803: static int
804: pre_SH(DECL_ARGS)
805: {
1.134 schwarze 806: int i;
1.22 kristaps 807:
1.19 kristaps 808: switch (n->type) {
1.171 schwarze 809: case ROFFT_BLOCK:
1.113 kristaps 810: mt->fl &= ~MANT_LITERAL;
1.122 schwarze 811: mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
812: mt->offset = term_len(p, p->defindent);
1.158 schwarze 813:
814: /*
815: * No vertical space before the first section
816: * and after an empty section.
817: */
818:
819: do {
820: n = n->prev;
821: } while (n != NULL && termacts[n->tok].flags & MAN_NOTEXT);
822: if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL))
1.61 kristaps 823: break;
1.158 schwarze 824:
1.134 schwarze 825: for (i = 0; i < mt->pardist; i++)
826: term_vspace(p);
1.19 kristaps 827: break;
1.171 schwarze 828: case ROFFT_HEAD:
1.52 kristaps 829: term_fontrepl(p, TERMFONT_BOLD);
1.19 kristaps 830: p->offset = 0;
1.176 schwarze 831: p->rmargin = mt->offset;
832: p->trailspace = mt->offset;
833: p->flags |= TERMP_NOBREAK | TERMP_BRIND;
1.19 kristaps 834: break;
1.171 schwarze 835: case ROFFT_BODY:
1.26 kristaps 836: p->offset = mt->offset;
1.176 schwarze 837: p->rmargin = p->maxrmargin;
838: p->trailspace = 0;
839: p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
1.19 kristaps 840: break;
841: default:
842: break;
843: }
1.1 kristaps 844:
845: return(1);
846: }
847:
848: static void
849: post_SH(DECL_ARGS)
850: {
1.146 schwarze 851:
1.19 kristaps 852: switch (n->type) {
1.171 schwarze 853: case ROFFT_HEAD:
1.19 kristaps 854: term_newln(p);
855: break;
1.171 schwarze 856: case ROFFT_BODY:
1.19 kristaps 857: term_newln(p);
858: break;
859: default:
860: break;
861: }
1.1 kristaps 862: }
863:
1.26 kristaps 864: static int
865: pre_RS(DECL_ARGS)
866: {
1.163 schwarze 867: struct roffsu su;
1.26 kristaps 868:
869: switch (n->type) {
1.171 schwarze 870: case ROFFT_BLOCK:
1.26 kristaps 871: term_newln(p);
872: return(1);
1.171 schwarze 873: case ROFFT_HEAD:
1.26 kristaps 874: return(0);
875: default:
876: break;
877: }
878:
1.165 schwarze 879: n = n->parent->head;
880: n->aux = SHRT_MAX + 1;
1.177 schwarze 881: if (n->child == NULL)
882: n->aux = mt->lmargin[mt->lmargincur];
883: else if (a2roffsu(n->child->string, &su, SCALE_EN))
1.175 schwarze 884: n->aux = term_hspan(p, &su) / 24;
1.165 schwarze 885: if (n->aux < 0 && (size_t)(-n->aux) > mt->offset)
886: n->aux = -mt->offset;
887: else if (n->aux > SHRT_MAX)
888: n->aux = term_len(p, p->defindent);
1.26 kristaps 889:
1.165 schwarze 890: mt->offset += n->aux;
1.140 schwarze 891: p->offset = mt->offset;
1.156 schwarze 892: p->rmargin = p->maxrmargin;
1.26 kristaps 893:
1.116 schwarze 894: if (++mt->lmarginsz < MAXMARGINS)
895: mt->lmargincur = mt->lmarginsz;
896:
1.178 schwarze 897: mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
1.26 kristaps 898: return(1);
899: }
900:
901: static void
902: post_RS(DECL_ARGS)
903: {
904:
905: switch (n->type) {
1.171 schwarze 906: case ROFFT_BLOCK:
1.110 kristaps 907: return;
1.171 schwarze 908: case ROFFT_HEAD:
1.110 kristaps 909: return;
1.26 kristaps 910: default:
911: term_newln(p);
912: break;
913: }
1.110 kristaps 914:
1.165 schwarze 915: mt->offset -= n->parent->head->aux;
1.110 kristaps 916: p->offset = mt->offset;
1.116 schwarze 917:
918: if (--mt->lmarginsz < MAXMARGINS)
919: mt->lmargincur = mt->lmarginsz;
1.137 schwarze 920: }
921:
922: static int
923: pre_UR(DECL_ARGS)
924: {
925:
1.171 schwarze 926: return (n->type != ROFFT_HEAD);
1.137 schwarze 927: }
928:
929: static void
930: post_UR(DECL_ARGS)
931: {
932:
1.171 schwarze 933: if (n->type != ROFFT_BLOCK)
1.137 schwarze 934: return;
935:
936: term_word(p, "<");
937: p->flags |= TERMP_NOSPACE;
938:
939: if (NULL != n->child->child)
940: print_man_node(p, mt, n->child->child, meta);
941:
942: p->flags |= TERMP_NOSPACE;
943: term_word(p, ">");
1.26 kristaps 944: }
945:
1.1 kristaps 946: static void
1.45 kristaps 947: print_man_node(DECL_ARGS)
1.1 kristaps 948: {
1.65 joerg 949: size_t rm, rmax;
1.54 kristaps 950: int c;
1.1 kristaps 951:
952: switch (n->type) {
1.171 schwarze 953: case ROFFT_TEXT:
1.97 kristaps 954: /*
955: * If we have a blank line, output a vertical space.
956: * If we have a space as the first character, break
957: * before printing the line's data.
958: */
1.96 kristaps 959: if ('\0' == *n->string) {
1.4 kristaps 960: term_vspace(p);
1.98 schwarze 961: return;
1.97 kristaps 962: } else if (' ' == *n->string && MAN_LINE & n->flags)
1.96 kristaps 963: term_newln(p);
1.54 kristaps 964:
1.4 kristaps 965: term_word(p, n->string);
1.130 schwarze 966: goto out;
1.52 kristaps 967:
1.171 schwarze 968: case ROFFT_EQN:
1.152 schwarze 969: if ( ! (n->flags & MAN_LINE))
970: p->flags |= TERMP_NOSPACE;
1.115 kristaps 971: term_eqn(p, n->eqn);
1.154 schwarze 972: if (n->next != NULL && ! (n->next->flags & MAN_LINE))
1.153 schwarze 973: p->flags |= TERMP_NOSPACE;
1.97 kristaps 974: return;
1.171 schwarze 975: case ROFFT_TBL:
1.169 schwarze 976: if (p->tbl.cols == NULL)
977: term_vspace(p);
1.92 kristaps 978: term_tbl(p, n->span);
1.97 kristaps 979: return;
1.1 kristaps 980: default:
981: break;
982: }
983:
1.97 kristaps 984: if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
985: term_fontrepl(p, TERMFONT_NONE);
986:
987: c = 1;
988: if (termacts[n->tok].pre)
1.135 schwarze 989: c = (*termacts[n->tok].pre)(p, mt, n, meta);
1.97 kristaps 990:
1.1 kristaps 991: if (c && n->child)
1.135 schwarze 992: print_man_nodelist(p, mt, n->child, meta);
1.1 kristaps 993:
1.97 kristaps 994: if (termacts[n->tok].post)
1.135 schwarze 995: (*termacts[n->tok].post)(p, mt, n, meta);
1.97 kristaps 996: if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
997: term_fontrepl(p, TERMFONT_NONE);
1.63 kristaps 998:
1.130 schwarze 999: out:
1000: /*
1001: * If we're in a literal context, make sure that words
1002: * together on the same line stay together. This is a
1003: * POST-printing call, so we check the NEXT word. Since
1004: * -man doesn't have nested macros, we don't need to be
1005: * more specific than this.
1006: */
1.157 schwarze 1007: if (mt->fl & MANT_LITERAL &&
1008: ! (p->flags & (TERMP_NOBREAK | TERMP_NONEWLINE)) &&
1009: (n->next == NULL || n->next->flags & MAN_LINE)) {
1.130 schwarze 1010: rm = p->rmargin;
1011: rmax = p->maxrmargin;
1012: p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
1013: p->flags |= TERMP_NOSPACE;
1.157 schwarze 1014: if (n->string != NULL && *n->string != '\0')
1.130 schwarze 1015: term_flushln(p);
1016: else
1017: term_newln(p);
1018: if (rm < rmax && n->parent->tok == MAN_HP) {
1019: p->offset = rm;
1020: p->rmargin = rmax;
1021: } else
1022: p->rmargin = rm;
1023: p->maxrmargin = rmax;
1024: }
1.63 kristaps 1025: if (MAN_EOS & n->flags)
1026: p->flags |= TERMP_SENTENCE;
1.1 kristaps 1027: }
1028:
1029:
1030: static void
1.52 kristaps 1031: print_man_nodelist(DECL_ARGS)
1.1 kristaps 1032: {
1.19 kristaps 1033:
1.168 schwarze 1034: while (n != NULL) {
1035: print_man_node(p, mt, n, meta);
1036: n = n->next;
1037: }
1.1 kristaps 1038: }
1039:
1.31 kristaps 1040: static void
1.173 schwarze 1041: print_man_foot(struct termp *p, const struct roff_meta *meta)
1.1 kristaps 1042: {
1.147 schwarze 1043: char *title;
1.156 schwarze 1044: size_t datelen, titlen;
1.73 kristaps 1045:
1.125 schwarze 1046: assert(meta->title);
1047: assert(meta->msec);
1048: assert(meta->date);
1.1 kristaps 1049:
1.52 kristaps 1050: term_fontrepl(p, TERMFONT_NONE);
1.50 kristaps 1051:
1.149 schwarze 1052: if (meta->hasbody)
1053: term_vspace(p);
1.126 schwarze 1054:
1055: /*
1056: * Temporary, undocumented option to imitate mdoc(7) output.
1.173 schwarze 1057: * In the bottom right corner, use the operating system
1058: * instead of the title.
1.126 schwarze 1059: */
1060:
1061: if ( ! p->mdocstyle) {
1.149 schwarze 1062: if (meta->hasbody) {
1063: term_vspace(p);
1064: term_vspace(p);
1065: }
1.147 schwarze 1066: mandoc_asprintf(&title, "%s(%s)",
1067: meta->title, meta->msec);
1.173 schwarze 1068: } else if (meta->os) {
1069: title = mandoc_strdup(meta->os);
1.126 schwarze 1070: } else {
1.147 schwarze 1071: title = mandoc_strdup("");
1.126 schwarze 1072: }
1.125 schwarze 1073: datelen = term_strlen(p, meta->date);
1.1 kristaps 1074:
1.173 schwarze 1075: /* Bottom left corner: operating system. */
1.126 schwarze 1076:
1.1 kristaps 1077: p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
1.139 schwarze 1078: p->trailspace = 1;
1.1 kristaps 1079: p->offset = 0;
1.156 schwarze 1080: p->rmargin = p->maxrmargin > datelen ?
1081: (p->maxrmargin + term_len(p, 1) - datelen) / 2 : 0;
1.1 kristaps 1082:
1.173 schwarze 1083: if (meta->os)
1084: term_word(p, meta->os);
1.1 kristaps 1085: term_flushln(p);
1086:
1.126 schwarze 1087: /* At the bottom in the middle: manual date. */
1088:
1.156 schwarze 1089: p->offset = p->rmargin;
1090: titlen = term_strlen(p, title);
1091: p->rmargin = p->maxrmargin > titlen ? p->maxrmargin - titlen : 0;
1.117 schwarze 1092: p->flags |= TERMP_NOSPACE;
1.123 schwarze 1093:
1.125 schwarze 1094: term_word(p, meta->date);
1.123 schwarze 1095: term_flushln(p);
1096:
1.126 schwarze 1097: /* Bottom right corner: manual title and section. */
1098:
1.123 schwarze 1099: p->flags &= ~TERMP_NOBREAK;
1100: p->flags |= TERMP_NOSPACE;
1.139 schwarze 1101: p->trailspace = 0;
1.123 schwarze 1102: p->offset = p->rmargin;
1.1 kristaps 1103: p->rmargin = p->maxrmargin;
1104:
1.123 schwarze 1105: term_word(p, title);
1.1 kristaps 1106: term_flushln(p);
1.147 schwarze 1107: free(title);
1.1 kristaps 1108: }
1109:
1.31 kristaps 1110: static void
1.173 schwarze 1111: print_man_head(struct termp *p, const struct roff_meta *meta)
1.1 kristaps 1112: {
1.148 schwarze 1113: const char *volume;
1.147 schwarze 1114: char *title;
1.148 schwarze 1115: size_t vollen, titlen;
1.73 kristaps 1116:
1.135 schwarze 1117: assert(meta->title);
1118: assert(meta->msec);
1.1 kristaps 1119:
1.148 schwarze 1120: volume = NULL == meta->vol ? "" : meta->vol;
1121: vollen = term_strlen(p, volume);
1.1 kristaps 1122:
1.126 schwarze 1123: /* Top left corner: manual title and section. */
1124:
1.147 schwarze 1125: mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec);
1.77 kristaps 1126: titlen = term_strlen(p, title);
1.1 kristaps 1127:
1.118 schwarze 1128: p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
1.139 schwarze 1129: p->trailspace = 1;
1.1 kristaps 1130: p->offset = 0;
1.148 schwarze 1131: p->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ?
1132: (p->maxrmargin - vollen + term_len(p, 1)) / 2 :
1.156 schwarze 1133: vollen < p->maxrmargin ? p->maxrmargin - vollen : 0;
1.1 kristaps 1134:
1135: term_word(p, title);
1136: term_flushln(p);
1137:
1.126 schwarze 1138: /* At the top in the middle: manual volume. */
1139:
1.117 schwarze 1140: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1141: p->offset = p->rmargin;
1.148 schwarze 1142: p->rmargin = p->offset + vollen + titlen < p->maxrmargin ?
1.57 kristaps 1143: p->maxrmargin - titlen : p->maxrmargin;
1.1 kristaps 1144:
1.148 schwarze 1145: term_word(p, volume);
1.1 kristaps 1146: term_flushln(p);
1147:
1.126 schwarze 1148: /* Top right corner: title and section, again. */
1149:
1.1 kristaps 1150: p->flags &= ~TERMP_NOBREAK;
1.139 schwarze 1151: p->trailspace = 0;
1.57 kristaps 1152: if (p->rmargin + titlen <= p->maxrmargin) {
1.117 schwarze 1153: p->flags |= TERMP_NOSPACE;
1.57 kristaps 1154: p->offset = p->rmargin;
1155: p->rmargin = p->maxrmargin;
1156: term_word(p, title);
1157: term_flushln(p);
1158: }
1.1 kristaps 1159:
1.118 schwarze 1160: p->flags &= ~TERMP_NOSPACE;
1161: p->offset = 0;
1.1 kristaps 1162: p->rmargin = p->maxrmargin;
1.61 kristaps 1163:
1.146 schwarze 1164: /*
1.126 schwarze 1165: * Groff prints three blank lines before the content.
1166: * Do the same, except in the temporary, undocumented
1167: * mode imitating mdoc(7) output.
1.62 kristaps 1168: */
1169:
1.61 kristaps 1170: term_vspace(p);
1.126 schwarze 1171: if ( ! p->mdocstyle) {
1172: term_vspace(p);
1173: term_vspace(p);
1174: }
1.147 schwarze 1175: free(title);
1.1 kristaps 1176: }
CVSweb