summaryrefslogtreecommitdiffstats
path: root/mdoc_html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-03-15 11:29:53 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-03-15 11:29:53 +0000
commit28bf3097cb23e1f811b5273cd04e16d309f04607 (patch)
tree38ecfdeb14b8bad014fc814155f7a1dd2f311e86 /mdoc_html.c
parent7f62257df910dabf75acbc931ba339de0abde743 (diff)
downloadmandoc-28bf3097cb23e1f811b5273cd04e16d309f04607.tar.gz
Minimal support for deep linking into man(7) pages.
As the man(7) language does not provide semantic markup, only .SH, .SS, and .UR become anchors for now.
Diffstat (limited to 'mdoc_html.c')
-rw-r--r--mdoc_html.c33
1 files changed, 5 insertions, 28 deletions
diff --git a/mdoc_html.c b/mdoc_html.c
index 3a0b774b..eda5ce41 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -49,7 +49,6 @@ struct htmlmdoc {
};
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);
@@ -478,28 +477,6 @@ mdoc_root_pre(MDOC_ARGS)
}
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)
{
if (n->child != NULL &&
@@ -511,7 +488,7 @@ 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;
}
@@ -522,7 +499,7 @@ mdoc_sh_pre(MDOC_ARGS)
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);
free(id);
@@ -545,7 +522,7 @@ mdoc_ss_pre(MDOC_ARGS)
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);
free(id);
@@ -955,7 +932,7 @@ mdoc_sx_pre(MDOC_ARGS)
{
char *id;
- id = make_id(n);
+ id = html_make_id(n);
print_otag(h, TAG_A, "cThR", "Sx", id);
free(id);
return 1;
@@ -1128,7 +1105,7 @@ mdoc_er_pre(MDOC_ARGS)
(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);