X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/3e23d66c0abbb35f937f3969d2a6a54cb8827037..9425244d2b742390e69a9fedde12afadefb6802b:/html.c

diff --git a/html.c b/html.c
index 5e19b09c..138d3e4c 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/*	$Id: html.c,v 1.107 2010/07/16 22:33:30 kristaps Exp $ */
+/*	$Id: html.c,v 1.112 2010/09/04 20:18:53 kristaps Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -88,7 +88,8 @@ static	const char	*const htmlattrs[ATTR_MAX] = {
 	"summary",
 };
 
-static	void		  print_spec(struct html *, const char *, size_t);
+static	void		  print_spec(struct html *, enum roffdeco,
+				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 *);
@@ -115,7 +116,7 @@ ml_alloc(char *outopts, enum htmltype type)
 	h = calloc(1, sizeof(struct html));
 	if (NULL == h) {
 		perror(NULL);
-		exit(EXIT_FAILURE);
+		exit((int)MANDOCLEVEL_SYSERR);
 	}
 
 	h->type = type;
@@ -215,7 +216,7 @@ print_gen_head(struct html *h)
 
 
 static void
-print_spec(struct html *h, const char *p, size_t len)
+print_spec(struct html *h, enum roffdeco d, const char *p, size_t len)
 {
 	int		 cp;
 	const char	*rhs;
@@ -224,6 +225,9 @@ print_spec(struct html *h, const char *p, size_t len)
 	if ((cp = chars_spec2cp(h->symtab, p, len)) > 0) {
 		printf("&#%d;", cp);
 		return;
+	} else if (-1 == cp && DECO_SSPECIAL == d) {
+		fwrite(p, 1, len, stdout);
+		return;
 	} else if (-1 == cp)
 		return;
 
@@ -342,8 +346,10 @@ print_encode(struct html *h, const char *p, int norecurse)
 		case (DECO_RESERVED):
 			print_res(h, seq, sz);
 			break;
+		case (DECO_SSPECIAL):
+			/* FALLTHROUGH */
 		case (DECO_SPECIAL):
-			print_spec(h, seq, sz);
+			print_spec(h, deco, seq, sz);
 			break;
 		case (DECO_PREVIOUS):
 			/* FALLTHROUGH */
@@ -392,7 +398,7 @@ print_otag(struct html *h, enum htmltag tag,
 		t = malloc(sizeof(struct tag));
 		if (NULL == t) {
 			perror(NULL);
-			exit(EXIT_FAILURE);
+			exit((int)MANDOCLEVEL_SYSERR);
 		}
 		t->tag = tag;
 		t->next = h->tags.head;
@@ -411,6 +417,11 @@ print_otag(struct html *h, enum htmltag tag,
 				printf("&#160;");
 		}
 
+	if ( ! (h->flags & HTML_NONOSPACE))
+		h->flags &= ~HTML_NOSPACE;
+	else
+		h->flags |= HTML_NOSPACE;
+
 	/* Print out the tag name and attributes. */
 
 	printf("<%s", htmltags[tag].name);
@@ -538,7 +549,8 @@ print_text(struct html *h, const char *word)
 
 	assert(word);
 	if ( ! print_encode(h, word, 0))
-		h->flags &= ~HTML_NOSPACE;
+		if ( ! (h->flags & HTML_NONOSPACE))
+			h->flags &= ~HTML_NOSPACE;
 
 	/* 
 	 * Note that we don't process the pipe: the parser sees it as