=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/html.c,v retrieving revision 1.113 retrieving revision 1.114 diff -u -r1.113 -r1.114 --- src/usr.bin/mandoc/html.c 2018/11/23 19:15:32 1.113 +++ src/usr.bin/mandoc/html.c 2018/11/26 01:38:17 1.114 @@ -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 * Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze @@ -521,7 +521,7 @@ struct tag *t; const char *attr; char *arg1, *arg2; - int tflags; + int style_written, tflags; tflags = htmltags[tag].flags; @@ -561,7 +561,7 @@ va_start(ap, fmt); - while (*fmt != '\0') { + while (*fmt != '\0' && *fmt != 's') { /* Parse attributes and arguments. */ @@ -577,10 +577,6 @@ 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 @@ 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. */