summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile15
-rw-r--r--html.c97
-rw-r--r--html.h7
-rw-r--r--man.32
-rw-r--r--mandoc.110
-rw-r--r--mdoc.32
-rw-r--r--mdoc_html.c109
7 files changed, 120 insertions, 122 deletions
diff --git a/Makefile b/Makefile
index d8185484..33bff355 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,9 @@ CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -g
CFLAGS += $(VFLAGS)
LINTFLAGS += $(VFLAGS)
+MANDOCFLAGS = -Wall -fstrict
+MANDOCHTML = -Thtml -ostyle=style.css,man=%N.%S.html,includes=%I.html
+
MDOCLNS = mdoc_macro.ln mdoc.ln mdoc_hash.ln mdoc_strings.ln \
mdoc_argv.ln mdoc_validate.ln mdoc_action.ln \
lib.ln att.ln arch.ln vol.ln msec.ln st.ln \
@@ -229,22 +232,22 @@ mandoc: $(MAINOBJS) libmdoc.a libman.a
sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< > $@
.1.1.txt:
- ./mandoc -Wall,error -fstrict $< | col -b > $@
+ ./mandoc $(MANDOCFLAGS) $< | col -b > $@
.1.1.sgml:
- ./mandoc -Thtml -ostyle=style.css -Wall,error -fstrict $< > $@
+ ./mandoc $(MANDOCFLAGS) $(MANDOCHTML) $< > $@
.3.3.txt:
- ./mandoc -Wall,error -fstrict $< | col -b > $@
+ ./mandoc $(MANDOCFLAGS) $< | col -b > $@
.3.3.sgml:
- ./mandoc -Thtml -ostyle=style.css -Wall,error -fstrict $< > $@
+ ./mandoc $(MANDOCFLAGS) $(MANDOCHTML) $< > $@
.7.7.txt:
- ./mandoc -Wall,error -fstrict $< | col -b > $@
+ ./mandoc $(MANDOCFLAGS) $< | col -b > $@
.7.7.sgml:
- ./mandoc -Thtml -ostyle=style.css -Wall,error -fstrict $< > $@
+ ./mandoc $(MANDOCFLAGS) $(MANDOCHTML) $< > $@
.tar.gz.md5:
md5 $< > $@
diff --git a/html.c b/html.c
index e46d0a47..431a8f11 100644
--- a/html.c
+++ b/html.c
@@ -20,6 +20,7 @@
#include <assert.h>
#include <err.h>
#include <stdio.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -142,8 +143,6 @@ html_free(void *p)
free(tag);
}
- if (h->buf)
- free(h->buf);
if (h->symtab)
chars_free(h->symtab);
@@ -487,3 +486,97 @@ print_stagq(struct html *h, const struct tag *suntil)
free(tag);
}
}
+
+
+void
+bufinit(struct html *h)
+{
+
+ h->buf[0] = '\0';
+ h->buflen = 0;
+}
+
+
+void
+bufcat(struct html *h, const char *p)
+{
+
+ bufncat(h, p, strlen(p));
+}
+
+
+void
+buffmt(struct html *h, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ (void)vsnprintf(h->buf + h->buflen,
+ BUFSIZ - h->buflen - 1, fmt, ap);
+ va_end(ap);
+ h->buflen = strlen(h->buf);
+ assert('\0' == h->buf[h->buflen]);
+}
+
+
+void
+bufncat(struct html *h, const char *p, size_t sz)
+{
+
+ if (h->buflen + sz > BUFSIZ - 1)
+ sz = BUFSIZ - 1 - h->buflen;
+
+ (void)strncat(h->buf, p, sz);
+ h->buflen += sz;
+ assert('\0' == h->buf[h->buflen]);
+}
+
+
+void
+buffmt_includes(struct html *h, const char *name)
+{
+ const char *p, *pp;
+
+ pp = h->base_includes;
+ while ((p = strchr(pp, '%'))) {
+ bufncat(h, pp, p - pp);
+ switch (*(p + 1)) {
+ case('I'):
+ bufcat(h, name);
+ break;
+ default:
+ bufncat(h, p, 2);
+ break;
+ }
+ pp = p + 2;
+ }
+ if (pp)
+ bufcat(h, pp);
+}
+
+
+void
+buffmt_man(struct html *h,
+ const char *name, const char *sec)
+{
+ const char *p, *pp;
+
+ pp = h->base_man;
+ while ((p = strchr(pp, '%'))) {
+ bufncat(h, pp, p - pp);
+ switch (*(p + 1)) {
+ case('S'):
+ bufcat(h, sec);
+ break;
+ case('N'):
+ buffmt(h, name ? name : "1");
+ break;
+ default:
+ bufncat(h, p, 2);
+ break;
+ }
+ pp = p + 2;
+ }
+ if (pp)
+ bufcat(h, pp);
+}
diff --git a/html.h b/html.h
index 11657a77..4ec8c3cf 100644
--- a/html.h
+++ b/html.h
@@ -103,6 +103,13 @@ void print_tagq(struct html *, const struct tag *);
void print_stagq(struct html *, const struct tag *);
void print_text(struct html *, const char *);
+void buffmt_man(struct html *, const char *, const char *);
+void buffmt_includes(struct html *, const char *);
+void buffmt(struct html *, const char *, ...);
+void bufcat(struct html *, const char *);
+void bufncat(struct html *, const char *, size_t);
+void bufinit(struct html *);
+
__END_DECLS
#endif /*!HTML_H*/
diff --git a/man.3 b/man.3
index 2e8c5682..e1be1aea 100644
--- a/man.3
+++ b/man.3
@@ -29,7 +29,7 @@
.Nd man macro compiler library
.\" SECTION
.Sh SYNOPSIS
-.Fd #include "man.h"
+.In man.h
.Vt extern const char * const * man_macronames;
.Ft "struct man *"
.Fn man_alloc "void *data" "int pflags" "const struct man_cb *cb"
diff --git a/mandoc.1 b/mandoc.1
index 894952d3..66f5f371 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -54,7 +54,7 @@ Input format. See
for available formats. Defaults to
.Fl m Ns Ar andoc .
.
-.It Fl o Ns Ar format
+.It Fl o Ns Ar option...
Comma-separated output options. See
.Sx Output Options
for details.
@@ -295,11 +295,11 @@ To page manuals to the terminal:
.D1 % mandoc mandoc.1 mdoc.3 mdoc.7 | less
.
.Pp
-To produce HTML manuals with
-.Pa http://localhost/
-as the base URI:
+To produce HTML manuals with
+.Ar style.css
+as the style-sheet:
.Pp
-.D1 % mandoc \-Thtml -obase=http://localhost/ mdoc.7 > mdoc.7.html
+.D1 % mandoc \-Thtml -ostyle=style.css mdoc.7 > mdoc.7.html
.Pp
To check over a large set of manuals:
.
diff --git a/mdoc.3 b/mdoc.3
index 47bc40a1..5d715225 100644
--- a/mdoc.3
+++ b/mdoc.3
@@ -29,7 +29,7 @@
.Nd mdoc macro compiler library
.\" SECTION
.Sh SYNOPSIS
-.Fd #include "mdoc.h"
+.In mdoc.h
.Vt extern const char * const * mdoc_macronames;
.Vt extern const char * const * mdoc_argnames;
.Ft "struct mdoc *"
diff --git a/mdoc_html.c b/mdoc_html.c
index 5db4658e..3a8911dc 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -21,7 +21,6 @@
#include <assert.h>
#include <ctype.h>
#include <err.h>
-#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -54,14 +53,6 @@ static int a2width(const char *);
static int a2offs(const char *);
static int a2list(const struct mdoc_node *);
-static void buffmt_man(struct html *,
- const char *, const char *);
-static void buffmt_includes(struct html *, const char *);
-static void buffmt(struct html *, const char *, ...);
-static void bufcat(struct html *, const char *);
-static void bufncat(struct html *, const char *, size_t);
-
-
static void mdoc_root_post(MDOC_ARGS);
static int mdoc_root_pre(MDOC_ARGS);
static int mdoc_tbl_pre(MDOC_ARGS, int);
@@ -282,100 +273,6 @@ html_mdoc(void *arg, const struct mdoc *m)
}
-static void
-bufinit(struct html *h)
-{
-
- h->buf[0] = '\0';
- h->buflen = 0;
-}
-
-
-static void
-bufcat(struct html *h, const char *p)
-{
-
- bufncat(h, p, strlen(p));
-}
-
-
-static void
-buffmt(struct html *h, const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- (void)vsnprintf(h->buf + h->buflen,
- BUFSIZ - h->buflen - 1, fmt, ap);
- va_end(ap);
- h->buflen = strlen(h->buf);
- assert('\0' == h->buf[h->buflen]);
-}
-
-
-static void
-bufncat(struct html *h, const char *p, size_t sz)
-{
-
- if (h->buflen + sz > BUFSIZ - 1)
- sz = BUFSIZ - 1 - h->buflen;
-
- (void)strncat(h->buf, p, sz);
- h->buflen += sz;
- assert('\0' == h->buf[h->buflen]);
-}
-
-
-static void
-buffmt_includes(struct html *h, const char *name)
-{
- const char *p, *pp;
-
- pp = h->base_includes;
- while ((p = strchr(pp, '%'))) {
- bufncat(h, pp, p - pp);
- switch (*(p + 1)) {
- case('I'):
- bufcat(h, name);
- break;
- default:
- bufncat(h, p, 2);
- break;
- }
- pp = p + 2;
- }
- if (pp)
- bufcat(h, pp);
-}
-
-
-static void
-buffmt_man(struct html *h,
- const char *name, const char *sec)
-{
- const char *p, *pp;
-
- pp = h->base_man;
- while ((p = strchr(pp, '%'))) {
- bufncat(h, pp, p - pp);
- switch (*(p + 1)) {
- case('S'):
- bufcat(h, sec);
- break;
- case('N'):
- buffmt(h, name ? name : "1");
- break;
- default:
- bufncat(h, p, 2);
- break;
- }
- pp = p + 2;
- }
- if (pp)
- bufcat(h, pp);
-}
-
-
static int
a2list(const struct mdoc_node *n)
{
@@ -1375,7 +1272,7 @@ mdoc_d1_pre(MDOC_ARGS)
static int
mdoc_sx_pre(MDOC_ARGS)
{
- struct htmlpair tag[3];
+ struct htmlpair tag[2];
const struct mdoc_node *nn;
bufcat(h, "#");
@@ -1389,10 +1286,8 @@ mdoc_sx_pre(MDOC_ARGS)
tag[0].val = h->buf;
tag[1].key = ATTR_CLASS;
tag[1].val = "link-sec";
- tag[2].key = ATTR_TARGET;
- tag[2].val = "_self";
- print_otag(h, TAG_A, 3, tag);
+ print_otag(h, TAG_A, 2, tag);
return(1);
}