=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.379 retrieving revision 1.383 diff -u -p -r1.379 -r1.383 --- mandoc/mdoc_term.c 2020/03/13 15:32:28 1.379 +++ mandoc/mdoc_term.c 2023/11/13 19:13:01 1.383 @@ -1,6 +1,6 @@ -/* $Id: mdoc_term.c,v 1.379 2020/03/13 15:32:28 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.383 2023/11/13 19:13:01 schwarze Exp $ */ /* - * Copyright (c) 2010, 2012-2020 Ingo Schwarze + * Copyright (c) 2010, 2012-2020, 2022 Ingo Schwarze * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2013 Franco Fichtner * @@ -250,7 +250,6 @@ terminal_mdoc(void *arg, const struct roff_meta *mdoc) { struct roff_node *n, *nn; struct termp *p; - size_t save_defindent; p = (struct termp *)arg; p->tcol->rmargin = p->maxrmargin = p->defrmargin; @@ -275,9 +274,6 @@ terminal_mdoc(void *arg, const struct roff_meta *mdoc) print_mdoc_nodelist(p, NULL, mdoc, n); term_newln(p); } else { - save_defindent = p->defindent; - if (p->defindent == 0) - p->defindent = 5; term_begin(p, print_mdoc_head, print_mdoc_foot, mdoc); while (n != NULL && (n->type == ROFFT_COMMENT || @@ -289,7 +285,6 @@ terminal_mdoc(void *arg, const struct roff_meta *mdoc) print_mdoc_nodelist(p, NULL, mdoc, n); } term_end(p); - p->defindent = save_defindent; } } @@ -320,8 +315,11 @@ print_mdoc_node(DECL_ARGS) (p->flags & TERMP_NONEWLINE) == 0) term_newln(p); p->flags |= TERMP_BRNEVER; - } else + } else { + if (n->flags & NODE_LINE) + term_tab_ref(p); p->flags &= ~TERMP_BRNEVER; + } if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT) return; @@ -335,7 +333,8 @@ print_mdoc_node(DECL_ARGS) memset(&npair, 0, sizeof(struct termpair)); npair.ppair = pair; - if (n->flags & NODE_ID) + if (n->flags & NODE_ID && n->tok != MDOC_Pp && + (n->tok != MDOC_It || n->type != ROFFT_BLOCK)) term_tag_write(n, p->line); /* @@ -565,8 +564,8 @@ a2width(const struct termp *p, const char *v) end = a2roffsu(v, &su, SCALE_MAX); if (end == NULL || *end != '\0') { - SCALE_HS_INIT(&su, term_strlen(p, v)); - su.scale /= term_strlen(p, "0"); + su.unit = SCALE_EN; + su.scale = term_strlen(p, v) / term_strlen(p, "0"); } return term_hen(p, &su); } @@ -630,6 +629,8 @@ termp_it_pre(DECL_ARGS) if (n->type == ROFFT_BLOCK) { print_bvspace(p, n->parent->parent, n); + if (n->flags & NODE_ID) + term_tag_write(n, p->line); return 1; } @@ -700,9 +701,9 @@ termp_it_pre(DECL_ARGS) for (i = 0, nn = n->prev; nn->prev && i < (int)ncols; nn = nn->prev, i++) { - SCALE_HS_INIT(&su, - term_strlen(p, bl->norm->Bl.cols[i])); - su.scale /= term_strlen(p, "0"); + su.unit = SCALE_EN; + su.scale = term_strlen(p, bl->norm->Bl.cols[i]) / + term_strlen(p, "0"); offset += term_hen(p, &su) + dcol; } @@ -719,8 +720,9 @@ termp_it_pre(DECL_ARGS) * Use the declared column widths, extended as explained * in the preceding paragraph. */ - SCALE_HS_INIT(&su, term_strlen(p, bl->norm->Bl.cols[i])); - su.scale /= term_strlen(p, "0"); + su.unit = SCALE_EN; + su.scale = term_strlen(p, bl->norm->Bl.cols[i]) / + term_strlen(p, "0"); width = term_hen(p, &su) + dcol; break; default: @@ -1110,7 +1112,6 @@ termp_ex_pre(DECL_ARGS) static int termp_nd_pre(DECL_ARGS) { - if (n->type == ROFFT_BODY) term_word(p, "\\(en"); return 1; @@ -1119,14 +1120,20 @@ termp_nd_pre(DECL_ARGS) static int termp_bl_pre(DECL_ARGS) { - - return n->type != ROFFT_HEAD; + switch (n->type) { + case ROFFT_BLOCK: + term_newln(p); + return 1; + case ROFFT_HEAD: + return 0; + default: + return 1; + } } static void termp_bl_post(DECL_ARGS) { - if (n->type != ROFFT_BLOCK) return; term_newln(p); @@ -1140,7 +1147,6 @@ termp_bl_post(DECL_ARGS) static int termp_xr_pre(DECL_ARGS) { - if (NULL == (n = n->child)) return 0; @@ -1555,6 +1561,8 @@ static int termp_pp_pre(DECL_ARGS) { term_vspace(p); + if (n->flags & NODE_ID) + term_tag_write(n, p->line); return 0; }