1 /* $Id: mdoc_term.c,v 1.331 2016/01/08 17:48:09 schwarze Exp $ */
3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2010, 2012-2016 Ingo Schwarze <schwarze@openbsd.org>
5 * Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include <sys/types.h>
31 #include "mandoc_aux.h"
41 struct termpair *ppair;
45 #define DECL_ARGS struct termp *p, \
46 struct termpair *pair, \
47 const struct roff_meta *meta, \
51 int (*pre)(DECL_ARGS);
52 void (*post)(DECL_ARGS);
55 static int a2width(const struct termp *, const char *);
57 static void print_bvspace(struct termp *,
58 const struct roff_node *,
59 const struct roff_node *);
60 static void print_mdoc_node(DECL_ARGS);
61 static void print_mdoc_nodelist(DECL_ARGS);
62 static void print_mdoc_head(struct termp *, const struct roff_meta *);
63 static void print_mdoc_foot(struct termp *, const struct roff_meta *);
64 static void synopsis_pre(struct termp *,
65 const struct roff_node *);
67 static void termp____post(DECL_ARGS);
68 static void termp__t_post(DECL_ARGS);
69 static void termp_bd_post(DECL_ARGS);
70 static void termp_bk_post(DECL_ARGS);
71 static void termp_bl_post(DECL_ARGS);
72 static void termp_eo_post(DECL_ARGS);
73 static void termp_fd_post(DECL_ARGS);
74 static void termp_fo_post(DECL_ARGS);
75 static void termp_in_post(DECL_ARGS);
76 static void termp_it_post(DECL_ARGS);
77 static void termp_lb_post(DECL_ARGS);
78 static void termp_nm_post(DECL_ARGS);
79 static void termp_pf_post(DECL_ARGS);
80 static void termp_quote_post(DECL_ARGS);
81 static void termp_sh_post(DECL_ARGS);
82 static void termp_ss_post(DECL_ARGS);
84 static int termp__a_pre(DECL_ARGS);
85 static int termp__t_pre(DECL_ARGS);
86 static int termp_an_pre(DECL_ARGS);
87 static int termp_ap_pre(DECL_ARGS);
88 static int termp_bd_pre(DECL_ARGS);
89 static int termp_bf_pre(DECL_ARGS);
90 static int termp_bk_pre(DECL_ARGS);
91 static int termp_bl_pre(DECL_ARGS);
92 static int termp_bold_pre(DECL_ARGS);
93 static int termp_bt_pre(DECL_ARGS);
94 static int termp_bx_pre(DECL_ARGS);
95 static int termp_cd_pre(DECL_ARGS);
96 static int termp_d1_pre(DECL_ARGS);
97 static int termp_eo_pre(DECL_ARGS);
98 static int termp_er_pre(DECL_ARGS);
99 static int termp_ex_pre(DECL_ARGS);
100 static int termp_fa_pre(DECL_ARGS);
101 static int termp_fd_pre(DECL_ARGS);
102 static int termp_fl_pre(DECL_ARGS);
103 static int termp_fn_pre(DECL_ARGS);
104 static int termp_fo_pre(DECL_ARGS);
105 static int termp_ft_pre(DECL_ARGS);
106 static int termp_in_pre(DECL_ARGS);
107 static int termp_it_pre(DECL_ARGS);
108 static int termp_li_pre(DECL_ARGS);
109 static int termp_ll_pre(DECL_ARGS);
110 static int termp_lk_pre(DECL_ARGS);
111 static int termp_nd_pre(DECL_ARGS);
112 static int termp_nm_pre(DECL_ARGS);
113 static int termp_ns_pre(DECL_ARGS);
114 static int termp_quote_pre(DECL_ARGS);
115 static int termp_rs_pre(DECL_ARGS);
116 static int termp_rv_pre(DECL_ARGS);
117 static int termp_sh_pre(DECL_ARGS);
118 static int termp_skip_pre(DECL_ARGS);
119 static int termp_sm_pre(DECL_ARGS);
120 static int termp_sp_pre(DECL_ARGS);
121 static int termp_ss_pre(DECL_ARGS);
122 static int termp_tag_pre(DECL_ARGS);
123 static int termp_under_pre(DECL_ARGS);
124 static int termp_ud_pre(DECL_ARGS);
125 static int termp_vt_pre(DECL_ARGS);
126 static int termp_xr_pre(DECL_ARGS);
127 static int termp_xx_pre(DECL_ARGS);
129 static const struct termact termacts[MDOC_MAX] = {
130 { termp_ap_pre, NULL }, /* Ap */
131 { NULL, NULL }, /* Dd */
132 { NULL, NULL }, /* Dt */
133 { NULL, NULL }, /* Os */
134 { termp_sh_pre, termp_sh_post }, /* Sh */
135 { termp_ss_pre, termp_ss_post }, /* Ss */
136 { termp_sp_pre, NULL }, /* Pp */
137 { termp_d1_pre, termp_bl_post }, /* D1 */
138 { termp_d1_pre, termp_bl_post }, /* Dl */
139 { termp_bd_pre, termp_bd_post }, /* Bd */
140 { NULL, NULL }, /* Ed */
141 { termp_bl_pre, termp_bl_post }, /* Bl */
142 { NULL, NULL }, /* El */
143 { termp_it_pre, termp_it_post }, /* It */
144 { termp_under_pre, NULL }, /* Ad */
145 { termp_an_pre, NULL }, /* An */
146 { termp_under_pre, NULL }, /* Ar */
147 { termp_cd_pre, NULL }, /* Cd */
148 { termp_bold_pre, NULL }, /* Cm */
149 { termp_li_pre, NULL }, /* Dv */
150 { termp_er_pre, NULL }, /* Er */
151 { termp_tag_pre, NULL }, /* Ev */
152 { termp_ex_pre, NULL }, /* Ex */
153 { termp_fa_pre, NULL }, /* Fa */
154 { termp_fd_pre, termp_fd_post }, /* Fd */
155 { termp_fl_pre, NULL }, /* Fl */
156 { termp_fn_pre, NULL }, /* Fn */
157 { termp_ft_pre, NULL }, /* Ft */
158 { termp_bold_pre, NULL }, /* Ic */
159 { termp_in_pre, termp_in_post }, /* In */
160 { termp_li_pre, NULL }, /* Li */
161 { termp_nd_pre, NULL }, /* Nd */
162 { termp_nm_pre, termp_nm_post }, /* Nm */
163 { termp_quote_pre, termp_quote_post }, /* Op */
164 { termp_ft_pre, NULL }, /* Ot */
165 { termp_under_pre, NULL }, /* Pa */
166 { termp_rv_pre, NULL }, /* Rv */
167 { NULL, NULL }, /* St */
168 { termp_under_pre, NULL }, /* Va */
169 { termp_vt_pre, NULL }, /* Vt */
170 { termp_xr_pre, NULL }, /* Xr */
171 { termp__a_pre, termp____post }, /* %A */
172 { termp_under_pre, termp____post }, /* %B */
173 { NULL, termp____post }, /* %D */
174 { termp_under_pre, termp____post }, /* %I */
175 { termp_under_pre, termp____post }, /* %J */
176 { NULL, termp____post }, /* %N */
177 { NULL, termp____post }, /* %O */
178 { NULL, termp____post }, /* %P */
179 { NULL, termp____post }, /* %R */
180 { termp__t_pre, termp__t_post }, /* %T */
181 { NULL, termp____post }, /* %V */
182 { NULL, NULL }, /* Ac */
183 { termp_quote_pre, termp_quote_post }, /* Ao */
184 { termp_quote_pre, termp_quote_post }, /* Aq */
185 { NULL, NULL }, /* At */
186 { NULL, NULL }, /* Bc */
187 { termp_bf_pre, NULL }, /* Bf */
188 { termp_quote_pre, termp_quote_post }, /* Bo */
189 { termp_quote_pre, termp_quote_post }, /* Bq */
190 { termp_xx_pre, NULL }, /* Bsx */
191 { termp_bx_pre, NULL }, /* Bx */
192 { termp_skip_pre, NULL }, /* Db */
193 { NULL, NULL }, /* Dc */
194 { termp_quote_pre, termp_quote_post }, /* Do */
195 { termp_quote_pre, termp_quote_post }, /* Dq */
196 { NULL, NULL }, /* Ec */ /* FIXME: no space */
197 { NULL, NULL }, /* Ef */
198 { termp_under_pre, NULL }, /* Em */
199 { termp_eo_pre, termp_eo_post }, /* Eo */
200 { termp_xx_pre, NULL }, /* Fx */
201 { termp_bold_pre, NULL }, /* Ms */
202 { termp_li_pre, NULL }, /* No */
203 { termp_ns_pre, NULL }, /* Ns */
204 { termp_xx_pre, NULL }, /* Nx */
205 { termp_xx_pre, NULL }, /* Ox */
206 { NULL, NULL }, /* Pc */
207 { NULL, termp_pf_post }, /* Pf */
208 { termp_quote_pre, termp_quote_post }, /* Po */
209 { termp_quote_pre, termp_quote_post }, /* Pq */
210 { NULL, NULL }, /* Qc */
211 { termp_quote_pre, termp_quote_post }, /* Ql */
212 { termp_quote_pre, termp_quote_post }, /* Qo */
213 { termp_quote_pre, termp_quote_post }, /* Qq */
214 { NULL, NULL }, /* Re */
215 { termp_rs_pre, NULL }, /* Rs */
216 { NULL, NULL }, /* Sc */
217 { termp_quote_pre, termp_quote_post }, /* So */
218 { termp_quote_pre, termp_quote_post }, /* Sq */
219 { termp_sm_pre, NULL }, /* Sm */
220 { termp_under_pre, NULL }, /* Sx */
221 { termp_bold_pre, NULL }, /* Sy */
222 { NULL, NULL }, /* Tn */
223 { termp_xx_pre, NULL }, /* Ux */
224 { NULL, NULL }, /* Xc */
225 { NULL, NULL }, /* Xo */
226 { termp_fo_pre, termp_fo_post }, /* Fo */
227 { NULL, NULL }, /* Fc */
228 { termp_quote_pre, termp_quote_post }, /* Oo */
229 { NULL, NULL }, /* Oc */
230 { termp_bk_pre, termp_bk_post }, /* Bk */
231 { NULL, NULL }, /* Ek */
232 { termp_bt_pre, NULL }, /* Bt */
233 { NULL, NULL }, /* Hf */
234 { termp_under_pre, NULL }, /* Fr */
235 { termp_ud_pre, NULL }, /* Ud */
236 { NULL, termp_lb_post }, /* Lb */
237 { termp_sp_pre, NULL }, /* Lp */
238 { termp_lk_pre, NULL }, /* Lk */
239 { termp_under_pre, NULL }, /* Mt */
240 { termp_quote_pre, termp_quote_post }, /* Brq */
241 { termp_quote_pre, termp_quote_post }, /* Bro */
242 { NULL, NULL }, /* Brc */
243 { NULL, termp____post }, /* %C */
244 { termp_skip_pre, NULL }, /* Es */
245 { termp_quote_pre, termp_quote_post }, /* En */
246 { termp_xx_pre, NULL }, /* Dx */
247 { NULL, termp____post }, /* %Q */
248 { termp_sp_pre, NULL }, /* br */
249 { termp_sp_pre, NULL }, /* sp */
250 { NULL, termp____post }, /* %U */
251 { NULL, NULL }, /* Ta */
252 { termp_ll_pre, NULL }, /* ll */
258 terminal_mdoc(void *arg, const struct roff_man *mdoc)
263 p = (struct termp *)arg;
265 p->rmargin = p->maxrmargin = p->defrmargin;
266 p->tabwidth = term_len(p, 5);
268 n = mdoc->first->child;
269 if (p->synopsisonly) {
271 if (n->tok == MDOC_Sh && n->sec == SEC_SYNOPSIS) {
272 if (n->child->next->child != NULL)
273 print_mdoc_nodelist(p, NULL,
275 n->child->next->child);
282 if (p->defindent == 0)
284 term_begin(p, print_mdoc_head, print_mdoc_foot,
287 if (n->tok != MDOC_Sh)
289 print_mdoc_nodelist(p, NULL, &mdoc->meta, n);
296 print_mdoc_nodelist(DECL_ARGS)
300 print_mdoc_node(p, pair, meta, n);
306 print_mdoc_node(DECL_ARGS)
309 struct termpair npair;
310 size_t offset, rmargin;
314 rmargin = p->rmargin;
315 n->flags &= ~MDOC_ENDED;
316 n->prev_font = p->fonti;
318 memset(&npair, 0, sizeof(struct termpair));
322 * Keeps only work until the end of a line. If a keep was
323 * invoked in a prior line, revert it to PREKEEP.
326 if (p->flags & TERMP_KEEP && n->flags & MDOC_LINE) {
327 p->flags &= ~TERMP_KEEP;
328 p->flags |= TERMP_PREKEEP;
332 * After the keep flags have been set up, we may now
333 * produce output. Note that some pre-handlers do so.
338 if (' ' == *n->string && MDOC_LINE & n->flags)
340 if (MDOC_DELIMC & n->flags)
341 p->flags |= TERMP_NOSPACE;
342 term_word(p, n->string);
343 if (MDOC_DELIMO & n->flags)
344 p->flags |= TERMP_NOSPACE;
347 if ( ! (n->flags & MDOC_LINE))
348 p->flags |= TERMP_NOSPACE;
350 if (n->next != NULL && ! (n->next->flags & MDOC_LINE))
351 p->flags |= TERMP_NOSPACE;
354 if (p->tbl.cols == NULL)
356 term_tbl(p, n->span);
359 if (termacts[n->tok].pre &&
360 (n->end == ENDBODY_NOT || n->child != NULL))
361 chld = (*termacts[n->tok].pre)
362 (p, &npair, meta, n);
366 if (chld && n->child)
367 print_mdoc_nodelist(p, &npair, meta, n->child);
370 (ENDBODY_NOT == n->end ? n : n->body)->prev_font);
380 if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags)
382 (void)(*termacts[n->tok].post)(p, &npair, meta, n);
385 * Explicit end tokens not only call the post
386 * handler, but also tell the respective block
387 * that it must not call the post handler again.
389 if (ENDBODY_NOT != n->end)
390 n->body->flags |= MDOC_ENDED;
393 * End of line terminating an implicit block
394 * while an explicit block is still open.
395 * Continue the explicit block without spacing.
397 if (ENDBODY_NOSPACE == n->end)
398 p->flags |= TERMP_NOSPACE;
402 if (MDOC_EOS & n->flags)
403 p->flags |= TERMP_SENTENCE;
405 if (MDOC_ll != n->tok) {
407 p->rmargin = rmargin;
412 print_mdoc_foot(struct termp *p, const struct roff_meta *meta)
416 term_fontrepl(p, TERMFONT_NONE);
419 * Output the footer in new-groff style, that is, three columns
420 * with the middle being the manual date and flanking columns
421 * being the operating system:
429 sz = term_strlen(p, meta->date);
430 p->rmargin = p->maxrmargin > sz ?
431 (p->maxrmargin + term_len(p, 1) - sz) / 2 : 0;
433 p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
435 term_word(p, meta->os);
438 p->offset = p->rmargin;
439 sz = term_strlen(p, meta->os);
440 p->rmargin = p->maxrmargin > sz ? p->maxrmargin - sz : 0;
441 p->flags |= TERMP_NOSPACE;
443 term_word(p, meta->date);
446 p->offset = p->rmargin;
447 p->rmargin = p->maxrmargin;
449 p->flags &= ~TERMP_NOBREAK;
450 p->flags |= TERMP_NOSPACE;
452 term_word(p, meta->os);
456 p->rmargin = p->maxrmargin;
461 print_mdoc_head(struct termp *p, const struct roff_meta *meta)
463 char *volume, *title;
464 size_t vollen, titlen;
467 * The header is strange. It has three components, which are
468 * really two with the first duplicated. It goes like this:
470 * IDENTIFIER TITLE IDENTIFIER
472 * The IDENTIFIER is NAME(SECTION), which is the command-name
473 * (if given, or "unknown" if not) followed by the manual page
474 * section. These are given in `Dt'. The TITLE is a free-form
475 * string depending on the manual volume. If not specified, it
476 * switches on the manual section.
480 if (NULL == meta->arch)
481 volume = mandoc_strdup(meta->vol);
483 mandoc_asprintf(&volume, "%s (%s)",
484 meta->vol, meta->arch);
485 vollen = term_strlen(p, volume);
487 if (NULL == meta->msec)
488 title = mandoc_strdup(meta->title);
490 mandoc_asprintf(&title, "%s(%s)",
491 meta->title, meta->msec);
492 titlen = term_strlen(p, title);
494 p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
497 p->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ?
498 (p->maxrmargin - vollen + term_len(p, 1)) / 2 :
499 vollen < p->maxrmargin ? p->maxrmargin - vollen : 0;
504 p->flags |= TERMP_NOSPACE;
505 p->offset = p->rmargin;
506 p->rmargin = p->offset + vollen + titlen < p->maxrmargin ?
507 p->maxrmargin - titlen : p->maxrmargin;
509 term_word(p, volume);
512 p->flags &= ~TERMP_NOBREAK;
514 if (p->rmargin + titlen <= p->maxrmargin) {
515 p->flags |= TERMP_NOSPACE;
516 p->offset = p->rmargin;
517 p->rmargin = p->maxrmargin;
522 p->flags &= ~TERMP_NOSPACE;
524 p->rmargin = p->maxrmargin;
530 a2width(const struct termp *p, const char *v)
534 if (a2roffsu(v, &su, SCALE_MAX) < 2) {
535 SCALE_HS_INIT(&su, term_strlen(p, v));
536 su.scale /= term_strlen(p, "0");
538 return term_hspan(p, &su) / 24;
542 * Determine how much space to print out before block elements of `It'
543 * (and thus `Bl') and `Bd'. And then go ahead and print that space,
547 print_bvspace(struct termp *p,
548 const struct roff_node *bl,
549 const struct roff_node *n)
551 const struct roff_node *nn;
557 if (MDOC_Bd == bl->tok && bl->norm->Bd.comp)
559 if (MDOC_Bl == bl->tok && bl->norm->Bl.comp)
562 /* Do not vspace directly after Ss/Sh. */
565 while (nn->prev == NULL) {
568 if (nn->type == ROFFT_ROOT)
570 } while (nn->type != ROFFT_BLOCK);
571 if (nn->tok == MDOC_Sh || nn->tok == MDOC_Ss)
573 if (nn->tok == MDOC_It &&
574 nn->parent->parent->norm->Bl.type != LIST_item)
578 /* A `-column' does not assert vspace within the list. */
580 if (MDOC_Bl == bl->tok && LIST_column == bl->norm->Bl.type)
581 if (n->prev && MDOC_It == n->prev->tok)
584 /* A `-diag' without body does not vspace. */
586 if (MDOC_Bl == bl->tok && LIST_diag == bl->norm->Bl.type)
587 if (n->prev && MDOC_It == n->prev->tok) {
588 assert(n->prev->body);
589 if (NULL == n->prev->body->child)
598 termp_ll_pre(DECL_ARGS)
601 term_setwidth(p, n->child != NULL ? n->child->string : NULL);
606 termp_it_pre(DECL_ARGS)
609 const struct roff_node *bl, *nn;
611 int i, offset, width;
614 if (n->type == ROFFT_BLOCK) {
615 print_bvspace(p, n->parent->parent, n);
619 bl = n->parent->parent->parent;
620 type = bl->norm->Bl.type;
623 * Defaults for specific list types.
631 width = term_len(p, 2);
634 width = term_len(p, 8);
638 width = term_len(p, 10);
647 * First calculate width and offset. This is pretty easy unless
648 * we're a -column list, in which case all prior columns must
652 if (bl->norm->Bl.offs != NULL) {
653 offset = a2width(p, bl->norm->Bl.offs);
654 if (offset < 0 && (size_t)(-offset) > p->offset)
656 else if (offset > SHRT_MAX)
662 if (n->type == ROFFT_HEAD)
666 * Imitate groff's column handling:
667 * - For each earlier column, add its width.
668 * - For less than 5 columns, add four more blanks per
670 * - For exactly 5 columns, add three more blank per
672 * - For more than 5 columns, add only one column.
674 ncols = bl->norm->Bl.ncols;
675 dcol = ncols < 5 ? term_len(p, 4) :
676 ncols == 5 ? term_len(p, 3) : term_len(p, 1);
679 * Calculate the offset by applying all prior ROFFT_BODY,
680 * so we stop at the ROFFT_HEAD (nn->prev == NULL).
683 for (i = 0, nn = n->prev;
684 nn->prev && i < (int)ncols;
686 offset += dcol + a2width(p,
687 bl->norm->Bl.cols[i]);
690 * When exceeding the declared number of columns, leave
691 * the remaining widths at 0. This will later be
692 * adjusted to the default width of 10, or, for the last
693 * column, stretched to the right margin.
699 * Use the declared column widths, extended as explained
700 * in the preceding paragraph.
702 width = a2width(p, bl->norm->Bl.cols[i]) + dcol;
705 if (NULL == bl->norm->Bl.width)
709 * Note: buffer the width by 2, which is groff's magic
710 * number for buffering single arguments. See the above
711 * handling for column for how this changes.
713 width = a2width(p, bl->norm->Bl.width) + term_len(p, 2);
714 if (width < 0 && (size_t)(-width) > p->offset)
716 else if (width > SHRT_MAX)
722 * Whitespace control. Inset bodies need an initial space,
723 * while diagonal bodies need two.
726 p->flags |= TERMP_NOSPACE;
730 if (n->type == ROFFT_BODY)
731 term_word(p, "\\ \\ ");
734 if (n->type == ROFFT_BODY && n->parent->head->child != NULL)
741 p->flags |= TERMP_NOSPACE;
745 if (n->type == ROFFT_HEAD)
746 term_fontpush(p, TERMFONT_BOLD);
753 * Pad and break control. This is the tricky part. These flags
754 * are documented in term_flushln() in term.c. Note that we're
755 * going to unset all of these flags in termp_it_post() when we
765 * Weird special case.
766 * Some very narrow lists actually hang.
768 if (width <= (int)term_len(p, 2))
769 p->flags |= TERMP_HANG;
770 if (n->type != ROFFT_HEAD)
772 p->flags |= TERMP_NOBREAK;
776 if (n->type != ROFFT_HEAD)
780 * This is ugly. If `-hang' is specified and the body
781 * is a `Bl' or `Bd', then we want basically to nullify
782 * the "overstep" effect in term_flushln() and treat
783 * this as a `-ohang' list instead.
785 if (NULL != n->next &&
786 NULL != n->next->child &&
787 (MDOC_Bl == n->next->child->tok ||
788 MDOC_Bd == n->next->child->tok))
791 p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
795 if (n->type != ROFFT_HEAD)
798 p->flags |= TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND;
801 if (NULL == n->next || NULL == n->next->child)
802 p->flags |= TERMP_DANGLE;
805 if (n->type == ROFFT_HEAD)
808 if (NULL == n->next) {
809 p->flags &= ~TERMP_NOBREAK;
812 p->flags |= TERMP_NOBREAK;
818 if (n->type != ROFFT_HEAD)
820 p->flags |= TERMP_NOBREAK | TERMP_BRIND;
828 * Margin control. Set-head-width lists have their right
829 * margins shortened. The body for these lists has the offset
830 * necessarily lengthened. Everybody gets the offset.
838 * Same stipulation as above, regarding `-hang'. We
839 * don't want to recalculate rmargin and offsets when
840 * using `Bd' or `Bl' within `-hang' overstep lists.
842 if (n->type == ROFFT_HEAD &&
844 NULL != n->next->child &&
845 (MDOC_Bl == n->next->child->tok ||
846 MDOC_Bd == n->next->child->tok))
854 if (n->type == ROFFT_HEAD)
855 p->rmargin = p->offset + width;
861 p->rmargin = p->offset + width;
863 * XXX - this behaviour is not documented: the
864 * right-most column is filled to the right margin.
866 if (n->type == ROFFT_HEAD)
868 if (NULL == n->next && p->rmargin < p->maxrmargin)
869 p->rmargin = p->maxrmargin;
876 * The dash, hyphen, bullet and enum lists all have a special
877 * HEAD character (temporarily bold, in some cases).
880 if (n->type == ROFFT_HEAD)
883 term_fontpush(p, TERMFONT_BOLD);
884 term_word(p, "\\[bu]");
889 term_fontpush(p, TERMFONT_BOLD);
894 (pair->ppair->ppair->count)++;
895 (void)snprintf(buf, sizeof(buf), "%d.",
896 pair->ppair->ppair->count);
904 * If we're not going to process our children, indicate so here.
913 if (n->type == ROFFT_HEAD)
917 if (n->type == ROFFT_HEAD)
928 termp_it_post(DECL_ARGS)
932 if (n->type == ROFFT_BLOCK)
935 type = n->parent->parent->parent->norm->Bl.type;
941 if (n->type == ROFFT_BODY)
945 if (n->type == ROFFT_BODY)
954 * Now that our output is flushed, we can reset our tags. Since
955 * only `It' sets these flags, we're free to assume that nobody
956 * has munged them in the meanwhile.
959 p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND |
960 TERMP_DANGLE | TERMP_HANG);
965 termp_nm_pre(DECL_ARGS)
969 if (n->type == ROFFT_BLOCK) {
970 p->flags |= TERMP_PREKEEP;
974 if (n->type == ROFFT_BODY) {
975 if (NULL == n->child)
977 p->flags |= TERMP_NOSPACE;
979 if (n->prev->child != NULL)
980 cp = n->prev->child->string;
984 p->offset += term_len(p, 6);
986 p->offset += term_len(p, 1) + term_strlen(p, cp);
990 if (NULL == n->child && NULL == meta->name)
993 if (n->type == ROFFT_HEAD)
994 synopsis_pre(p, n->parent);
996 if (n->type == ROFFT_HEAD &&
997 NULL != n->next && NULL != n->next->child) {
998 p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_BRIND;
1000 p->rmargin = p->offset + term_len(p, 1);
1001 if (NULL == n->child) {
1002 p->rmargin += term_strlen(p, meta->name);
1003 } else if (n->child->type == ROFFT_TEXT) {
1004 p->rmargin += term_strlen(p, n->child->string);
1006 p->flags |= TERMP_HANG;
1008 p->rmargin += term_len(p, 5);
1009 p->flags |= TERMP_HANG;
1013 term_fontpush(p, TERMFONT_BOLD);
1014 if (NULL == n->child)
1015 term_word(p, meta->name);
1020 termp_nm_post(DECL_ARGS)
1023 if (n->type == ROFFT_BLOCK) {
1024 p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
1025 } else if (n->type == ROFFT_HEAD &&
1026 NULL != n->next && NULL != n->next->child) {
1028 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG);
1030 } else if (n->type == ROFFT_BODY && n->child != NULL)
1035 termp_fl_pre(DECL_ARGS)
1038 termp_tag_pre(p, pair, meta, n);
1039 term_fontpush(p, TERMFONT_BOLD);
1040 term_word(p, "\\-");
1042 if (!(n->child == NULL &&
1044 n->next->type == ROFFT_TEXT ||
1045 n->next->flags & MDOC_LINE)))
1046 p->flags |= TERMP_NOSPACE;
1052 termp__a_pre(DECL_ARGS)
1055 if (n->prev && MDOC__A == n->prev->tok)
1056 if (NULL == n->next || MDOC__A != n->next->tok)
1057 term_word(p, "and");
1063 termp_an_pre(DECL_ARGS)
1066 if (n->norm->An.auth == AUTH_split) {
1067 p->flags &= ~TERMP_NOSPLIT;
1068 p->flags |= TERMP_SPLIT;
1071 if (n->norm->An.auth == AUTH_nosplit) {
1072 p->flags &= ~TERMP_SPLIT;
1073 p->flags |= TERMP_NOSPLIT;
1077 if (p->flags & TERMP_SPLIT)
1080 if (n->sec == SEC_AUTHORS && ! (p->flags & TERMP_NOSPLIT))
1081 p->flags |= TERMP_SPLIT;
1087 termp_ns_pre(DECL_ARGS)
1090 if ( ! (MDOC_LINE & n->flags))
1091 p->flags |= TERMP_NOSPACE;
1096 termp_rs_pre(DECL_ARGS)
1099 if (SEC_SEE_ALSO != n->sec)
1101 if (n->type == ROFFT_BLOCK && n->prev != NULL)
1107 termp_rv_pre(DECL_ARGS)
1109 struct roff_node *nch;
1113 if (n->child != NULL) {
1114 term_word(p, "The");
1116 for (nch = n->child; nch != NULL; nch = nch->next) {
1117 term_fontpush(p, TERMFONT_BOLD);
1118 term_word(p, nch->string);
1121 p->flags |= TERMP_NOSPACE;
1124 if (nch->next == NULL)
1127 if (nch->prev != NULL || nch->next->next != NULL) {
1128 p->flags |= TERMP_NOSPACE;
1131 if (nch->next->next == NULL)
1132 term_word(p, "and");
1135 if (n->child != NULL && n->child->next != NULL)
1136 term_word(p, "functions return");
1138 term_word(p, "function returns");
1140 term_word(p, "the value\\~0 if successful;");
1142 term_word(p, "Upon successful completion,"
1143 " the value\\~0 is returned;");
1145 term_word(p, "otherwise the value\\~\\-1 is returned"
1146 " and the global variable");
1148 term_fontpush(p, TERMFONT_UNDER);
1149 term_word(p, "errno");
1152 term_word(p, "is set to indicate the error.");
1153 p->flags |= TERMP_SENTENCE;
1159 termp_ex_pre(DECL_ARGS)
1161 struct roff_node *nch;
1164 term_word(p, "The");
1166 for (nch = n->child; nch != NULL; nch = nch->next) {
1167 term_fontpush(p, TERMFONT_BOLD);
1168 term_word(p, nch->string);
1171 if (nch->next == NULL)
1174 if (nch->prev != NULL || nch->next->next != NULL) {
1175 p->flags |= TERMP_NOSPACE;
1179 if (nch->next->next == NULL)
1180 term_word(p, "and");
1183 if (n->child != NULL && n->child->next != NULL)
1184 term_word(p, "utilities exit\\~0");
1186 term_word(p, "utility exits\\~0");
1188 term_word(p, "on success, and\\~>0 if an error occurs.");
1190 p->flags |= TERMP_SENTENCE;
1195 termp_nd_pre(DECL_ARGS)
1198 if (n->type == ROFFT_BODY)
1199 term_word(p, "\\(en");
1204 termp_bl_pre(DECL_ARGS)
1207 return n->type != ROFFT_HEAD;
1211 termp_bl_post(DECL_ARGS)
1214 if (n->type == ROFFT_BLOCK)
1219 termp_xr_pre(DECL_ARGS)
1222 if (NULL == (n = n->child))
1225 assert(n->type == ROFFT_TEXT);
1226 term_word(p, n->string);
1228 if (NULL == (n = n->next))
1231 p->flags |= TERMP_NOSPACE;
1233 p->flags |= TERMP_NOSPACE;
1235 assert(n->type == ROFFT_TEXT);
1236 term_word(p, n->string);
1238 p->flags |= TERMP_NOSPACE;
1245 * This decides how to assert whitespace before any of the SYNOPSIS set
1246 * of macros (which, as in the case of Ft/Fo and Ft/Fn, may contain
1250 synopsis_pre(struct termp *p, const struct roff_node *n)
1253 * Obviously, if we're not in a SYNOPSIS or no prior macros
1254 * exist, do nothing.
1256 if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
1260 * If we're the second in a pair of like elements, emit our
1261 * newline and return. UNLESS we're `Fo', `Fn', `Fn', in which
1262 * case we soldier on.
1264 if (n->prev->tok == n->tok &&
1265 MDOC_Ft != n->tok &&
1266 MDOC_Fo != n->tok &&
1267 MDOC_Fn != n->tok) {
1273 * If we're one of the SYNOPSIS set and non-like pair-wise after
1274 * another (or Fn/Fo, which we've let slip through) then assert
1275 * vertical space, else only newline and move on.
1277 switch (n->prev->tok) {
1286 if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
1298 termp_vt_pre(DECL_ARGS)
1301 if (n->type == ROFFT_ELEM) {
1303 return termp_under_pre(p, pair, meta, n);
1304 } else if (n->type == ROFFT_BLOCK) {
1307 } else if (n->type == ROFFT_HEAD)
1310 return termp_under_pre(p, pair, meta, n);
1314 termp_bold_pre(DECL_ARGS)
1317 termp_tag_pre(p, pair, meta, n);
1318 term_fontpush(p, TERMFONT_BOLD);
1323 termp_fd_pre(DECL_ARGS)
1327 return termp_bold_pre(p, pair, meta, n);
1331 termp_fd_post(DECL_ARGS)
1338 termp_sh_pre(DECL_ARGS)
1344 * Vertical space before sections, except
1345 * when the previous section was empty.
1347 if (n->prev == NULL ||
1348 n->prev->tok != MDOC_Sh ||
1349 (n->prev->body != NULL &&
1350 n->prev->body->child != NULL))
1354 term_fontpush(p, TERMFONT_BOLD);
1357 p->offset = term_len(p, p->defindent);
1359 case SEC_DESCRIPTION:
1363 p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT);
1376 termp_sh_post(DECL_ARGS)
1393 termp_bt_pre(DECL_ARGS)
1396 term_word(p, "is currently in beta test.");
1397 p->flags |= TERMP_SENTENCE;
1402 termp_lb_post(DECL_ARGS)
1405 if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags)
1410 termp_ud_pre(DECL_ARGS)
1413 term_word(p, "currently under development.");
1414 p->flags |= TERMP_SENTENCE;
1419 termp_d1_pre(DECL_ARGS)
1422 if (n->type != ROFFT_BLOCK)
1425 p->offset += term_len(p, p->defindent + 1);
1430 termp_ft_pre(DECL_ARGS)
1433 /* NB: MDOC_LINE does not effect this! */
1435 term_fontpush(p, TERMFONT_UNDER);
1440 termp_fn_pre(DECL_ARGS)
1445 pretty = MDOC_SYNPRETTY & n->flags;
1449 if (NULL == (n = n->child))
1453 rmargin = p->rmargin;
1454 p->rmargin = p->offset + term_len(p, 4);
1455 p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
1458 assert(n->type == ROFFT_TEXT);
1459 term_fontpush(p, TERMFONT_BOLD);
1460 term_word(p, n->string);
1463 if (n->sec == SEC_DESCRIPTION)
1464 tag_put(n->string, ++fn_prio, p->line);
1468 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG);
1469 p->offset = p->rmargin;
1470 p->rmargin = rmargin;
1473 p->flags |= TERMP_NOSPACE;
1475 p->flags |= TERMP_NOSPACE;
1477 for (n = n->next; n; n = n->next) {
1478 assert(n->type == ROFFT_TEXT);
1479 term_fontpush(p, TERMFONT_UNDER);
1481 p->flags |= TERMP_NBRWORD;
1482 term_word(p, n->string);
1486 p->flags |= TERMP_NOSPACE;
1491 p->flags |= TERMP_NOSPACE;
1495 p->flags |= TERMP_NOSPACE;
1504 termp_fa_pre(DECL_ARGS)
1506 const struct roff_node *nn;
1508 if (n->parent->tok != MDOC_Fo) {
1509 term_fontpush(p, TERMFONT_UNDER);
1513 for (nn = n->child; nn; nn = nn->next) {
1514 term_fontpush(p, TERMFONT_UNDER);
1515 p->flags |= TERMP_NBRWORD;
1516 term_word(p, nn->string);
1519 if (nn->next || (n->next && n->next->tok == MDOC_Fa)) {
1520 p->flags |= TERMP_NOSPACE;
1529 termp_bd_pre(DECL_ARGS)
1531 size_t tabwidth, lm, len, rm, rmax;
1532 struct roff_node *nn;
1535 if (n->type == ROFFT_BLOCK) {
1536 print_bvspace(p, n, n);
1538 } else if (n->type == ROFFT_HEAD)
1541 /* Handle the -offset argument. */
1543 if (n->norm->Bd.offs == NULL ||
1544 ! strcmp(n->norm->Bd.offs, "left"))
1546 else if ( ! strcmp(n->norm->Bd.offs, "indent"))
1547 p->offset += term_len(p, p->defindent + 1);
1548 else if ( ! strcmp(n->norm->Bd.offs, "indent-two"))
1549 p->offset += term_len(p, (p->defindent + 1) * 2);
1551 offset = a2width(p, n->norm->Bd.offs);
1552 if (offset < 0 && (size_t)(-offset) > p->offset)
1554 else if (offset < SHRT_MAX)
1555 p->offset += offset;
1559 * If -ragged or -filled are specified, the block does nothing
1560 * but change the indentation. If -unfilled or -literal are
1561 * specified, text is printed exactly as entered in the display:
1562 * for macro lines, a newline is appended to the line. Blank
1563 * lines are allowed.
1566 if (DISP_literal != n->norm->Bd.type &&
1567 DISP_unfilled != n->norm->Bd.type &&
1568 DISP_centered != n->norm->Bd.type)
1571 tabwidth = p->tabwidth;
1572 if (DISP_literal == n->norm->Bd.type)
1573 p->tabwidth = term_len(p, 8);
1577 rmax = p->maxrmargin;
1578 p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
1580 for (nn = n->child; nn; nn = nn->next) {
1581 if (DISP_centered == n->norm->Bd.type) {
1582 if (nn->type == ROFFT_TEXT) {
1583 len = term_strlen(p, nn->string);
1584 p->offset = len >= rm ? 0 :
1585 lm + len >= rm ? rm - len :
1586 (lm + rm - len) / 2;
1590 print_mdoc_node(p, pair, meta, nn);
1592 * If the printed node flushes its own line, then we
1593 * needn't do it here as well. This is hacky, but the
1594 * notion of selective eoln whitespace is pretty dumb
1595 * anyway, so don't sweat it.
1610 if (p->flags & TERMP_NONEWLINE ||
1611 (nn->next && ! (nn->next->flags & MDOC_LINE)))
1614 p->flags |= TERMP_NOSPACE;
1617 p->tabwidth = tabwidth;
1619 p->maxrmargin = rmax;
1624 termp_bd_post(DECL_ARGS)
1628 if (n->type != ROFFT_BODY)
1632 rmax = p->maxrmargin;
1634 if (DISP_literal == n->norm->Bd.type ||
1635 DISP_unfilled == n->norm->Bd.type)
1636 p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
1638 p->flags |= TERMP_NOSPACE;
1642 p->maxrmargin = rmax;
1646 termp_bx_pre(DECL_ARGS)
1649 if (NULL != (n = n->child)) {
1650 term_word(p, n->string);
1651 p->flags |= TERMP_NOSPACE;
1652 term_word(p, "BSD");
1654 term_word(p, "BSD");
1658 if (NULL != (n = n->next)) {
1659 p->flags |= TERMP_NOSPACE;
1661 p->flags |= TERMP_NOSPACE;
1662 term_word(p, n->string);
1669 termp_xx_pre(DECL_ARGS)
1701 p->flags |= TERMP_KEEP;
1702 term_word(p, n->child->string);
1709 termp_pf_post(DECL_ARGS)
1712 if ( ! (n->next == NULL || n->next->flags & MDOC_LINE))
1713 p->flags |= TERMP_NOSPACE;
1717 termp_ss_pre(DECL_ARGS)
1727 term_fontpush(p, TERMFONT_BOLD);
1728 p->offset = term_len(p, (p->defindent+1)/2);
1731 p->offset = term_len(p, p->defindent);
1741 termp_ss_post(DECL_ARGS)
1744 if (n->type == ROFFT_HEAD || n->type == ROFFT_BODY)
1749 termp_cd_pre(DECL_ARGS)
1753 term_fontpush(p, TERMFONT_BOLD);
1758 termp_in_pre(DECL_ARGS)
1763 if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags) {
1764 term_fontpush(p, TERMFONT_BOLD);
1765 term_word(p, "#include");
1769 term_fontpush(p, TERMFONT_UNDER);
1772 p->flags |= TERMP_NOSPACE;
1777 termp_in_post(DECL_ARGS)
1780 if (MDOC_SYNPRETTY & n->flags)
1781 term_fontpush(p, TERMFONT_BOLD);
1783 p->flags |= TERMP_NOSPACE;
1786 if (MDOC_SYNPRETTY & n->flags)
1791 termp_sp_pre(DECL_ARGS)
1799 if ( ! a2roffsu(n->child->string, &su, SCALE_VS))
1801 len = term_vspan(p, &su);
1819 for (i = 0; i < len; i++)
1826 termp_skip_pre(DECL_ARGS)
1833 termp_quote_pre(DECL_ARGS)
1836 if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
1842 term_word(p, n->child != NULL && n->child->next == NULL &&
1843 n->child->tok == MDOC_Mt ? "<" : "\\(la");
1857 term_word(p, "\\(Lq");
1860 if (NULL == n->norm->Es ||
1861 NULL == n->norm->Es->child)
1863 term_word(p, n->norm->Es->child->string);
1877 term_word(p, "\\(oq");
1883 p->flags |= TERMP_NOSPACE;
1888 termp_quote_post(DECL_ARGS)
1891 if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
1894 p->flags |= TERMP_NOSPACE;
1899 term_word(p, n->child != NULL && n->child->next == NULL &&
1900 n->child->tok == MDOC_Mt ? ">" : "\\(ra");
1914 term_word(p, "\\(Rq");
1917 if (n->norm->Es == NULL ||
1918 n->norm->Es->child == NULL ||
1919 n->norm->Es->child->next == NULL)
1920 p->flags &= ~TERMP_NOSPACE;
1922 term_word(p, n->norm->Es->child->next->string);
1936 term_word(p, "\\(cq");
1944 termp_eo_pre(DECL_ARGS)
1947 if (n->type != ROFFT_BODY)
1950 if (n->end == ENDBODY_NOT &&
1951 n->parent->head->child == NULL &&
1953 n->child->end != ENDBODY_NOT)
1954 term_word(p, "\\&");
1955 else if (n->end != ENDBODY_NOT ? n->child != NULL :
1956 n->parent->head->child != NULL && (n->child != NULL ||
1957 (n->parent->tail != NULL && n->parent->tail->child != NULL)))
1958 p->flags |= TERMP_NOSPACE;
1964 termp_eo_post(DECL_ARGS)
1968 if (n->type != ROFFT_BODY)
1971 if (n->end != ENDBODY_NOT) {
1972 p->flags &= ~TERMP_NOSPACE;
1976 body = n->child != NULL || n->parent->head->child != NULL;
1977 tail = n->parent->tail != NULL && n->parent->tail->child != NULL;
1980 p->flags |= TERMP_NOSPACE;
1981 else if ( ! (body || tail))
1982 term_word(p, "\\&");
1984 p->flags &= ~TERMP_NOSPACE;
1988 termp_fo_pre(DECL_ARGS)
1993 pretty = MDOC_SYNPRETTY & n->flags;
1995 if (n->type == ROFFT_BLOCK) {
1998 } else if (n->type == ROFFT_BODY) {
2000 rmargin = p->rmargin;
2001 p->rmargin = p->offset + term_len(p, 4);
2002 p->flags |= TERMP_NOBREAK | TERMP_BRIND |
2005 p->flags |= TERMP_NOSPACE;
2007 p->flags |= TERMP_NOSPACE;
2010 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
2012 p->offset = p->rmargin;
2013 p->rmargin = rmargin;
2018 if (NULL == n->child)
2021 /* XXX: we drop non-initial arguments as per groff. */
2023 assert(n->child->string);
2024 term_fontpush(p, TERMFONT_BOLD);
2025 term_word(p, n->child->string);
2030 termp_fo_post(DECL_ARGS)
2033 if (n->type != ROFFT_BODY)
2036 p->flags |= TERMP_NOSPACE;
2039 if (MDOC_SYNPRETTY & n->flags) {
2040 p->flags |= TERMP_NOSPACE;
2047 termp_bf_pre(DECL_ARGS)
2050 if (n->type == ROFFT_HEAD)
2052 else if (n->type != ROFFT_BODY)
2055 if (FONT_Em == n->norm->Bf.font)
2056 term_fontpush(p, TERMFONT_UNDER);
2057 else if (FONT_Sy == n->norm->Bf.font)
2058 term_fontpush(p, TERMFONT_BOLD);
2060 term_fontpush(p, TERMFONT_NONE);
2066 termp_sm_pre(DECL_ARGS)
2069 if (NULL == n->child)
2070 p->flags ^= TERMP_NONOSPACE;
2071 else if (0 == strcmp("on", n->child->string))
2072 p->flags &= ~TERMP_NONOSPACE;
2074 p->flags |= TERMP_NONOSPACE;
2076 if (p->col && ! (TERMP_NONOSPACE & p->flags))
2077 p->flags &= ~TERMP_NOSPACE;
2083 termp_ap_pre(DECL_ARGS)
2086 p->flags |= TERMP_NOSPACE;
2088 p->flags |= TERMP_NOSPACE;
2093 termp____post(DECL_ARGS)
2097 * Handle lists of authors. In general, print each followed by
2098 * a comma. Don't print the comma if there are only two
2101 if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok)
2102 if (NULL == n->next->next || MDOC__A != n->next->next->tok)
2103 if (NULL == n->prev || MDOC__A != n->prev->tok)
2108 if (NULL == n->parent || MDOC_Rs != n->parent->tok)
2111 p->flags |= TERMP_NOSPACE;
2112 if (NULL == n->next) {
2114 p->flags |= TERMP_SENTENCE;
2120 termp_li_pre(DECL_ARGS)
2123 term_fontpush(p, TERMFONT_NONE);
2128 termp_lk_pre(DECL_ARGS)
2130 const struct roff_node *link, *descr;
2132 if (NULL == (link = n->child))
2135 if (NULL != (descr = link->next)) {
2136 term_fontpush(p, TERMFONT_UNDER);
2137 while (NULL != descr) {
2138 term_word(p, descr->string);
2139 descr = descr->next;
2141 p->flags |= TERMP_NOSPACE;
2146 term_fontpush(p, TERMFONT_BOLD);
2147 term_word(p, link->string);
2154 termp_bk_pre(DECL_ARGS)
2163 if (n->parent->args != NULL || n->prev->child == NULL)
2164 p->flags |= TERMP_PREKEEP;
2174 termp_bk_post(DECL_ARGS)
2177 if (n->type == ROFFT_BODY)
2178 p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
2182 termp__t_post(DECL_ARGS)
2186 * If we're in an `Rs' and there's a journal present, then quote
2187 * us instead of underlining us (for disambiguation).
2189 if (n->parent && MDOC_Rs == n->parent->tok &&
2190 n->parent->norm->Rs.quote_T)
2191 termp_quote_post(p, pair, meta, n);
2193 termp____post(p, pair, meta, n);
2197 termp__t_pre(DECL_ARGS)
2201 * If we're in an `Rs' and there's a journal present, then quote
2202 * us instead of underlining us (for disambiguation).
2204 if (n->parent && MDOC_Rs == n->parent->tok &&
2205 n->parent->norm->Rs.quote_T)
2206 return termp_quote_pre(p, pair, meta, n);
2208 term_fontpush(p, TERMFONT_UNDER);
2213 termp_under_pre(DECL_ARGS)
2216 term_fontpush(p, TERMFONT_UNDER);
2221 termp_er_pre(DECL_ARGS)
2224 if (n->sec == SEC_ERRORS &&
2225 (n->parent->tok == MDOC_It ||
2226 (n->parent->tok == MDOC_Bq &&
2227 n->parent->parent->parent->tok == MDOC_It)))
2228 tag_put(n->child->string, 1, p->line);
2233 termp_tag_pre(DECL_ARGS)
2236 if (n->child != NULL &&
2237 n->child->type == ROFFT_TEXT &&
2239 (n->parent->tok == MDOC_It ||
2240 (n->parent->tok == MDOC_Xo &&
2241 n->parent->parent->prev == NULL &&
2242 n->parent->parent->parent->tok == MDOC_It)))
2243 tag_put(n->child->string, 1, p->line);