aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-11-26 01:38:23 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-11-26 01:38:23 +0000
commit61fcffec773b678355426660027d08c645313d1e (patch)
tree1ec144d9d43c25233318b28579c04e1d7a4c0249 /html.c
parentc262512cda526a647bc53812a01794100b385be9 (diff)
downloadmandoc-61fcffec773b678355426660027d08c645313d1e.tar.gz
mandoc-61fcffec773b678355426660027d08c645313d1e.tar.zst
mandoc-61fcffec773b678355426660027d08c645313d1e.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.
Diffstat (limited to 'html.c')
-rw-r--r--html.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/html.c b/html.c
index 63b93c0b..db5c471b 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.243 2018/11/23 19:17:05 schwarze Exp $ */
+/* $Id: html.c,v 1.244 2018/11/26 01:38:23 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -523,7 +523,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;
@@ -563,7 +563,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. */
@@ -579,10 +579,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 *);
@@ -622,19 +618,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. */