summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2010-12-25 13:23:03 +0000
committerschwarze <schwarze@openbsd.org>2010-12-25 13:23:03 +0000
commit3a7b861cec42f7ba93252a1226552d5f42f8ae24 (patch)
treeba6c75a785ec8fff089ca58a7743e7cc88c2480e
parentntfs memory names were too long and make vmstat -m look ugly (diff)
downloadwireguard-openbsd-3a7b861cec42f7ba93252a1226552d5f42f8ae24.tar.xz
wireguard-openbsd-3a7b861cec42f7ba93252a1226552d5f42f8ae24.zip
Yet another batch of -Thtml polishing from kristaps@:
In particular, use <SMALL> for .SM and <CODE> for .Dl. Use <B> for bold and <I> for italic in general. Also call this mandoc 1.10.8 now, as it is functionally equivalent, even though one one set of refactoring patches has not been merged yet because it conflicts with our tbl(1) handling.
-rw-r--r--usr.bin/mandoc/Makefile4
-rw-r--r--usr.bin/mandoc/html.c56
-rw-r--r--usr.bin/mandoc/html.h12
-rw-r--r--usr.bin/mandoc/man_html.c53
-rw-r--r--usr.bin/mandoc/mdoc_html.c23
5 files changed, 71 insertions, 77 deletions
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile
index d94e5bbf594..4c469a34fe5 100644
--- a/usr.bin/mandoc/Makefile
+++ b/usr.bin/mandoc/Makefile
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile,v 1.49 2010/12/07 00:08:52 schwarze Exp $
+# $OpenBSD: Makefile,v 1.50 2010/12/25 13:23:03 schwarze Exp $
.include <bsd.own.mk>
-VERSION=1.10.7
+VERSION=1.10.8
CFLAGS+=-DVERSION=\"${VERSION}\"
CFLAGS+=-W -Wall -Wstrict-prototypes
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c
index f5966003f3d..2aa4f4bb107 100644
--- a/usr.bin/mandoc/html.c
+++ b/usr.bin/mandoc/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.19 2010/12/22 00:33:25 schwarze Exp $ */
+/* $Id: html.c,v 1.20 2010/12/25 13:23:03 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -68,13 +68,8 @@ static const struct htmldata htmltags[TAG_MAX] = {
{"pre", HTML_CLRLINE }, /* TAG_PRE */
{"b", 0 }, /* TAG_B */
{"i", 0 }, /* TAG_I */
- {"u", 0 }, /* TAG_U */
-};
-
-static const char *const htmlfonts[HTMLFONT_MAX] = {
- "roman",
- "bold",
- "italic"
+ {"code", 0 }, /* TAG_CODE */
+ {"small", 0 }, /* TAG_SMALL */
};
static const char *const htmlattrs[ATTR_MAX] = {
@@ -252,25 +247,6 @@ print_res(struct html *h, const char *p, size_t len)
}
-struct tag *
-print_ofont(struct html *h, enum htmlfont font)
-{
- struct htmlpair tag;
-
- h->metal = h->metac;
- h->metac = font;
-
- /* FIXME: DECO_ROMAN should just close out preexisting. */
-
- if (h->metaf && h->tags.head == h->metaf)
- print_tagq(h, h->metaf);
-
- PAIR_CLASS_INIT(&tag, htmlfonts[font]);
- h->metaf = print_otag(h, TAG_SPAN, 1, &tag);
- return(h->metaf);
-}
-
-
static void
print_metaf(struct html *h, enum roffdeco deco)
{
@@ -294,7 +270,18 @@ print_metaf(struct html *h, enum roffdeco deco)
/* NOTREACHED */
}
- (void)print_ofont(h, font);
+ if (h->metaf) {
+ print_tagq(h, h->metaf);
+ h->metaf = NULL;
+ }
+
+ h->metal = h->metac;
+ h->metac = font;
+
+ if (HTMLFONT_NONE != font)
+ h->metaf = HTMLFONT_BOLD == font ?
+ print_otag(h, TAG_B, 0, NULL) :
+ print_otag(h, TAG_I, 0, NULL);
}
@@ -482,7 +469,7 @@ print_xmltype(struct html *h)
{
if (HTML_XHTML_1_0_STRICT == h->type)
- printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ puts("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
}
@@ -549,11 +536,22 @@ print_text(struct html *h, const char *word)
printf("&#160;");
}
+ assert(NULL == h->metaf);
+ if (HTMLFONT_NONE != h->metac)
+ h->metaf = HTMLFONT_BOLD == h->metac ?
+ print_otag(h, TAG_B, 0, NULL) :
+ print_otag(h, TAG_I, 0, NULL);
+
assert(word);
if ( ! print_encode(h, word, 0))
if ( ! (h->flags & HTML_NONOSPACE))
h->flags &= ~HTML_NOSPACE;
+ if (h->metaf) {
+ print_tagq(h, h->metaf);
+ h->metaf = NULL;
+ }
+
h->flags &= ~HTML_IGNDELIM;
/*
diff --git a/usr.bin/mandoc/html.h b/usr.bin/mandoc/html.h
index d6d3c9453d6..61c66b7865e 100644
--- a/usr.bin/mandoc/html.h
+++ b/usr.bin/mandoc/html.h
@@ -1,4 +1,4 @@
-/* $Id: html.h,v 1.10 2010/12/22 00:33:25 schwarze Exp $ */
+/* $Id: html.h,v 1.11 2010/12/25 13:23:03 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -48,7 +48,8 @@ enum htmltag {
TAG_PRE,
TAG_B,
TAG_I,
- TAG_U,
+ TAG_CODE,
+ TAG_SMALL,
TAG_MAX
};
@@ -122,9 +123,9 @@ struct html {
char *style;
char buf[BUFSIZ];
size_t buflen;
- struct tag *metaf;
- enum htmlfont metal;
- enum htmlfont metac;
+ struct tag *metaf; /* current open font scope */
+ enum htmlfont metal; /* last used font */
+ enum htmlfont metac; /* current font mode */
enum htmltype type;
};
@@ -132,7 +133,6 @@ struct roffsu;
void print_gen_decls(struct html *);
void print_gen_head(struct html *);
-struct tag *print_ofont(struct html *, enum htmlfont);
struct tag *print_otag(struct html *, enum htmltag,
int, const struct htmlpair *);
void print_tagq(struct html *, const struct tag *);
diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c
index e0a61c1e9bd..345217649e2 100644
--- a/usr.bin/mandoc/man_html.c
+++ b/usr.bin/mandoc/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.26 2010/12/22 22:35:05 schwarze Exp $ */
+/* $Id: man_html.c,v 1.27 2010/12/25 13:23:03 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -207,11 +207,9 @@ print_man_node(MAN_ARGS)
* scope. Assert that the metafont is on the top of the
* stack (it's never nested).
*/
- if (h->metaf) {
- assert(h->metaf == t);
- print_tagq(h, h->metaf);
- assert(NULL == h->metaf);
- t = h->tags.head;
+ if (HTMLFONT_NONE != h->metac) {
+ h->metal = h->metac;
+ h->metac = HTMLFONT_NONE;
}
if (mans[n->tok].pre)
child = (*mans[n->tok].pre)(m, n, mh, h);
@@ -407,29 +405,30 @@ static int
man_alt_pre(MAN_ARGS)
{
const struct man_node *nn;
- struct tag *t;
- int i;
- enum htmlfont fp;
+ int i;
+ enum htmltag fp;
+ struct tag *t;
for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
+ t = NULL;
switch (n->tok) {
case (MAN_BI):
- fp = i % 2 ? HTMLFONT_ITALIC : HTMLFONT_BOLD;
+ fp = i % 2 ? TAG_I : TAG_B;
break;
case (MAN_IB):
- fp = i % 2 ? HTMLFONT_BOLD : HTMLFONT_ITALIC;
+ fp = i % 2 ? TAG_B : TAG_I;
break;
case (MAN_RI):
- fp = i % 2 ? HTMLFONT_ITALIC : HTMLFONT_NONE;
+ fp = i % 2 ? TAG_I : TAG_MAX;
break;
case (MAN_IR):
- fp = i % 2 ? HTMLFONT_NONE : HTMLFONT_ITALIC;
+ fp = i % 2 ? TAG_MAX : TAG_I;
break;
case (MAN_BR):
- fp = i % 2 ? HTMLFONT_NONE : HTMLFONT_BOLD;
+ fp = i % 2 ? TAG_MAX : TAG_B;
break;
case (MAN_RB):
- fp = i % 2 ? HTMLFONT_BOLD : HTMLFONT_NONE;
+ fp = i % 2 ? TAG_B : TAG_MAX;
break;
default:
abort();
@@ -439,14 +438,13 @@ man_alt_pre(MAN_ARGS)
if (i)
h->flags |= HTML_NOSPACE;
- /*
- * Open and close the scope with each argument, so that
- * internal \f escapes, which are common, are also
- * closed out with the scope.
- */
- t = print_ofont(h, fp);
+ if (TAG_MAX != fp)
+ t = print_otag(h, fp, 0, NULL);
+
print_man_node(m, nn, mh, h);
- print_tagq(h, t);
+
+ if (t)
+ print_tagq(h, t);
}
return(0);
@@ -457,13 +455,10 @@ man_alt_pre(MAN_ARGS)
static int
man_SM_pre(MAN_ARGS)
{
- struct htmlpair tag;
- /* FIXME: print_ofont(). */
- PAIR_CLASS_INIT(&tag, "small");
- print_otag(h, TAG_SPAN, 1, &tag);
+ print_otag(h, TAG_SMALL, 0, NULL);
if (MAN_SB == n->tok)
- print_ofont(h, HTMLFONT_BOLD);
+ print_otag(h, TAG_B, 0, NULL);
return(1);
}
@@ -628,7 +623,7 @@ static int
man_B_pre(MAN_ARGS)
{
- print_ofont(h, HTMLFONT_BOLD);
+ print_otag(h, TAG_B, 0, NULL);
return(1);
}
@@ -638,7 +633,7 @@ static int
man_I_pre(MAN_ARGS)
{
- print_ofont(h, HTMLFONT_ITALIC);
+ print_otag(h, TAG_I, 0, NULL);
return(1);
}
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index 3400eb55da1..f2df8d2f028 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.42 2010/12/22 00:33:25 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.43 2010/12/25 13:23:03 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -468,8 +468,8 @@ mdoc_root_post(MDOC_ARGS)
PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
PAIR_CLASS_INIT(&tag[1], "foot");
if (NULL == h->style) {
- PAIR_INIT(&tag[1], ATTR_WIDTH, "100%");
- t = print_otag(h, TAG_TABLE, 2, tag);
+ PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
+ t = print_otag(h, TAG_TABLE, 3, tag);
PAIR_INIT(&tag[0], ATTR_WIDTH, "50%");
print_otag(h, TAG_COL, 1, tag);
print_otag(h, TAG_COL, 1, tag);
@@ -1094,12 +1094,14 @@ mdoc_d1_pre(MDOC_ARGS)
/* BLOCKQUOTE needs a block body. */
- if (MDOC_Dl == n->tok)
- PAIR_CLASS_INIT(&tag[0], "lit display");
- else
- PAIR_CLASS_INIT(&tag[0], "display");
-
+ PAIR_CLASS_INIT(&tag[0], "display");
print_otag(h, TAG_DIV, 1, tag);
+
+ if (MDOC_Dl == n->tok) {
+ PAIR_CLASS_INIT(&tag[0], "lit");
+ print_otag(h, TAG_CODE, 1, tag);
+ }
+
return(1);
}
@@ -1593,7 +1595,7 @@ mdoc_fo_pre(MDOC_ARGS)
assert(n->child->string);
PAIR_CLASS_INIT(&tag, "fname");
- t = print_otag(h, TAG_SPAN, 1, &tag);
+ t = print_otag(h, TAG_B, 1, &tag);
print_text(h, n->child->string);
print_tagq(h, t);
return(0);
@@ -1680,7 +1682,7 @@ mdoc_rv_pre(MDOC_ARGS)
for (nn = n->child; nn; nn = nn->next) {
PAIR_CLASS_INIT(&tag, "fname");
- t = print_otag(h, TAG_SPAN, 1, &tag);
+ t = print_otag(h, TAG_B, 1, &tag);
print_text(h, nn->string);
print_tagq(h, t);
@@ -1931,7 +1933,6 @@ mdoc__x_pre(MDOC_ARGS)
break;
case(MDOC__T):
PAIR_CLASS_INIT(&tag[0], "ref-title");
- t = TAG_U;
break;
case(MDOC__U):
PAIR_CLASS_INIT(&tag[0], "link-ref");