summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2018-11-26 01:38:17 +0000
committerschwarze <schwarze@openbsd.org>2018-11-26 01:38:17 +0000
commit373dd5ba116d42cddf1fdcb58b578a4274f6d589 (patch)
tree82fca9d21586c9e23d02f32cb186bb45f8a1a4a7
parentLet cells containing nothing but \^ extend the cell above. (diff)
downloadwireguard-openbsd-373dd5ba116d42cddf1fdcb58b578a4274f6d589.tar.xz
wireguard-openbsd-373dd5ba116d42cddf1fdcb58b578a4274f6d589.zip
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.
-rw-r--r--usr.bin/mandoc/html.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c
index a76a96ce269..9f94c12b86b 100644
--- a/usr.bin/mandoc/html.c
+++ b/usr.bin/mandoc/html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.c,v 1.113 2018/11/23 19:15:32 schwarze Exp $ */
+/* $OpenBSD: html.c,v 1.114 2018/11/26 01:38:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -521,7 +521,7 @@ print_otag(struct html *h, enum htmltag tag, const char *fmt, ...)
struct tag *t;
const char *attr;
char *arg1, *arg2;
- int tflags;
+ int style_written, tflags;
tflags = htmltags[tag].flags;
@@ -561,7 +561,7 @@ print_otag(struct html *h, enum htmltag tag, const char *fmt, ...)
va_start(ap, fmt);
- while (*fmt != '\0') {
+ while (*fmt != '\0' && *fmt != 's') {
/* Parse attributes and arguments. */
@@ -577,10 +577,6 @@ print_otag(struct html *h, enum htmltag tag, const char *fmt, ...)
case 'i':
attr = "id";
break;
- case 's':
- attr = "style";
- arg2 = va_arg(ap, char *);
- break;
case '?':
attr = arg1;
arg1 = va_arg(ap, char *);
@@ -620,19 +616,32 @@ print_otag(struct html *h, enum htmltag tag, const char *fmt, ...)
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. */