=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mdoc_html.c,v retrieving revision 1.208 retrieving revision 1.209 diff -c -r1.208 -r1.209 *** src/usr.bin/mandoc/mdoc_html.c 2020/01/19 17:59:01 1.208 --- src/usr.bin/mandoc/mdoc_html.c 2020/02/27 01:25:57 1.209 *************** *** 1,4 **** ! /* $OpenBSD: mdoc_html.c,v 1.208 2020/01/19 17:59:01 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2014-2020 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: mdoc_html.c,v 1.209 2020/02/27 01:25:57 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2014-2020 Ingo Schwarze *************** *** 50,57 **** struct html *); static void print_mdoc_node(MDOC_ARGS); static void print_mdoc_nodelist(MDOC_ARGS); ! static void synopsis_pre(struct html *, ! const struct roff_node *); static void mdoc_root_post(const struct roff_meta *, struct html *); --- 50,56 ---- struct html *); static void print_mdoc_node(MDOC_ARGS); static void print_mdoc_nodelist(MDOC_ARGS); ! static void synopsis_pre(struct html *, struct roff_node *); static void mdoc_root_post(const struct roff_meta *, struct html *); *************** *** 248,260 **** * See the same function in mdoc_term.c for documentation. */ static void ! synopsis_pre(struct html *h, const struct roff_node *n) { ! if (NULL == n->prev || ! (NODE_SYNPRETTY & n->flags)) return; ! if (n->prev->tok == n->tok && MDOC_Fo != n->tok && MDOC_Ft != n->tok && MDOC_Fn != n->tok) { --- 247,261 ---- * See the same function in mdoc_term.c for documentation. */ static void ! synopsis_pre(struct html *h, struct roff_node *n) { + struct roff_node *np; ! if ((n->flags & NODE_SYNPRETTY) == 0 || ! (np = roff_node_prev(n)) == NULL) return; ! if (np->tok == n->tok && MDOC_Fo != n->tok && MDOC_Ft != n->tok && MDOC_Fn != n->tok) { *************** *** 262,268 **** return; } ! switch (n->prev->tok) { case MDOC_Fd: case MDOC_Fn: case MDOC_Fo: --- 263,269 ---- return; } ! switch (np->tok) { case MDOC_Fd: case MDOC_Fn: case MDOC_Fo: *************** *** 623,639 **** static int mdoc_fl_pre(MDOC_ARGS) { ! char *id; if ((id = cond_id(n)) != NULL) print_otag(h, TAG_A, "chR", "permalink", id); print_otag(h, TAG_CODE, "ci", "Fl", id); print_text(h, "\\-"); ! if (!(n->child == NULL && ! (n->next == NULL || ! n->next->type == ROFFT_TEXT || ! n->next->flags & NODE_LINE))) h->flags |= HTML_NOSPACE; return 1; --- 624,641 ---- static int mdoc_fl_pre(MDOC_ARGS) { ! struct roff_node *nn; ! char *id; if ((id = cond_id(n)) != NULL) print_otag(h, TAG_A, "chR", "permalink", id); print_otag(h, TAG_CODE, "ci", "Fl", id); print_text(h, "\\-"); ! if (n->child != NULL || ! ((nn = roff_node_next(n)) != NULL && ! nn->type != ROFFT_TEXT && ! (nn->flags & NODE_LINE) == 0)) h->flags |= HTML_NOSPACE; return 1; *************** *** 907,913 **** static int mdoc_ex_pre(MDOC_ARGS) { ! if (n->prev) print_otag(h, TAG_BR, ""); return 1; } --- 909,915 ---- static int mdoc_ex_pre(MDOC_ARGS) { ! if (roff_node_prev(n) != NULL) print_otag(h, TAG_BR, ""); return 1; } *************** *** 984,990 **** continue; if (nn->tok == MDOC_Sh || nn->tok == MDOC_Ss) comp = 1; ! if (nn->prev != NULL) break; } (void)strlcpy(buf, "Bd", sizeof(buf)); --- 986,992 ---- continue; if (nn->tok == MDOC_Sh || nn->tok == MDOC_Ss) comp = 1; ! if (roff_node_prev(nn) != NULL) break; } (void)strlcpy(buf, "Bd", sizeof(buf)); *************** *** 1096,1117 **** print_otag(h, TAG_VAR, "c", "Fa"); return 1; } ! ! for (nn = n->child; nn; nn = nn->next) { t = print_otag(h, TAG_VAR, "c", "Fa"); print_text(h, nn->string); print_tagq(h, t); ! if (nn->next) { h->flags |= HTML_NOSPACE; print_text(h, ","); } } ! ! if (n->child && n->next && n->next->tok == MDOC_Fa) { h->flags |= HTML_NOSPACE; print_text(h, ","); } - return 0; } --- 1098,1118 ---- print_otag(h, TAG_VAR, "c", "Fa"); return 1; } ! for (nn = n->child; nn != NULL; nn = nn->next) { t = print_otag(h, TAG_VAR, "c", "Fa"); print_text(h, nn->string); print_tagq(h, t); ! if (nn->next != NULL) { h->flags |= HTML_NOSPACE; print_text(h, ","); } } ! if (n->child != NULL && ! (nn = roff_node_next(n)) != NULL && ! nn->tok == MDOC_Fa) { h->flags |= HTML_NOSPACE; print_text(h, ","); } return 0; } *************** *** 1570,1576 **** static int mdoc_lb_pre(MDOC_ARGS) { ! if (SEC_LIBRARY == n->sec && NODE_LINE & n->flags && n->prev) print_otag(h, TAG_BR, ""); print_otag(h, TAG_SPAN, "c", "Lb"); --- 1571,1579 ---- static int mdoc_lb_pre(MDOC_ARGS) { ! if (n->sec == SEC_LIBRARY && ! n->flags & NODE_LINE && ! roff_node_prev(n) != NULL) print_otag(h, TAG_BR, ""); print_otag(h, TAG_SPAN, "c", "Lb"); *************** *** 1580,1596 **** static int mdoc__x_pre(MDOC_ARGS) { ! const char *cattr; ! enum htmltag t; t = TAG_SPAN; switch (n->tok) { case MDOC__A: cattr = "RsA"; ! if (n->prev && MDOC__A == n->prev->tok) ! if (NULL == n->next || MDOC__A != n->next->tok) ! print_text(h, "and"); break; case MDOC__B: t = TAG_I; --- 1583,1600 ---- static int mdoc__x_pre(MDOC_ARGS) { ! struct roff_node *nn; ! const char *cattr; ! enum htmltag t; t = TAG_SPAN; switch (n->tok) { case MDOC__A: cattr = "RsA"; ! if ((nn = roff_node_prev(n)) != NULL && nn->tok == MDOC__A && ! ((nn = roff_node_next(n)) == NULL || nn->tok != MDOC__A)) ! print_text(h, "and"); break; case MDOC__B: t = TAG_I; *************** *** 1645,1663 **** static void mdoc__x_post(MDOC_ARGS) { ! if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok) ! if (NULL == n->next->next || MDOC__A != n->next->next->tok) ! if (NULL == n->prev || MDOC__A != n->prev->tok) ! return; /* TODO: %U */ ! if (NULL == n->parent || MDOC_Rs != n->parent->tok) return; h->flags |= HTML_NOSPACE; ! print_text(h, n->next ? "," : "."); } static int --- 1649,1669 ---- static void mdoc__x_post(MDOC_ARGS) { + struct roff_node *nn; ! if (n->tok == MDOC__A && ! (nn = roff_node_next(n)) != NULL && nn->tok == MDOC__A && ! ((nn = roff_node_next(nn)) == NULL || nn->tok != MDOC__A) && ! ((nn = roff_node_prev(n)) == NULL || nn->tok != MDOC__A)) ! return; /* TODO: %U */ ! if (n->parent == NULL || n->parent->tok != MDOC_Rs) return; h->flags |= HTML_NOSPACE; ! print_text(h, roff_node_next(n) ? "," : "."); } static int