1 /* $Id: man_term.c,v 1.236 2021/06/28 19:50:15 schwarze Exp $ */
3 * Copyright (c) 2010-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
4 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 * Plain text formatter for man(7), used by mandoc(1)
19 * for ASCII, UTF-8, PostScript, and PDF output.
23 #include <sys/types.h>
32 #include "mandoc_aux.h"
41 #define MAXMARGINS 64 /* maximum number of indented scopes */
44 int lmargin[MAXMARGINS]; /* margins (incl. vis. page) */
45 int lmargincur; /* index of current margin */
46 int lmarginsz; /* actual number of nested margins */
47 size_t offset; /* default offset to visible page */
48 int pardist; /* vert. space before par., unit: [v] */
51 #define DECL_ARGS struct termp *p, \
53 struct roff_node *n, \
54 const struct roff_meta *meta
57 int (*pre)(DECL_ARGS);
58 void (*post)(DECL_ARGS);
60 #define MAN_NOTEXT (1 << 0) /* Never has text children. */
63 static void print_man_nodelist(DECL_ARGS);
64 static void print_man_node(DECL_ARGS);
65 static void print_man_head(struct termp *,
66 const struct roff_meta *);
67 static void print_man_foot(struct termp *,
68 const struct roff_meta *);
69 static void print_bvspace(struct termp *,
70 struct roff_node *, int);
72 static int pre_B(DECL_ARGS);
73 static int pre_DT(DECL_ARGS);
74 static int pre_HP(DECL_ARGS);
75 static int pre_I(DECL_ARGS);
76 static int pre_IP(DECL_ARGS);
77 static int pre_OP(DECL_ARGS);
78 static int pre_PD(DECL_ARGS);
79 static int pre_PP(DECL_ARGS);
80 static int pre_RS(DECL_ARGS);
81 static int pre_SH(DECL_ARGS);
82 static int pre_SS(DECL_ARGS);
83 static int pre_SY(DECL_ARGS);
84 static int pre_TP(DECL_ARGS);
85 static int pre_UR(DECL_ARGS);
86 static int pre_abort(DECL_ARGS);
87 static int pre_alternate(DECL_ARGS);
88 static int pre_ign(DECL_ARGS);
89 static int pre_in(DECL_ARGS);
90 static int pre_literal(DECL_ARGS);
92 static void post_IP(DECL_ARGS);
93 static void post_HP(DECL_ARGS);
94 static void post_RS(DECL_ARGS);
95 static void post_SH(DECL_ARGS);
96 static void post_SY(DECL_ARGS);
97 static void post_TP(DECL_ARGS);
98 static void post_UR(DECL_ARGS);
100 static const struct man_term_act man_term_acts[MAN_MAX - MAN_TH] = {
101 { NULL, NULL, 0 }, /* TH */
102 { pre_SH, post_SH, 0 }, /* SH */
103 { pre_SS, post_SH, 0 }, /* SS */
104 { pre_TP, post_TP, 0 }, /* TP */
105 { pre_TP, post_TP, 0 }, /* TQ */
106 { pre_abort, NULL, 0 }, /* LP */
107 { pre_PP, NULL, 0 }, /* PP */
108 { pre_abort, NULL, 0 }, /* P */
109 { pre_IP, post_IP, 0 }, /* IP */
110 { pre_HP, post_HP, 0 }, /* HP */
111 { NULL, NULL, 0 }, /* SM */
112 { pre_B, NULL, 0 }, /* SB */
113 { pre_alternate, NULL, 0 }, /* BI */
114 { pre_alternate, NULL, 0 }, /* IB */
115 { pre_alternate, NULL, 0 }, /* BR */
116 { pre_alternate, NULL, 0 }, /* RB */
117 { NULL, NULL, 0 }, /* R */
118 { pre_B, NULL, 0 }, /* B */
119 { pre_I, NULL, 0 }, /* I */
120 { pre_alternate, NULL, 0 }, /* IR */
121 { pre_alternate, NULL, 0 }, /* RI */
122 { NULL, NULL, 0 }, /* RE */
123 { pre_RS, post_RS, 0 }, /* RS */
124 { pre_DT, NULL, 0 }, /* DT */
125 { pre_ign, NULL, MAN_NOTEXT }, /* UC */
126 { pre_PD, NULL, MAN_NOTEXT }, /* PD */
127 { pre_ign, NULL, 0 }, /* AT */
128 { pre_in, NULL, MAN_NOTEXT }, /* in */
129 { pre_SY, post_SY, 0 }, /* SY */
130 { NULL, NULL, 0 }, /* YS */
131 { pre_OP, NULL, 0 }, /* OP */
132 { pre_literal, NULL, 0 }, /* EX */
133 { pre_literal, NULL, 0 }, /* EE */
134 { pre_UR, post_UR, 0 }, /* UR */
135 { NULL, NULL, 0 }, /* UE */
136 { pre_UR, post_UR, 0 }, /* MT */
137 { NULL, NULL, 0 }, /* ME */
139 static const struct man_term_act *man_term_act(enum roff_tok);
142 static const struct man_term_act *
143 man_term_act(enum roff_tok tok)
145 assert(tok >= MAN_TH && tok <= MAN_MAX);
146 return man_term_acts + (tok - MAN_TH);
150 terminal_man(void *arg, const struct roff_meta *man)
154 struct roff_node *n, *nc, *nn;
155 size_t save_defindent;
157 p = (struct termp *)arg;
158 save_defindent = p->defindent;
159 if (p->synopsisonly == 0 && p->defindent == 0)
161 p->tcol->rmargin = p->maxrmargin = p->defrmargin;
162 term_tab_set(p, NULL);
163 term_tab_set(p, "T");
164 term_tab_set(p, ".5i");
166 memset(&mt, 0, sizeof(mt));
167 mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
168 mt.offset = term_len(p, p->defindent);
171 n = man->first->child;
172 if (p->synopsisonly) {
173 for (nn = NULL; n != NULL; n = n->next) {
174 if (n->tok != MAN_SH)
176 nc = n->child->child;
177 if (nc->type != ROFFT_TEXT)
179 if (strcmp(nc->string, "SYNOPSIS") == 0)
181 if (nn == NULL && strcmp(nc->string, "NAME") == 0)
186 p->flags |= TERMP_NOSPACE;
187 if (n != NULL && (n = n->child->next->child) != NULL)
188 print_man_nodelist(p, &mt, n, man);
191 term_begin(p, print_man_head, print_man_foot, man);
192 p->flags |= TERMP_NOSPACE;
194 print_man_nodelist(p, &mt, n, man);
197 p->defindent = save_defindent;
201 * Printing leading vertical space before a block.
202 * This is used for the paragraph macros.
203 * The rules are pretty simple, since there's very little nesting going
204 * on here. Basically, if we're the first within another block (SS/SH),
205 * then don't emit vertical space. If we are (RS), then do. If not the
209 print_bvspace(struct termp *p, struct roff_node *n, int pardist)
211 struct roff_node *nch;
216 if (n->body != NULL &&
217 (nch = roff_node_child(n->body)) != NULL &&
218 nch->type == ROFFT_TBL)
221 if (n->parent->tok != MAN_RS && roff_node_prev(n) == NULL)
224 for (i = 0; i < pardist; i++)
244 term_fontrepl(p, TERMFONT_UNDER);
249 pre_literal(DECL_ARGS)
254 * Unlike .IP and .TP, .HP does not have a HEAD.
255 * So in case a second call to term_flushln() is needed,
256 * indentation has to be set up explicitly.
258 if (n->parent->tok == MAN_HP && p->tcol->rmargin < p->maxrmargin) {
259 p->tcol->offset = p->tcol->rmargin;
260 p->tcol->rmargin = p->maxrmargin;
262 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
263 p->flags |= TERMP_NOSPACE;
278 assert(n->type == ROFFT_TEXT);
279 if (a2roffsu(n->string, &su, SCALE_VS) != NULL)
280 mt->pardist = term_vspan(p, &su);
285 pre_alternate(DECL_ARGS)
287 enum termfont font[2];
288 struct roff_node *nn;
293 font[0] = TERMFONT_NONE;
294 font[1] = TERMFONT_BOLD;
297 font[0] = TERMFONT_NONE;
298 font[1] = TERMFONT_UNDER;
301 font[0] = TERMFONT_BOLD;
302 font[1] = TERMFONT_NONE;
305 font[0] = TERMFONT_BOLD;
306 font[1] = TERMFONT_UNDER;
309 font[0] = TERMFONT_UNDER;
310 font[1] = TERMFONT_NONE;
313 font[0] = TERMFONT_UNDER;
314 font[1] = TERMFONT_BOLD;
319 for (i = 0, nn = n->child; nn != NULL; nn = nn->next, i = 1 - i) {
320 term_fontrepl(p, font[i]);
321 assert(nn->type == ROFFT_TEXT);
322 term_word(p, nn->string);
323 if (nn->flags & NODE_EOS)
324 p->flags |= TERMP_SENTENCE;
325 if (nn->next != NULL)
326 p->flags |= TERMP_NOSPACE;
334 term_fontrepl(p, TERMFONT_BOLD);
342 p->flags |= TERMP_KEEP | TERMP_NOSPACE;
344 if ((n = n->child) != NULL) {
345 term_fontrepl(p, TERMFONT_BOLD);
346 term_word(p, n->string);
348 if (n != NULL && n->next != NULL) {
349 term_fontrepl(p, TERMFONT_UNDER);
350 term_word(p, n->next->string);
352 term_fontrepl(p, TERMFONT_NONE);
353 p->flags &= ~TERMP_KEEP;
354 p->flags |= TERMP_NOSPACE;
369 if (n->child == NULL) {
370 p->tcol->offset = mt->offset;
374 cp = n->child->string;
384 if (a2roffsu(++cp, &su, SCALE_EN) == NULL)
387 v = term_hen(p, &su);
390 p->tcol->offset -= p->tcol->offset > v ? v : p->tcol->offset;
392 p->tcol->offset += v;
395 if (p->tcol->offset > SHRT_MAX)
396 p->tcol->offset = term_len(p, p->defindent);
404 term_tab_set(p, NULL);
405 term_tab_set(p, "T");
406 term_tab_set(p, ".5i");
414 const struct roff_node *nn;
419 print_bvspace(p, n, mt->pardist);
429 if (n->child == NULL)
432 if ((n->child->flags & NODE_NOFILL) == 0) {
433 p->flags |= TERMP_NOBREAK | TERMP_BRIND;
437 /* Calculate offset. */
439 if ((nn = n->parent->head->child) != NULL &&
440 a2roffsu(nn->string, &su, SCALE_EN) != NULL) {
441 len = term_hen(p, &su);
442 if (len < 0 && (size_t)(-len) > mt->offset)
444 else if (len > SHRT_MAX)
445 len = term_len(p, p->defindent);
446 mt->lmargin[mt->lmargincur] = len;
448 len = mt->lmargin[mt->lmargincur];
450 p->tcol->offset = mt->offset;
451 p->tcol->rmargin = mt->offset + len;
466 * Compatibility with a groff bug.
467 * The .HP macro uses the undocumented .tag request
468 * which causes a line break and cancels no-space
469 * mode even if there isn't any output.
472 if (n->child == NULL)
475 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
477 p->tcol->offset = mt->offset;
478 p->tcol->rmargin = p->maxrmargin;
490 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
491 print_bvspace(p, n, mt->pardist);
496 p->tcol->offset = mt->offset;
508 const struct roff_node *nn;
513 print_bvspace(p, n, mt->pardist);
516 p->flags |= TERMP_NOBREAK;
520 p->flags |= TERMP_NOSPACE;
526 /* Calculate the offset from the optional second argument. */
527 if ((nn = n->parent->head->child) != NULL &&
528 (nn = nn->next) != NULL &&
529 a2roffsu(nn->string, &su, SCALE_EN) != NULL) {
530 len = term_hen(p, &su);
531 if (len < 0 && (size_t)(-len) > mt->offset)
533 else if (len > SHRT_MAX)
534 len = term_len(p, p->defindent);
535 mt->lmargin[mt->lmargincur] = len;
537 len = mt->lmargin[mt->lmargincur];
541 p->tcol->offset = mt->offset;
542 p->tcol->rmargin = mt->offset + len;
543 if (n->child != NULL)
544 print_man_node(p, mt, n->child, meta);
547 p->tcol->offset = mt->offset + len;
548 p->tcol->rmargin = p->maxrmargin;
564 p->flags &= ~TERMP_NOBREAK;
566 p->tcol->rmargin = p->maxrmargin;
570 p->tcol->offset = mt->offset;
581 struct roff_node *nn;
586 if (n->tok == MAN_TP)
587 print_bvspace(p, n, mt->pardist);
590 p->flags |= TERMP_NOBREAK | TERMP_BRTRSP;
594 p->flags |= TERMP_NOSPACE;
600 /* Calculate offset. */
602 if ((nn = n->parent->head->child) != NULL &&
603 nn->string != NULL && ! (NODE_LINE & nn->flags) &&
604 a2roffsu(nn->string, &su, SCALE_EN) != NULL) {
605 len = term_hen(p, &su);
606 if (len < 0 && (size_t)(-len) > mt->offset)
608 else if (len > SHRT_MAX)
609 len = term_len(p, p->defindent);
610 mt->lmargin[mt->lmargincur] = len;
612 len = mt->lmargin[mt->lmargincur];
616 p->tcol->offset = mt->offset;
617 p->tcol->rmargin = mt->offset + len;
619 /* Don't print same-line elements. */
621 while (nn != NULL && (nn->flags & NODE_LINE) == 0)
625 print_man_node(p, mt, nn, meta);
630 p->tcol->offset = mt->offset + len;
631 p->tcol->rmargin = p->maxrmargin;
633 p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP);
652 p->tcol->offset = mt->offset;
666 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
667 mt->offset = term_len(p, p->defindent);
670 * No vertical space before the first subsection
671 * and after an empty subsection.
674 if ((n = roff_node_prev(n)) == NULL ||
675 (n->tok == MAN_SS && roff_node_child(n->body) == NULL))
678 for (i = 0; i < mt->pardist; i++)
682 term_fontrepl(p, TERMFONT_BOLD);
683 p->tcol->offset = term_len(p, 3);
684 p->tcol->rmargin = mt->offset;
685 p->trailspace = mt->offset;
686 p->flags |= TERMP_NOBREAK | TERMP_BRIND;
689 p->tcol->offset = mt->offset;
690 p->tcol->rmargin = p->maxrmargin;
692 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
707 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
708 mt->offset = term_len(p, p->defindent);
711 * No vertical space before the first section
712 * and after an empty section.
715 if ((n = roff_node_prev(n)) == NULL ||
716 (n->tok == MAN_SH && roff_node_child(n->body) == NULL))
719 for (i = 0; i < mt->pardist; i++)
723 term_fontrepl(p, TERMFONT_BOLD);
725 p->tcol->rmargin = mt->offset;
726 p->trailspace = mt->offset;
727 p->flags |= TERMP_NOBREAK | TERMP_BRIND;
730 p->tcol->offset = mt->offset;
731 p->tcol->rmargin = p->maxrmargin;
733 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
774 n->aux = SHRT_MAX + 1;
775 if (n->child == NULL)
776 n->aux = mt->lmargin[mt->lmargincur];
777 else if (a2roffsu(n->child->string, &su, SCALE_EN) != NULL)
778 n->aux = term_hen(p, &su);
779 if (n->aux < 0 && (size_t)(-n->aux) > mt->offset)
780 n->aux = -mt->offset;
781 else if (n->aux > SHRT_MAX)
782 n->aux = term_len(p, p->defindent);
784 mt->offset += n->aux;
785 p->tcol->offset = mt->offset;
786 p->tcol->rmargin = p->maxrmargin;
788 if (++mt->lmarginsz < MAXMARGINS)
789 mt->lmargincur = mt->lmarginsz;
791 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
808 mt->offset -= n->parent->head->aux;
809 p->tcol->offset = mt->offset;
810 if (--mt->lmarginsz < MAXMARGINS)
811 mt->lmargincur = mt->lmarginsz;
817 const struct roff_node *nn;
822 if ((nn = roff_node_prev(n)) == NULL || nn->tok != MAN_SY)
823 print_bvspace(p, n, mt->pardist);
832 nn = n->parent->head->child;
833 len = nn == NULL ? 1 : term_strlen(p, nn->string) + 1;
837 p->tcol->offset = mt->offset;
838 p->tcol->rmargin = mt->offset + len;
839 if (n->next->child == NULL ||
840 (n->next->child->flags & NODE_NOFILL) == 0)
841 p->flags |= TERMP_NOBREAK;
842 term_fontrepl(p, TERMFONT_BOLD);
845 mt->lmargin[mt->lmargincur] = len;
846 p->tcol->offset = mt->offset + len;
847 p->tcol->rmargin = p->maxrmargin;
848 p->flags |= TERMP_NOSPACE;
864 p->flags &= ~TERMP_NOBREAK;
868 p->tcol->offset = mt->offset;
878 return n->type != ROFFT_HEAD;
884 if (n->type != ROFFT_BLOCK)
888 p->flags |= TERMP_NOSPACE;
890 if (n->child->child != NULL)
891 print_man_node(p, mt, n->child->child, meta);
893 p->flags |= TERMP_NOSPACE;
898 print_man_node(DECL_ARGS)
900 const struct man_term_act *act;
903 if (n->flags & NODE_ID)
904 term_tag_write(n, p->line);
909 * If we have a blank line, output a vertical space.
910 * If we have a space as the first character, break
911 * before printing the line's data.
913 if (*n->string == '\0') {
914 if (p->flags & TERMP_NONEWLINE)
919 } else if (*n->string == ' ' && n->flags & NODE_LINE &&
920 (p->flags & TERMP_NONEWLINE) == 0)
922 else if (n->flags & NODE_DELIMC)
923 p->flags |= TERMP_NOSPACE;
925 term_word(p, n->string);
930 if ( ! (n->flags & NODE_LINE))
931 p->flags |= TERMP_NOSPACE;
933 if (n->next != NULL && ! (n->next->flags & NODE_LINE))
934 p->flags |= TERMP_NOSPACE;
937 if (p->tbl.cols == NULL)
939 term_tbl(p, n->span);
945 if (n->tok < ROFF_MAX) {
950 act = man_term_act(n->tok);
951 if ((act->flags & MAN_NOTEXT) == 0 && n->tok != MAN_SM)
952 term_fontrepl(p, TERMFONT_NONE);
955 if (act->pre != NULL)
956 c = (*act->pre)(p, mt, n, meta);
958 if (c && n->child != NULL)
959 print_man_nodelist(p, mt, n->child, meta);
961 if (act->post != NULL)
962 (*act->post)(p, mt, n, meta);
963 if ((act->flags & MAN_NOTEXT) == 0 && n->tok != MAN_SM)
964 term_fontrepl(p, TERMFONT_NONE);
968 * If we're in a literal context, make sure that words
969 * together on the same line stay together. This is a
970 * POST-printing call, so we check the NEXT word. Since
971 * -man doesn't have nested macros, we don't need to be
972 * more specific than this.
974 if (n->flags & NODE_NOFILL &&
975 ! (p->flags & (TERMP_NOBREAK | TERMP_NONEWLINE)) &&
976 (n->next == NULL || n->next->flags & NODE_LINE)) {
977 p->flags |= TERMP_BRNEVER | TERMP_NOSPACE;
978 if (n->string != NULL && *n->string != '\0')
982 p->flags &= ~TERMP_BRNEVER;
983 if (p->tcol->rmargin < p->maxrmargin &&
984 n->parent->tok == MAN_HP) {
985 p->tcol->offset = p->tcol->rmargin;
986 p->tcol->rmargin = p->maxrmargin;
989 if (n->flags & NODE_EOS)
990 p->flags |= TERMP_SENTENCE;
994 print_man_nodelist(DECL_ARGS)
997 print_man_node(p, mt, n, meta);
1003 print_man_foot(struct termp *p, const struct roff_meta *meta)
1006 size_t datelen, titlen;
1008 assert(meta->title);
1012 term_fontrepl(p, TERMFONT_NONE);
1018 * Temporary, undocumented option to imitate mdoc(7) output.
1019 * In the bottom right corner, use the operating system
1020 * instead of the title.
1023 if ( ! p->mdocstyle) {
1024 mandoc_asprintf(&title, "%s(%s)",
1025 meta->title, meta->msec);
1026 } else if (meta->os != NULL) {
1027 title = mandoc_strdup(meta->os);
1029 title = mandoc_strdup("");
1031 datelen = term_strlen(p, meta->date);
1033 /* Bottom left corner: operating system. */
1035 p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
1037 p->tcol->offset = 0;
1038 p->tcol->rmargin = p->maxrmargin > datelen ?
1039 (p->maxrmargin + term_len(p, 1) - datelen) / 2 : 0;
1042 term_word(p, meta->os);
1045 /* At the bottom in the middle: manual date. */
1047 p->tcol->offset = p->tcol->rmargin;
1048 titlen = term_strlen(p, title);
1049 p->tcol->rmargin = p->maxrmargin > titlen ?
1050 p->maxrmargin - titlen : 0;
1051 p->flags |= TERMP_NOSPACE;
1053 term_word(p, meta->date);
1056 /* Bottom right corner: manual title and section. */
1058 p->flags &= ~TERMP_NOBREAK;
1059 p->flags |= TERMP_NOSPACE;
1061 p->tcol->offset = p->tcol->rmargin;
1062 p->tcol->rmargin = p->maxrmargin;
1064 term_word(p, title);
1068 * Reset the terminal state for more output after the footer:
1069 * Some output modes, in particular PostScript and PDF, print
1070 * the header and the footer into a buffer such that it can be
1071 * reused for multiple output pages, then go on to format the
1075 p->tcol->offset = 0;
1082 print_man_head(struct termp *p, const struct roff_meta *meta)
1086 size_t vollen, titlen;
1088 assert(meta->title);
1091 volume = NULL == meta->vol ? "" : meta->vol;
1092 vollen = term_strlen(p, volume);
1094 /* Top left corner: manual title and section. */
1096 mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec);
1097 titlen = term_strlen(p, title);
1099 p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
1101 p->tcol->offset = 0;
1102 p->tcol->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ?
1103 (p->maxrmargin - vollen + term_len(p, 1)) / 2 :
1104 vollen < p->maxrmargin ? p->maxrmargin - vollen : 0;
1106 term_word(p, title);
1109 /* At the top in the middle: manual volume. */
1111 p->flags |= TERMP_NOSPACE;
1112 p->tcol->offset = p->tcol->rmargin;
1113 p->tcol->rmargin = p->tcol->offset + vollen + titlen <
1114 p->maxrmargin ? p->maxrmargin - titlen : p->maxrmargin;
1116 term_word(p, volume);
1119 /* Top right corner: title and section, again. */
1121 p->flags &= ~TERMP_NOBREAK;
1123 if (p->tcol->rmargin + titlen <= p->maxrmargin) {
1124 p->flags |= TERMP_NOSPACE;
1125 p->tcol->offset = p->tcol->rmargin;
1126 p->tcol->rmargin = p->maxrmargin;
1127 term_word(p, title);
1131 p->flags &= ~TERMP_NOSPACE;
1132 p->tcol->offset = 0;
1133 p->tcol->rmargin = p->maxrmargin;
1136 * Groff prints three blank lines before the content.
1137 * Do the same, except in the temporary, undocumented
1138 * mode imitating mdoc(7) output.