-/* $Id: mdoc_html.c,v 1.275 2017/03/13 20:22:18 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.278 2017/03/17 12:10:16 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze <schwarze@openbsd.org>
};
static char *cond_id(const struct roff_node *);
-static char *make_id(const struct roff_node *);
static void print_mdoc_head(MDOC_ARGS);
static void print_mdoc_node(MDOC_ARGS);
static void print_mdoc_nodelist(MDOC_ARGS);
return 1;
}
-static char *
-make_id(const struct roff_node *n)
-{
- const struct roff_node *nch;
- char *buf, *cp;
-
- for (nch = n->child; nch != NULL; nch = nch->next)
- if (nch->type != ROFFT_TEXT)
- return NULL;
-
- buf = NULL;
- deroff(&buf, n);
-
- /* http://www.w3.org/TR/html5/dom.html#the-id-attribute */
-
- for (cp = buf; *cp != '\0'; cp++)
- if (*cp == ' ')
- *cp = '_';
-
- return buf;
-}
-
static char *
cond_id(const struct roff_node *n)
{
(n->parent->tok == MDOC_Xo &&
n->parent->parent->prev == NULL &&
n->parent->parent->parent->tok == MDOC_It)))
- return make_id(n);
+ return html_make_id(n);
return NULL;
}
switch (n->type) {
case ROFFT_HEAD:
- id = make_id(n);
+ id = html_make_id(n);
print_otag(h, TAG_H1, "cTi", "Sh", id);
- print_otag(h, TAG_A, "chR", "selflink", id);
+ if (id != NULL)
+ print_otag(h, TAG_A, "chR", "selflink", id);
free(id);
break;
case ROFFT_BODY:
if (n->type != ROFFT_HEAD)
return 1;
- id = make_id(n);
+ id = html_make_id(n);
print_otag(h, TAG_H2, "cTi", "Ss", id);
- print_otag(h, TAG_A, "chR", "selflink", id);
+ if (id != NULL)
+ print_otag(h, TAG_A, "chR", "selflink", id);
free(id);
return 1;
}
len = html_strlen(meta->name);
t = print_otag(h, TAG_COLGROUP, "");
- print_otag(h, TAG_COL, "shw", len);
+ /* Increase width to make even bold text fit. */
+ print_otag(h, TAG_COL, "shw", len + 2);
print_otag(h, TAG_COL, "");
print_tagq(h, t);
print_otag(h, TAG_TR, "");
{
char *id;
- id = make_id(n);
+ id = html_make_id(n);
print_otag(h, TAG_A, "cThR", "Sx", id);
free(id);
return 1;
(n->parent->tok == MDOC_It ||
(n->parent->tok == MDOC_Bq &&
n->parent->parent->parent->tok == MDOC_It)) ?
- make_id(n) : NULL;
+ html_make_id(n) : NULL;
if (id != NULL)
print_otag(h, TAG_A, "chR", "selflink", id);