summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-07-11 17:11:39 -0400
committerJune McEnroe <june@causal.agency>2019-07-11 17:11:39 -0400
commitff43ade74b8e788b28a4eb74b1b688f803d30e8c (patch)
treed6c6d16a73ba4c4d83c77f0b39ea863801a2a310
parentIgnore SM and RM (diff)
downloadsrc-ff43ade74b8e788b28a4eb74b1b688f803d30e8c.tar.gz
src-ff43ade74b8e788b28a4eb74b1b688f803d30e8c.zip
Output <b>, <i>, <u> in shotty
-rw-r--r--bin/shotty.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/bin/shotty.c b/bin/shotty.c
index 234cd07f..15ab3e4d 100644
--- a/bin/shotty.c
+++ b/bin/shotty.c
@@ -231,15 +231,18 @@ static void update(wchar_t ch) {
 static void
 html(const struct Style *prev, const struct Cell *cell) {
 	if (!prev || memcmp(&cell->style, prev, sizeof(cell->style))) {
-		if (prev) printf("</span>");
-		printf("<span class=\"");
-		if (cell->style.bold) printf("bold ");
-		if (cell->style.italic) printf("italic ");
-		if (cell->style.underline) printf("underline ");
+		if (prev) {
+			if (prev->bold) printf("</b>");
+			if (prev->italic) printf("</i>");
+			if (prev->underline) printf("</u>");
+			printf("</span>");
+		}
 		uint bg = (cell->style.reverse ? cell->style.fg : cell->style.bg);
 		uint fg = (cell->style.reverse ? cell->style.bg : cell->style.fg);
-		if (cell->style.bold && fg < 8) fg += 8;
-		printf("bg%u fg%u\">", bg, fg);
+		printf("<span class=\"bg%u fg%u\">", bg, fg);
+		if (cell->style.bold) printf("<b>");
+		if (cell->style.italic) printf("<i>");
+		if (cell->style.underline) printf("<u>");
 	}
 	switch (cell->ch) {
 		break; case '&': printf("&amp;");