summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-01-29 14:39:37 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-01-29 14:39:37 +0000
commit69a80825be62eeca6a77c1f0a38955d29e30cd03 (patch)
treed6252bf20e26e0bef981cd35a23b6060535f3f1d
parent68432d6ea9e0e1a89eb79e9b1e957ffd93b49b72 (diff)
downloadmandoc-69a80825be62eeca6a77c1f0a38955d29e30cd03.tar.gz
mandoc-69a80825be62eeca6a77c1f0a38955d29e30cd03.tar.zst
mandoc-69a80825be62eeca6a77c1f0a38955d29e30cd03.zip
Fixed Makefile for `make lint' dep. on config.h
Added -Txhtml for XHTML output (minimal increase to programme logic). Because groff has it and it bothers me that we don't.
-rw-r--r--Makefile2
-rw-r--r--html.c97
-rw-r--r--html.h12
-rw-r--r--main.c11
-rw-r--r--main.h3
-rw-r--r--man_html.c4
-rw-r--r--mandoc.133
-rw-r--r--mdoc_html.c4
8 files changed, 135 insertions, 31 deletions
diff --git a/Makefile b/Makefile
index 4af9009c..18a60ddd 100644
--- a/Makefile
+++ b/Makefile
@@ -127,6 +127,8 @@ uninstall:
$(OBJS): config.h
+$(LNS): config.h
+
man_macro.ln: man_macro.c libman.h
man_macro.o: man_macro.c libman.h
diff --git a/html.c b/html.c
index eb5943b9..70641b72 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.92 2010/01/01 17:14:27 kristaps Exp $ */
+/* $Id: html.c,v 1.93 2010/01/29 14:39:37 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -36,38 +36,34 @@
#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
-#define DOCTYPE "-//W3C//DTD HTML 4.01//EN"
-#define DTD "http://www.w3.org/TR/html4/strict.dtd"
-
struct htmldata {
const char *name;
int flags;
#define HTML_CLRLINE (1 << 0)
#define HTML_NOSTACK (1 << 1)
+#define HTML_AUTOCLOSE (1 << 2) /* Tag has auto-closure. */
};
static const struct htmldata htmltags[TAG_MAX] = {
{"html", HTML_CLRLINE}, /* TAG_HTML */
{"head", HTML_CLRLINE}, /* TAG_HEAD */
{"body", HTML_CLRLINE}, /* TAG_BODY */
- {"meta", HTML_CLRLINE | HTML_NOSTACK}, /* TAG_META */
+ {"meta", HTML_CLRLINE | HTML_NOSTACK | HTML_AUTOCLOSE}, /* TAG_META */
{"title", HTML_CLRLINE}, /* TAG_TITLE */
{"div", HTML_CLRLINE}, /* TAG_DIV */
{"h1", 0}, /* TAG_H1 */
{"h2", 0}, /* TAG_H2 */
- {"p", HTML_CLRLINE}, /* TAG_P */
{"span", 0}, /* TAG_SPAN */
{"link", HTML_CLRLINE | HTML_NOSTACK}, /* TAG_LINK */
- {"br", HTML_CLRLINE | HTML_NOSTACK}, /* TAG_LINK */
+ {"br", HTML_CLRLINE | HTML_NOSTACK | HTML_AUTOCLOSE}, /* TAG_BR */
{"a", 0}, /* TAG_A */
{"table", HTML_CLRLINE}, /* TAG_TABLE */
- {"col", HTML_CLRLINE | HTML_NOSTACK}, /* TAG_COL */
+ {"col", HTML_CLRLINE | HTML_NOSTACK | HTML_AUTOCLOSE}, /* TAG_COL */
{"tr", HTML_CLRLINE}, /* TAG_TR */
{"td", HTML_CLRLINE}, /* TAG_TD */
{"li", HTML_CLRLINE}, /* TAG_LI */
{"ul", HTML_CLRLINE}, /* TAG_UL */
{"ol", HTML_CLRLINE}, /* TAG_OL */
- {"base", HTML_CLRLINE | HTML_NOSTACK}, /* TAG_BASE */
};
static const char *const htmlfonts[HTMLFONT_MAX] = {
@@ -96,12 +92,15 @@ static const char *const htmlattrs[ATTR_MAX] = {
static void print_spec(struct html *, const char *, size_t);
static void print_res(struct html *, const char *, size_t);
static void print_ctag(struct html *, enum htmltag);
+static void print_doctype(struct html *);
+static void print_xmltype(struct html *);
static int print_encode(struct html *, const char *, int);
static void print_metaf(struct html *, enum roffdeco);
+static void *ml_alloc(char *, enum htmltype);
-void *
-html_alloc(char *outopts)
+static void *
+ml_alloc(char *outopts, enum htmltype type)
{
struct html *h;
const char *toks[4];
@@ -118,6 +117,7 @@ html_alloc(char *outopts)
exit(EXIT_FAILURE);
}
+ h->type = type;
h->tags.head = NULL;
h->ords.head = NULL;
h->symtab = chars_init(CHARS_HTML);
@@ -140,6 +140,21 @@ html_alloc(char *outopts)
return(h);
}
+void *
+html_alloc(char *outopts)
+{
+
+ return(ml_alloc(outopts, HTML_HTML_4_01_STRICT));
+}
+
+
+void *
+xhtml_alloc(char *outopts)
+{
+
+ return(ml_alloc(outopts, HTML_XHTML_1_0_STRICT));
+}
+
void
html_free(void *p)
@@ -366,6 +381,16 @@ print_otag(struct html *h, enum htmltag tag,
(void)print_encode(h, p[i].val, 1);
putchar('\"');
}
+
+ if (HTML_AUTOCLOSE & htmltags[tag].flags)
+ switch (h->type) {
+ case (HTML_XHTML_1_0_STRICT):
+ putchar('/');
+ break;
+ default:
+ break;
+ }
+
putchar('>');
h->flags |= HTML_NOSPACE;
@@ -385,12 +410,54 @@ print_ctag(struct html *h, enum htmltag tag)
}
-/* ARGSUSED */
void
-print_gen_doctype(struct html *h)
+print_gen_decls(struct html *h)
{
-
- printf("<!DOCTYPE HTML PUBLIC \"%s\" \"%s\">", DOCTYPE, DTD);
+
+ print_xmltype(h);
+ print_doctype(h);
+}
+
+
+static void
+print_xmltype(struct html *h)
+{
+ const char *decl;
+
+ switch (h->type) {
+ case (HTML_XHTML_1_0_STRICT):
+ decl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+ break;
+ default:
+ decl = NULL;
+ break;
+ }
+
+ if (NULL == decl)
+ return;
+
+ printf("%s\n", decl);
+}
+
+
+static void
+print_doctype(struct html *h)
+{
+ const char *doctype;
+ const char *dtd;
+
+ switch (h->type) {
+ case (HTML_HTML_4_01_STRICT):
+ doctype = "-//W3C//DTD HTML 4.01//EN";
+ dtd = "http://www.w3.org/TR/html4/strict.dtd";
+ break;
+ default:
+ doctype = "-//W3C//DTD XHTML 1.0 Strict//EN";
+ dtd = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
+ break;
+ }
+
+ printf("<!DOCTYPE HTML PUBLIC \"%s\" \"%s\">\n", doctype, dtd);
}
diff --git a/html.h b/html.h
index ef0e0d10..92fbeaee 100644
--- a/html.h
+++ b/html.h
@@ -1,4 +1,4 @@
-/* $Id: html.h,v 1.21 2009/11/16 06:07:49 kristaps Exp $ */
+/* $Id: html.h,v 1.22 2010/01/29 14:39:38 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -28,7 +28,6 @@ enum htmltag {
TAG_DIV,
TAG_H1,
TAG_H2,
- TAG_P,
TAG_SPAN,
TAG_LINK,
TAG_BR,
@@ -40,7 +39,6 @@ enum htmltag {
TAG_LI,
TAG_UL,
TAG_OL,
- TAG_BASE,
TAG_MAX
};
@@ -105,6 +103,11 @@ struct htmlpair {
do { (p)->key = ATTR_SUMMARY; \
(p)->val = (v); } while (/* CONSTCOND */ 0)
+enum htmltype {
+ HTML_HTML_4_01_STRICT,
+ HTML_XHTML_1_0_STRICT
+};
+
struct html {
int flags;
#define HTML_NOSPACE (1 << 0)
@@ -121,11 +124,12 @@ struct html {
struct tag *metaf;
enum htmlfont metal;
enum htmlfont metac;
+ enum htmltype type;
};
struct roffsu;
-void print_gen_doctype(struct html *);
+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,
diff --git a/main.c b/main.c
index 0ab2aad9..4309818a 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.58 2010/01/01 17:14:27 kristaps Exp $ */
+/* $Id: main.c,v 1.59 2010/01/29 14:39:38 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -61,6 +61,7 @@ enum outt {
OUTT_ASCII = 0,
OUTT_TREE,
OUTT_HTML,
+ OUTT_XHTML,
OUTT_LINT
};
@@ -428,6 +429,12 @@ fdesc(struct buf *blk, struct buf *ln, struct curparse *curp)
if ( ! (curp->outman && curp->outmdoc)) {
switch (curp->outtype) {
+ case (OUTT_XHTML):
+ curp->outdata = xhtml_alloc(curp->outopts);
+ curp->outman = html_man;
+ curp->outmdoc = html_mdoc;
+ curp->outfree = html_free;
+ break;
case (OUTT_HTML):
curp->outdata = html_alloc(curp->outopts);
curp->outman = html_man;
@@ -550,6 +557,8 @@ toptions(enum outt *tflags, char *arg)
*tflags = OUTT_TREE;
else if (0 == strcmp(arg, "html"))
*tflags = OUTT_HTML;
+ else if (0 == strcmp(arg, "xhtml"))
+ *tflags = OUTT_XHTML;
else {
fprintf(stderr, "%s: Bad argument\n", arg);
return(0);
diff --git a/main.h b/main.h
index a8d995ad..1ff1b6d2 100644
--- a/main.h
+++ b/main.h
@@ -1,4 +1,4 @@
-/* $Id: main.h,v 1.1 2009/10/13 10:57:25 kristaps Exp $ */
+/* $Id: main.h,v 1.2 2010/01/29 14:39:38 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -30,6 +30,7 @@ struct man;
*/
void *html_alloc(char *);
+void *xhtml_alloc(char *);
void html_mdoc(void *, const struct mdoc *);
void html_man(void *, const struct man *);
void html_free(void *);
diff --git a/man_html.c b/man_html.c
index bebc0ac8..a9db1dfa 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.25 2010/01/01 17:14:28 kristaps Exp $ */
+/* $Id: man_html.c,v 1.26 2010/01/29 14:39:38 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -114,7 +114,7 @@ html_man(void *arg, const struct man *m)
h = (struct html *)arg;
- print_gen_doctype(h);
+ print_gen_decls(h);
t = print_otag(h, TAG_HTML, 0, NULL);
print_man(man_meta(m), man_node(m), h);
diff --git a/mandoc.1 b/mandoc.1
index 569ef39e..64152e8b 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.49 2010/01/07 19:10:09 kristaps Exp $
+.\" $Id: mandoc.1,v 1.50 2010/01/29 14:39:38 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: January 7 2010 $
+.Dd $Mdocdate: January 29 2010 $
.Dt MANDOC 1
.Os
.
@@ -167,6 +167,10 @@ styles. This is the default. See
Produce strict HTML-4.01 output, with a sane default style. See
.Sx HTML Output .
.
+.It Fl T Ns Ar xhtml
+Produce strict XHTML-1.0 output, with a sane default style. See
+.Sx XHTML Output .
+.
.It Fl T Ns Ar tree
Produce an indented parse tree.
.
@@ -333,7 +337,7 @@ exceed this limit.
.Ss HTML Output
Output produced by
.Fl T Ns Ar html
-comforms to HTML-4.01 strict.
+conforms to HTML-4.01 strict.
.Pp
Font styles and page structure are applied using CSS2. By default, no
font style is applied to any text, although CSS2 is hard-coded to format
@@ -348,6 +352,17 @@ cause rendered documents to appear as they do in
Special characters are rendered in decimal-encoded UTF-8.
.
.
+.Ss XHTML Output
+Output produced by
+.Fl T Ns Ar xhtml
+conforms to XHTML-1.0 strict.
+.Pp
+See
+.Sx HTML Output
+for details; beyond generating XHTML tags instead of HTML tags, these
+output modes are identical.
+.
+.
.Sh EXAMPLES
To page manuals to the terminal:
.
@@ -437,7 +452,7 @@ Sentences are unilaterally monospaced.
.El
.
.
-.Ss HTML Compatibility
+.Ss HTML/XHTML Compatibility
.Bl -bullet -compact
.It
The
@@ -483,13 +498,17 @@ utility was written by
.Sh CAVEATS
The
.Fl T Ns Ar html
+and
+.Fl T Ns Ar xhtml
CSS2 styling used for
.Fl m Ns Ar doc
input lists does not render properly in brain-dead browsers, such as
Internet Explorer 6 and earlier.
.Pp
In
-.Fl T Ns Ar html ,
+.Fl T Ns Ar html
+and
+.Fl T Ns Ar xhtml ,
the maximum size of an element attribute is determined by
.Dv BUFSIZ ,
which is usually 1024 bytes. Be aware of this when setting long link
@@ -498,7 +517,9 @@ formats, e.g.,
.Pp
The
.Fl T Ns Ar html
-output mode doesn't render the
+and
+.Fl T Ns Ar xhtml
+output modes don't render the
.Sq \es
font size escape documented in
.Xr mdoc 7
diff --git a/mdoc_html.c b/mdoc_html.c
index 88e9b2f5..3a8c9b80 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.52 2010/01/01 17:14:29 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.53 2010/01/29 14:39:38 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -266,7 +266,7 @@ html_mdoc(void *arg, const struct mdoc *m)
h = (struct html *)arg;
- print_gen_doctype(h);
+ print_gen_decls(h);
t = print_otag(h, TAG_HTML, 0, NULL);
print_mdoc(mdoc_meta(m), mdoc_node(m), h);
print_tagq(h, t);