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