summary refs log tree commit diff
path: root/html.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-23 17:39:24 -0400
committerJune McEnroe <june@causal.agency>2020-04-23 17:39:24 -0400
commitdfaf5cc9043b8bce6f1edfd55a6bf696ce445052 (patch)
tree5705b0dd73c0ac2adb68158827755457431f15c1 /html.c
parentAdd default.html (diff)
downloadbubger-dfaf5cc9043b8bce6f1edfd55a6bf696ce445052.tar.gz
bubger-dfaf5cc9043b8bce6f1edfd55a6bf696ce445052.zip
Wrap quoted lines in <q>
Diffstat (limited to '')
-rw-r--r--html.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/html.c b/html.c
index 200032a..fe2f6db 100644
--- a/html.c
+++ b/html.c
@@ -204,11 +204,7 @@ static int htmlInlineAttrs(FILE *file, const struct BodyPart *part) {
 	return 0;
 }
 
-static bool isPatch(const char *content) {
-	return !strncmp(content, "---\n", 4) || strstr(content, "\n---\n");
-}
-
-static int htmlPatch(FILE *file, const char *content) {
+static int htmlHighlight(FILE *file, const char *content) {
 	int error = 0;
 	size_t cap = 0;
 	char *buf = NULL;
@@ -245,6 +241,10 @@ static int htmlPatch(FILE *file, const char *content) {
 			error = templateRender(
 				file, TEMPLATE(<ins>[line]</ins>), vars, escapeXML
 			);
+		} else if (buf[0] == '>') {
+			error = templateRender(
+				file, TEMPLATE(<q>[line]</q>), vars, escapeXML
+			);
 		} else {
 			error = escapeXML(file, buf);
 		}
@@ -255,17 +255,12 @@ static int htmlPatch(FILE *file, const char *content) {
 }
 
 int htmlInline(FILE *file, const struct BodyPart *part, const char *content) {
-	int error = 0
+	return 0
 		|| templateRender(file, TEMPLATE(<pre), NULL, NULL)
 		|| htmlInlineAttrs(file, part)
-		|| templateRender(file, TEMPLATE(>), NULL, NULL);
-	if (error) return error;
-	if (isPatch(content)) {
-		error = htmlPatch(file, content);
-	} else {
-		error = escapeXML(file, content);
-	}
-	return error || templateRender(file, TEMPLATE(</pre>), NULL, NULL);
+		|| templateRender(file, TEMPLATE(>), NULL, NULL)
+		|| htmlHighlight(file, content)
+		|| templateRender(file, TEMPLATE(</pre>), NULL, NULL);
 }
 
 int htmlAttachmentOpen(FILE *file) {