summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile15
-rw-r--r--html.c99
-rw-r--r--html.h9
-rw-r--r--man.36
-rw-r--r--mandoc.112
-rw-r--r--mdoc.36
-rw-r--r--mdoc_html.c111
7 files changed, 128 insertions, 130 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 45b40be8..02d77cbe 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.54 2009/10/03 15:26:26 kristaps Exp $ */
+/* $Id: html.c,v 1.55 2009/10/03 16:36:06 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 6d7faa35..17b39ae0 100644
--- a/html.h
+++ b/html.h
@@ -1,4 +1,4 @@
-/* $Id: html.h,v 1.9 2009/10/03 15:26:26 kristaps Exp $ */
+/* $Id: html.h,v 1.10 2009/10/03 16:36:06 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 da638d22..00ec8b28 100644
--- a/man.3
+++ b/man.3
@@ -1,4 +1,4 @@
-.\" $Id: man.3,v 1.9 2009/09/16 09:41:24 kristaps Exp $
+.\" $Id: man.3,v 1.10 2009/10/03 16:36:06 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: September 16 2009 $
+.Dd $Mdocdate: October 3 2009 $
.Dt MAN 3
.Os
.\" SECTION
@@ -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 c81018fc..cce6f834 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.40 2009/10/03 15:26:26 kristaps Exp $
+.\" $Id: mandoc.1,v 1.41 2009/10/03 16:36:06 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
.\"
@@ -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 1f68e5a7..5c6ac4ac 100644
--- a/mdoc.3
+++ b/mdoc.3
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.3,v 1.34 2009/09/16 09:41:24 kristaps Exp $
+.\" $Id: mdoc.3,v 1.35 2009/10/03 16:36:06 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: September 16 2009 $
+.Dd $Mdocdate: October 3 2009 $
.Dt MDOC 3
.Os
.\" SECTION
@@ -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 5fd7f919..2b8f0db4 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.17 2009/10/03 15:26:26 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.18 2009/10/03 16:36:06 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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);
}