discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
* HTML5
@ 2014-08-09 23:33 Kristaps Dzonsons
  2014-08-10  2:23 ` HTML5 Ingo Schwarze
  2014-08-10  4:33 ` HTML5 Anthony J. Bentley
  0 siblings, 2 replies; 7+ messages in thread
From: Kristaps Dzonsons @ 2014-08-09 23:33 UTC (permalink / raw)
  To: discuss

[-- Attachment #1: Type: text/plain, Size: 968 bytes --]

Hi,

Most everybody supports HTML5 these days.  Do we really need to knock 
around with XHTML and HTML-4.01?  Does anybody have a pressing need to 
use one or the other?

The enclosed ten-minute patch adds HTML5 support and makes it the 
default for both modes.  It also adds a default CSS style (if one isn't 
passed on the command line) identical to OpenBSD's man.cgi CSS.  I don't 
like this--I think online manpages should take more advantage of 
online-ness--but I'm just putting up the bikeshed so it's ready to 
paint.  This patch also rips out some chunks (embedded widths, etc.) 
that didn't HTML5 validate, so be warned...

If it looks useful, we could rip out a decent chunk of code that 
switches between the two existing modes.  (Including some attributes and 
elements in there.)  (Yes, I'd document it better, if useful, and 
probably tidy up the *html.c files as well.)

(Note this doesn't include the earlier patch for SCALE_BU.)

Thoughts?

Kristaps

[-- Attachment #2: html5.diff --]
[-- Type: text/plain, Size: 10557 bytes --]

Index: html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/html.c,v
retrieving revision 1.159
diff -u -p -r1.159 html.c
--- html.c	23 Jul 2014 15:00:08 -0000	1.159
+++ html.c	9 Aug 2014 23:31:38 -0000
@@ -70,12 +70,13 @@ static	const struct htmldata htmltags[TA
 	{"dt",		HTML_CLRLINE}, /* TAG_DT */
 	{"dd",		HTML_CLRLINE}, /* TAG_DD */
 	{"blockquote",	HTML_CLRLINE}, /* TAG_BLOCKQUOTE */
-	{"p",		HTML_CLRLINE | HTML_NOSTACK | HTML_AUTOCLOSE}, /* TAG_P */
+	{"p",		HTML_CLRLINE | HTML_NOSTACK }, /* TAG_P */
 	{"pre",		HTML_CLRLINE }, /* TAG_PRE */
 	{"b",		0 }, /* TAG_B */
 	{"i",		0 }, /* TAG_I */
 	{"code",	0 }, /* TAG_CODE */
 	{"small",	0 }, /* TAG_SMALL */
+	{"style",	HTML_CLRLINE }, /* TAG_STYLE */
 };
 
 static	const char	*const htmlattrs[ATTR_MAX] = {
@@ -93,6 +94,7 @@ static	const char	*const htmlattrs[ATTR_
 	"summary", /* ATTR_SUMMARY */
 	"align", /* ATTR_ALIGN */
 	"colspan", /* ATTR_COLSPAN */
+	"charset", /* ATTR_CHARSET */
 };
 
 static	const char	*const roffscales[SCALE_MAX] = {
@@ -161,14 +163,14 @@ void *
 html_alloc(char *outopts)
 {
 
-	return(ml_alloc(outopts, HTML_HTML_4_01_STRICT));
+	return(ml_alloc(outopts, HTML_HTML5));
 }
 
 void *
 xhtml_alloc(char *outopts)
 {
 
-	return(ml_alloc(outopts, HTML_XHTML_1_0_STRICT));
+	return(ml_alloc(outopts, HTML_HTML5));
 }
 
 void
@@ -194,20 +196,26 @@ void
 print_gen_head(struct html *h)
 {
 	struct htmlpair	 tag[4];
+	struct tag	*t;
 
-	tag[0].key = ATTR_HTTPEQUIV;
-	tag[0].val = "Content-Type";
-	tag[1].key = ATTR_CONTENT;
-	tag[1].val = "text/html; charset=utf-8";
-	print_otag(h, TAG_META, 2, tag);
-
-	tag[0].key = ATTR_NAME;
-	tag[0].val = "resource-type";
-	tag[1].key = ATTR_CONTENT;
-	tag[1].val = "document";
-	print_otag(h, TAG_META, 2, tag);
+	if (HTML_HTML5 == h->type) {
+		tag[0].key = ATTR_CHARSET;
+		tag[0].val = "utf-8";
+		print_otag(h, TAG_META, 1, tag);
+	} else {
+		tag[0].key = ATTR_HTTPEQUIV;
+		tag[0].val = "Content-Type";
+		tag[1].key = ATTR_CONTENT;
+		tag[1].val = "text/html; charset=utf-8";
+		print_otag(h, TAG_META, 2, tag);
+		tag[0].key = ATTR_NAME;
+		tag[0].val = "resource-type";
+		tag[1].key = ATTR_CONTENT;
+		tag[1].val = "document";
+		print_otag(h, TAG_META, 2, tag);
+	}
 
-	if (h->style) {
+	if (NULL != h->style) {
 		tag[0].key = ATTR_REL;
 		tag[0].val = "stylesheet";
 		tag[1].key = ATTR_HREF;
@@ -217,7 +225,66 @@ print_gen_head(struct html *h)
 		tag[3].key = ATTR_MEDIA;
 		tag[3].val = "all";
 		print_otag(h, TAG_LINK, 4, tag);
+		return;
 	}
+
+	/*
+	 * If we don't have a stylesheet, print some nice defaults here.
+	 * This looks like a terminal.
+	 */
+	if (HTML_HTML5 != h->type) {
+		PAIR_INIT(&tag[0], ATTR_TYPE, "text/css");
+		t = print_otag(h, TAG_STYLE, 1, tag);
+	} else 
+		t = print_otag(h, TAG_STYLE, 0, NULL);
+
+	print_text(h, "div.mandoc { min-width: 102ex; "
+		"width: 102ex; font-family: monospace; }\n");
+	print_text(h, "div.mandoc h1, div.mandoc h2 "
+		"{ margin-bottom: 0ex; font-size: inherit; }\n");
+	print_text(h, "div.mandoc h1 { margin-left: -4ex; }\n");
+	print_text(h, "div.mandoc h2 { margin-left: -2ex; }\n");
+       	print_text(h, "div.mandoc div.section { margin: 1ex 5ex; }\n");
+       	print_text(h, "div.mandoc table { width: 100%; }\n");
+	print_text(h, "div.mandoc td { vertical-align: top; }\n");
+       	print_text(h, "div.mandoc blockquote { margin: 0 5ex; }\n");
+       	print_text(h, "div.mandoc table.head.foot "
+		"td:last-child { text-align: right; }\n");
+       	print_text(h, "div.mandoc table.foot td { width: 50%; }\n");
+       	print_text(h, "div.mandoc table.head td { width: 10%; }\n");
+       	print_text(h, "div.mandoc table.head td.head-vol "
+		"{ width: 80%; text-align: center; }\n");
+       	print_text(h, "div.mandoc .emph { font-style: italic; "
+		"font-weight: normal; }\n");
+       	print_text(h, "div.mandoc .symb { font-style: normal; "
+		"font-weight: bold; }\n");
+       	print_text(h, "div.mandoc .symb { font-style: normal; "
+		"font-weight: normal; }\n");
+       	print_text(h, "div.mandoc i.addr.arg.farg.file.ftype."
+		"link-sec.ref-book.ref-issue.ref-jrnl "
+		"{ font-weight: normal; }\n");
+       	print_text(h, "div.mandoc b.cmd.config.diag.flag.fname."
+		"includes.macro.name.var { font-style: normal; }\n");
+       	print_text(h, "div.mandoc span.ref-title "
+		"{ text-decoration: underline; }\n");
+       	print_text(h, "div.mandoc span.type "
+		"{ font-style: italic; font-weight: normal; }\n");
+       	print_text(h, "div.mandoc dd.list-ohang "
+		"{ margin-left: 0ex; }\n");
+	print_text(h, "div.mandoc ul.list-bul "
+		"{ list-style-type: disc; padding-left: 1em; }\n");
+	print_text(h, "div.mandoc ul.list-dash "
+		"{ list-style-type: none; padding-left: 0em; }\n");
+	print_text(h, "div.mandoc li.list-dash:before "
+		"{ content: \'\\\\2014  \'; }\n");
+	print_text(h, "div.mandoc ul.list-hyph "
+		"{ list-style-type: none; padding-left: 0em; }\n");
+	print_text(h, "div.mandoc li.list-hyph:before "
+		"{ content: \'\\\\2013  \'; }\n");
+	print_text(h, "div.mandoc ul.list-item "
+		"{ list-style-type: none; padding-left: 0em; }\n");
+	print_text(h, "div.mandoc ol.list-enum { padding-left: 2em; }\n");
+	print_tagq(h, t);
 }
 
 static void
@@ -508,6 +575,7 @@ print_otag(struct html *h, enum htmltag 
 	if (HTML_AUTOCLOSE & htmltags[tag].flags)
 		switch (h->type) {
 		case HTML_XHTML_1_0_STRICT:
+		case HTML_HTML5:
 			putchar('/');
 			break;
 		default:
@@ -543,6 +611,9 @@ print_gen_decls(struct html *h)
 	const char	*name;
 
 	switch (h->type) {
+	case HTML_HTML5:
+		printf("<!DOCTYPE html>\n");
+		return;
 	case HTML_HTML_4_01_STRICT:
 		name = "HTML";
 		doctype = "-//W3C//DTD HTML 4.01//EN";
Index: html.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/html.h,v
retrieving revision 1.51
diff -u -p -r1.51 html.h
--- html.h	20 Apr 2014 16:46:04 -0000	1.51
+++ html.h	9 Aug 2014 23:31:38 -0000
@@ -50,6 +50,7 @@ enum	htmltag {
 	TAG_I,
 	TAG_CODE,
 	TAG_SMALL,
+	TAG_STYLE,
 	TAG_MAX
 };
 
@@ -68,6 +69,7 @@ enum	htmlattr {
 	ATTR_SUMMARY,
 	ATTR_ALIGN,
 	ATTR_COLSPAN,
+	ATTR_CHARSET,
 	ATTR_MAX
 };
 
@@ -107,7 +109,8 @@ struct	htmlpair {
 
 enum	htmltype {
 	HTML_HTML_4_01_STRICT,
-	HTML_XHTML_1_0_STRICT
+	HTML_XHTML_1_0_STRICT,
+	HTML_HTML5
 };
 
 struct	html {
Index: man_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_html.c,v
retrieving revision 1.96
diff -u -p -r1.96 man_html.c
--- man_html.c	1 Aug 2014 19:25:52 -0000	1.96
+++ man_html.c	9 Aug 2014 23:31:38 -0000
@@ -309,14 +309,8 @@ man_root_pre(MAN_ARGS)
 	assert(man->msec);
 	mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
 
-	PAIR_SUMMARY_INIT(&tag[0], "Document Header");
-	PAIR_CLASS_INIT(&tag[1], "head");
-	PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
-	t = print_otag(h, TAG_TABLE, 3, tag);
-	PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
-	print_otag(h, TAG_COL, 1, tag);
-	print_otag(h, TAG_COL, 1, tag);
-	print_otag(h, TAG_COL, 1, tag);
+	PAIR_CLASS_INIT(&tag[0], "head");
+	t = print_otag(h, TAG_TABLE, 1, tag);
 
 	print_otag(h, TAG_TBODY, 0, NULL);
 
@@ -328,15 +322,13 @@ man_root_pre(MAN_ARGS)
 	print_stagq(h, tt);
 
 	PAIR_CLASS_INIT(&tag[0], "head-vol");
-	PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
-	print_otag(h, TAG_TD, 2, tag);
+	print_otag(h, TAG_TD, 1, tag);
 	if (NULL != man->vol)
 		print_text(h, man->vol);
 	print_stagq(h, tt);
 
 	PAIR_CLASS_INIT(&tag[0], "head-rtitle");
-	PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
-	print_otag(h, TAG_TD, 2, tag);
+	print_otag(h, TAG_TD, 1, tag);
 	print_text(h, title);
 	print_tagq(h, t);
 	free(title);
@@ -348,13 +340,8 @@ man_root_post(MAN_ARGS)
 	struct htmlpair	 tag[3];
 	struct tag	*t, *tt;
 
-	PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
-	PAIR_CLASS_INIT(&tag[1], "foot");
-	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);
+	PAIR_CLASS_INIT(&tag[0], "foot");
+	t = print_otag(h, TAG_TABLE, 1, tag);
 
 	tt = print_otag(h, TAG_TR, 0, NULL);
 
@@ -366,8 +353,7 @@ man_root_post(MAN_ARGS)
 	print_stagq(h, tt);
 
 	PAIR_CLASS_INIT(&tag[0], "foot-os");
-	PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
-	print_otag(h, TAG_TD, 2, tag);
+	print_otag(h, TAG_TD, 1, tag);
 
 	if (man->source)
 		print_text(h, man->source);
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.195
diff -u -p -r1.195 mdoc_html.c
--- mdoc_html.c	6 Aug 2014 15:09:05 -0000	1.195
+++ mdoc_html.c	9 Aug 2014 23:31:38 -0000
@@ -489,13 +489,8 @@ mdoc_root_post(MDOC_ARGS)
 	struct htmlpair	 tag[3];
 	struct tag	*t, *tt;
 
-	PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
-	PAIR_CLASS_INIT(&tag[1], "foot");
-	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);
+	PAIR_CLASS_INIT(&tag[0], "foot");
+	t = print_otag(h, TAG_TABLE, 1, tag);
 
 	print_otag(h, TAG_TBODY, 0, NULL);
 
@@ -507,8 +502,7 @@ mdoc_root_post(MDOC_ARGS)
 	print_stagq(h, tt);
 
 	PAIR_CLASS_INIT(&tag[0], "foot-os");
-	PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
-	print_otag(h, TAG_TD, 2, tag);
+	print_otag(h, TAG_TD, 1, tag);
 	print_text(h, meta->os);
 	print_tagq(h, t);
 }
@@ -532,14 +526,8 @@ mdoc_root_pre(MDOC_ARGS)
 		mandoc_asprintf(&title, "%s(%s)",
 		    meta->title, meta->msec);
 
-	PAIR_SUMMARY_INIT(&tag[0], "Document Header");
-	PAIR_CLASS_INIT(&tag[1], "head");
-	PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
-	t = print_otag(h, TAG_TABLE, 3, tag);
-	PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
-	print_otag(h, TAG_COL, 1, tag);
-	print_otag(h, TAG_COL, 1, tag);
-	print_otag(h, TAG_COL, 1, tag);
+	PAIR_CLASS_INIT(&tag[0], "head");
+	t = print_otag(h, TAG_TABLE, 1, tag);
 
 	print_otag(h, TAG_TBODY, 0, NULL);
 
@@ -551,14 +539,12 @@ mdoc_root_pre(MDOC_ARGS)
 	print_stagq(h, tt);
 
 	PAIR_CLASS_INIT(&tag[0], "head-vol");
-	PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
-	print_otag(h, TAG_TD, 2, tag);
+	print_otag(h, TAG_TD, 1, tag);
 	print_text(h, volume);
 	print_stagq(h, tt);
 
 	PAIR_CLASS_INIT(&tag[0], "head-rtitle");
-	PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
-	print_otag(h, TAG_TD, 2, tag);
+	print_otag(h, TAG_TD, 1, tag);
 	print_text(h, title);
 	print_tagq(h, t);
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-08-10 17:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-09 23:33 HTML5 Kristaps Dzonsons
2014-08-10  2:23 ` HTML5 Ingo Schwarze
2014-08-10 11:39   ` HTML5 Kristaps Dzonsons
2014-08-10 16:12     ` HTML5 Ingo Schwarze
2014-08-10  4:33 ` HTML5 Anthony J. Bentley
2014-08-10 15:17   ` HTML5 Ingo Schwarze
2014-08-10 17:38     ` HTML5 Anthony J. Bentley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).