summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-03-15 11:29:51 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-03-15 11:29:51 +0000
commit71e1df8f7d0e006b9be8d74be882d1814dceef6d (patch)
tree1a22cb868d664a392990c2114d5066b78ccfb1fb /usr.bin/mandoc/html.c
parentf880e5e8ae2fce1bd5e98f77665a7fbc87ac2932 (diff)
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 'usr.bin/mandoc/html.c')
-rw-r--r--usr.bin/mandoc/html.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c
index c645cb71d3a..323888d3520 100644
--- a/usr.bin/mandoc/html.c
+++ b/usr.bin/mandoc/html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.c,v 1.79 2017/03/14 01:34:57 schwarze Exp $ */
+/* $OpenBSD: html.c,v 1.80 2017/03/15 11:29:50 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -26,8 +26,9 @@
#include <string.h>
#include <unistd.h>
-#include "mandoc.h"
#include "mandoc_aux.h"
+#include "mandoc.h"
+#include "roff.h"
#include "out.h"
#include "html.h"
#include "manconf.h"
@@ -234,6 +235,28 @@ print_metaf(struct html *h, enum mandoc_esc deco)
}
}
+char *
+html_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;
+}
+
int
html_strlen(const char *cp)
{