source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Support more than one style attribute one the same HTML element.
Date: Sun, 25 Nov 2018 20:38:53 -0500 (EST)	[thread overview]
Message-ID: <381d7c56194af1de@fantadrom.bsd.lv> (raw)

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

                 reply	other threads:[~2018-11-26  1:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=381d7c56194af1de@fantadrom.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).