diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-03-15 11:29:53 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-03-15 11:29:53 +0000 |
commit | 4765dc18ce4546a42d3aa2ce149a3c3fb4d79b00 (patch) | |
tree | 29466681c88eea5ed0346c222603343534c49d77 /html.c | |
parent | 7820a26ea52032d0330456ae02d4044b357144de (diff) | |
download | mandoc-4765dc18ce4546a42d3aa2ce149a3c3fb4d79b00.tar.gz mandoc-4765dc18ce4546a42d3aa2ce149a3c3fb4d79b00.tar.zst mandoc-4765dc18ce4546a42d3aa2ce149a3c3fb4d79b00.zip |
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 'html.c')
-rw-r--r-- | html.c | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.209 2017/03/14 01:35:15 schwarze Exp $ */ +/* $Id: html.c,v 1.210 2017/03/15 11:29:53 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011-2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -28,8 +28,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" @@ -236,6 +237,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) { |