source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: Support more than one style attribute one the same HTML element.
@ 2018-11-26  1:38 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2018-11-26  1:38 UTC (permalink / raw)
  To: source

Log Message:
-----------
Support more than one style attribute one the same HTML element.
In fact, this is already required when a table uses non-default
horizontal and vertical alignment in the same cell.

Modified Files:
--------------
    mandoc:
        html.c
        mandoc_html.3

Revision Data
-------------
Index: mandoc_html.3
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc_html.3,v
retrieving revision 1.17
retrieving revision 1.18
diff -Lmandoc_html.3 -Lmandoc_html.3 -u -p -r1.17 -r1.18
--- mandoc_html.3
+++ mandoc_html.3
@@ -216,6 +216,14 @@ It requires two
 .Va char *
 arguments.
 The first is the name of the style property, the second its value.
+The name must not be
+.Dv NULL .
+The
+.Cm s
+.Ar fmt
+letter can be repeated, each repetition requiring an additional pair of
+.Va char *
+arguments.
 .El
 .Pp
 .Fn print_otag
Index: html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/html.c,v
retrieving revision 1.243
retrieving revision 1.244
diff -Lhtml.c -Lhtml.c -u -p -r1.243 -r1.244
--- html.c
+++ html.c
@@ -523,7 +523,7 @@ print_otag(struct html *h, enum htmltag 
 	struct tag	*t;
 	const char	*attr;
 	char		*arg1, *arg2;
-	int		 tflags;
+	int		 style_written, tflags;
 
 	tflags = htmltags[tag].flags;
 
@@ -563,7 +563,7 @@ print_otag(struct html *h, enum htmltag 
 
 	va_start(ap, fmt);
 
-	while (*fmt != '\0') {
+	while (*fmt != '\0' && *fmt != 's') {
 
 		/* Parse attributes and arguments. */
 
@@ -579,10 +579,6 @@ print_otag(struct html *h, enum htmltag 
 		case 'i':
 			attr = "id";
 			break;
-		case 's':
-			attr = "style";
-			arg2 = va_arg(ap, char *);
-			break;
 		case '?':
 			attr = arg1;
 			arg1 = va_arg(ap, char *);
@@ -622,19 +618,32 @@ print_otag(struct html *h, enum htmltag 
 			fmt++;
 			break;
 		default:
-			if (arg2 == NULL)
-				print_encode(h, arg1, NULL, 1);
-			else {
-				print_word(h, arg1);
-				print_byte(h, ':');
-				print_byte(h, ' ');
-				print_word(h, arg2);
-				print_byte(h, ';');
-			}
+			print_encode(h, arg1, NULL, 1);
 			break;
 		}
 		print_byte(h, '"');
 	}
+
+	style_written = 0;
+	while (*fmt++ == 's') {
+		arg1 = va_arg(ap, char *);
+		arg2 = va_arg(ap, char *);
+		if (arg2 == NULL)
+			continue;
+		print_byte(h, ' ');
+		if (style_written == 0) {
+			print_word(h, "style=\"");
+			style_written = 1;
+		}
+		print_word(h, arg1);
+		print_byte(h, ':');
+		print_byte(h, ' ');
+		print_word(h, arg2);
+		print_byte(h, ';');
+	}
+	if (style_written)
+		print_byte(h, '"');
+
 	va_end(ap);
 
 	/* Accommodate for "well-formed" singleton escaping. */
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

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

only message in thread, other threads:[~2018-11-26  1:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-26  1:38 mandoc: Support more than one style attribute one the same HTML element schwarze

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