The html output contains nested anchor tags if the TABLE OF CONTENTS
has a second level.
For example, see http://man.openbsd.org/mdoc

The diff closes the anchor tag before printing the 'ul' of the second level.


Index: mdoc_html.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mdoc_html.c,v
retrieving revision 1.193
diff -u -p -u -p -r1.193 mdoc_html.c
--- mdoc_html.c 15 Dec 2018 23:33:20 -0000      1.193
+++ mdoc_html.c 22 Dec 2018 14:26:09 -0000
@@ -507,7 +507,7 @@ static int
 mdoc_sh_pre(MDOC_ARGS)
 {
        struct roff_node        *sn, *subn;
-       struct tag              *t, *tsec, *tsub;
+       struct tag              *t, *ta, *tsec, *tsub;
        char                    *id;
        int                      sc;

@@ -532,7 +532,7 @@ mdoc_sh_pre(MDOC_ARGS)
                for (sn = n; sn != NULL; sn = sn->next) {
                        tsec = print_otag(h, TAG_LI, "");
                        id = html_make_id(sn->head, 0);
-                       print_otag(h, TAG_A, "hR", id);
+                       ta = print_otag(h, TAG_A, "hR", id);
                        free(id);
                        print_mdoc_nodelist(meta, sn->head->child, h);
                        tsub = NULL;
@@ -543,9 +543,11 @@ mdoc_sh_pre(MDOC_ARGS)
                                id = html_make_id(subn->head, 0);
                                if (id == NULL)
                                        continue;
-                               if (tsub == NULL)
+                               if (tsub == NULL) {
+                                       print_tagq(h, ta);
                                        print_otag(h, TAG_UL,
                                            "c", "Bl-compact");
+                               }
                                tsub = print_otag(h, TAG_LI, "");
                                print_otag(h, TAG_A, "hR", id);
                                free(id);


Reply via email to