=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.342 retrieving revision 1.344 diff -u -p -r1.342 -r1.344 --- mandoc/mdoc_html.c 2021/03/30 19:26:20 1.342 +++ mandoc/mdoc_html.c 2022/06/25 12:44:25 1.344 @@ -1,7 +1,8 @@ -/* $Id: mdoc_html.c,v 1.342 2021/03/30 19:26:20 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.344 2022/06/25 12:44:25 schwarze Exp $ */ /* - * Copyright (c) 2014-2021 Ingo Schwarze + * Copyright (c) 2014-2022 Ingo Schwarze * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons + * Copyright (c) 2022 Anna Vyalkova * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -515,7 +516,7 @@ static int mdoc_sh_pre(MDOC_ARGS) { struct roff_node *sn, *subn; - struct tag *t, *tsec, *tsub; + struct tag *t, *tnav, *tsec, *tsub; char *id; int sc; @@ -536,6 +537,7 @@ mdoc_sh_pre(MDOC_ARGS) break; if (sc < 2) break; + tnav = print_otag(h, TAG_NAV, "r", "doc-toc"); t = print_otag(h, TAG_H1, "c", "Sh"); print_text(h, "TABLE OF CONTENTS"); print_tagq(h, t); @@ -567,7 +569,7 @@ mdoc_sh_pre(MDOC_ARGS) } print_tagq(h, tsec); } - print_tagq(h, t); + print_tagq(h, tnav); print_otag(h, TAG_SECTION, "c", "Sh"); break; case ROFFT_HEAD: @@ -664,26 +666,34 @@ mdoc_nm_pre(MDOC_ARGS) static int mdoc_xr_pre(MDOC_ARGS) { - if (NULL == n->child) + char *name, *section, *label; + + if (n->child == NULL) return 0; + name = n->child->string; + if (n->child->next != NULL) { + section = n->child->next->string; + mandoc_asprintf(&label, "%s, section %s", name, section); + } else + section = label = NULL; + if (h->base_man1) - print_otag(h, TAG_A, "chM", "Xr", - n->child->string, n->child->next == NULL ? - NULL : n->child->next->string); + print_otag(h, TAG_A, "chM?", "Xr", + name, section, "aria-label", label); else - print_otag(h, TAG_A, "c", "Xr"); + print_otag(h, TAG_A, "c?", "Xr", "aria-label", label); - n = n->child; - print_text(h, n->string); + free(label); + print_text(h, name); - if (NULL == (n = n->next)) + if (section == NULL) return 0; h->flags |= HTML_NOSPACE; print_text(h, "("); h->flags |= HTML_NOSPACE; - print_text(h, n->string); + print_text(h, section); h->flags |= HTML_NOSPACE; print_text(h, ")"); return 0;