source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Considerably fix up -man -T[x]html's handling of verbatim spaces
@ 2011-07-07 13:54 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-07-07 13:54 UTC (permalink / raw)
  To: source

Log Message:
-----------
Considerably fix up -man -T[x]html's handling of verbatim spaces (`nf'),
which before were being handled erratically.

Modified Files:
--------------
    mdocml:
        man_html.c

Revision Data
-------------
Index: man_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_html.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -Lman_html.c -Lman_html.c -u -p -r1.77 -r1.78
--- man_html.c
+++ man_html.c
@@ -219,22 +219,14 @@ print_man_node(MAN_ARGS)
 		if ('\0' == *n->string) {
 			print_otag(h, TAG_P, 0, NULL);
 			return;
-		} else if (' ' == *n->string && MAN_LINE & n->flags)
+		}
+
+		if (' ' == *n->string && MAN_LINE & n->flags)
+			print_otag(h, TAG_BR, 0, NULL);
+		else if (MANH_LITERAL & mh->fl && n->prev)
 			print_otag(h, TAG_BR, 0, NULL);
 
 		print_text(h, n->string);
-
-		/*
-		 * If we're in a literal context, make sure that words
-		 * togehter on the same line stay together.  This is a
-		 * POST-printing call, so we check the NEXT word.  Since
-		 * -man doesn't have nested macros, we don't need to be
-		 * more specific than this.
-		 */
-		if (MANH_LITERAL & mh->fl &&
-				(NULL == n->next ||
-				 n->next->line > n->line))
-			print_otag(h, TAG_BR, 0, NULL);
 		return;
 	case (MAN_EQN):
 		PAIR_CLASS_INIT(&tag, "eqn");
@@ -453,10 +445,15 @@ static int
 man_alt_pre(MAN_ARGS)
 {
 	const struct man_node	*nn;
-	int		 i;
+	int		 i, savelit;
 	enum htmltag	 fp;
 	struct tag	*t;
 
+	if ((savelit = mh->fl & MANH_LITERAL)) 
+		print_otag(h, TAG_BR, 0, NULL);
+
+	mh->fl &= ~MANH_LITERAL;
+
 	for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
 		t = NULL;
 		switch (n->tok) {
@@ -495,6 +492,9 @@ man_alt_pre(MAN_ARGS)
 			print_tagq(h, t);
 	}
 
+	if (savelit)
+		mh->fl |= MANH_LITERAL;
+
 	return(0);
 }
 
@@ -554,6 +554,8 @@ man_IP_pre(MAN_ARGS)
 		return(1);
 	}
 
+	/* FIXME: width specification. */
+
 	print_otag(h, TAG_DT, 0, NULL);
 
 	/* For IP, only print the first header element. */
@@ -623,11 +625,11 @@ static int
 man_literal_pre(MAN_ARGS)
 {
 
-	if (MAN_nf == n->tok) {
+	if (MAN_nf != n->tok) {
 		print_otag(h, TAG_BR, 0, NULL);
-		mh->fl |= MANH_LITERAL;
-	} else
 		mh->fl &= ~MANH_LITERAL;
+	} else
+		mh->fl |= MANH_LITERAL;
 
 	return(0);
 }
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-07-07 13:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-07 13:54 mdocml: Considerably fix up -man -T[x]html's handling of verbatim spaces kristaps

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).