=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.148 retrieving revision 1.154 diff -u -p -r1.148 -r1.154 --- mandoc/mdoc_html.c 2011/01/25 16:20:24 1.148 +++ mandoc/mdoc_html.c 2011/03/07 01:35:51 1.154 @@ -1,6 +1,6 @@ -/* $Id: mdoc_html.c,v 1.148 2011/01/25 16:20:24 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.154 2011/03/07 01:35:51 schwarze Exp $ */ /* - * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons + * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -410,6 +410,7 @@ print_mdoc_node(MDOC_ARGS) { int child; struct tag *t; + struct htmlpair tag; child = 1; t = h->tags.head; @@ -422,10 +423,21 @@ print_mdoc_node(MDOC_ARGS) case (MDOC_TEXT): /* No tables in this mode... */ assert(NULL == h->tblt); + + /* + * Make sure that if we're in a literal mode already + * (i.e., within a
) don't print the newline.
+		 */
 		if (' ' == *n->string && MDOC_LINE & n->flags)
-			print_otag(h, TAG_BR, 0, NULL);
+			if ( ! (HTML_LITERAL & h->flags))
+				print_otag(h, TAG_BR, 0, NULL);
 		print_text(h, n->string);
 		return;
+	case (MDOC_EQN):
+		PAIR_CLASS_INIT(&tag, "eqn");
+		print_otag(h, TAG_SPAN, 1, &tag);
+		print_text(h, n->eqn->data);
+		break;
 	case (MDOC_TBL):
 		/*
 		 * This will take care of initialising all of the table
@@ -473,6 +485,8 @@ print_mdoc_node(MDOC_ARGS)
 	case (MDOC_ROOT):
 		mdoc_root_post(m, n, h);
 		break;
+	case (MDOC_EQN):
+		break;
 	default:
 		if (mdocs[n->tok].post && ENDBODY_NOT == n->end)
 			(*mdocs[n->tok].post)(m, n, h);
@@ -486,10 +500,7 @@ mdoc_root_post(MDOC_ARGS)
 {
 	struct htmlpair	 tag[3];
 	struct tag	*t, *tt;
-	char		 b[DATESIZ];
 
-	time2a(m->date, b, DATESIZ);
-
 	PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
 	PAIR_CLASS_INIT(&tag[1], "foot");
 	if (NULL == h->style) {
@@ -508,7 +519,7 @@ mdoc_root_post(MDOC_ARGS)
 	PAIR_CLASS_INIT(&tag[0], "foot-date");
 	print_otag(h, TAG_TD, 1, tag);
 
-	print_text(h, b);
+	print_text(h, m->date);
 	print_stagq(h, tt);
 
 	PAIR_CLASS_INIT(&tag[0], "foot-os");
@@ -774,7 +785,8 @@ static int
 mdoc_ns_pre(MDOC_ARGS)
 {
 
-	h->flags |= HTML_NOSPACE;
+	if ( ! (MDOC_LINE & n->flags))
+		h->flags |= HTML_NOSPACE;
 	return(1);
 }
 
@@ -797,6 +809,7 @@ mdoc_xx_pre(MDOC_ARGS)
 {
 	const char	*pp;
 	struct htmlpair	 tag;
+	int		 flags;
 
 	switch (n->tok) {
 	case (MDOC_Bsx):
@@ -826,9 +839,10 @@ mdoc_xx_pre(MDOC_ARGS)
 
 	print_text(h, pp);
 	if (n->child) {
+		flags = h->flags;
 		h->flags |= HTML_KEEP;
 		print_text(h, n->child->string);
-		h->flags &= ~HTML_KEEP;
+		h->flags = flags;
 	}
 	return(0);
 }
@@ -1175,7 +1189,7 @@ static int
 mdoc_bd_pre(MDOC_ARGS)
 {
 	struct htmlpair	 	 tag[2];
-	int		 	 comp;
+	int		 	 comp, sv;
 	const struct mdoc_node	*nn;
 	struct roffsu		 su;
 
@@ -1214,6 +1228,11 @@ mdoc_bd_pre(MDOC_ARGS)
 	PAIR_CLASS_INIT(&tag[1], "lit display");
 	print_otag(h, TAG_PRE, 2, tag);
 
+	/* This can be recursive: save & set our literal state. */
+
+	sv = h->flags & HTML_LITERAL;
+	h->flags |= HTML_LITERAL;
+
 	for (nn = n->child; nn; nn = nn->next) {
 		print_mdoc_node(m, nn, h);
 		/*
@@ -1249,6 +1268,9 @@ mdoc_bd_pre(MDOC_ARGS)
 
 		h->flags |= HTML_NOSPACE;
 	}
+
+	if (0 == sv)
+		h->flags &= ~HTML_LITERAL;
 
 	return(0);
 }