about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-30 12:34:19 -0400
committerJune McEnroe <june@causal.agency>2020-04-30 12:34:19 -0400
commite7e2d7e6bb8a5a54f1efe049858526392168ba30 (patch)
treee0b0aafc8872255ad7cc787bf2a604ef9589a6ec
parentUse a table to decode base64 (diff)
downloadbubger-e7e2d7e6bb8a5a54f1efe049858526392168ba30.tar.gz
bubger-e7e2d7e6bb8a5a54f1efe049858526392168ba30.zip
Nest <q> elements for increased levels of quotation
-rw-r--r--default.html6
-rw-r--r--html.c22
2 files changed, 24 insertions, 4 deletions
diff --git a/default.html b/default.html
index 7059e61..9190086 100644
--- a/default.html
+++ b/default.html
@@ -98,6 +98,12 @@ pre q::before, pre q::after {
 pre q {
 	color: navy;
 }
+pre q q {
+	color: teal;
+}
+pre q q q {
+	color: purple;
+}
 pre del {
 	text-decoration: none;
 	color: red;
diff --git a/html.c b/html.c
index ee9e966..12f3ff0 100644
--- a/html.c
+++ b/html.c
@@ -253,6 +253,23 @@ static int htmlMarkupURLs(FILE *file, char *buf) {
 	return escapeXML(file, ptr);
 }
 
+static int htmlMarkupQuote(FILE *file, char *buf) {
+	int error;
+	size_t level = 0;
+	for (char *ch = buf; *ch == '>' || *ch == ' '; level += (*ch++ == '>'));
+	for (size_t i = 0; i < level; ++i) {
+		error = templateRender(file, TEMPLATE(<q>), NULL, NULL);
+		if (error) return error;
+	}
+	error = htmlMarkupURLs(file, buf);
+	if (error) return error;
+	for (size_t i = 0; i < level; ++i) {
+		error = templateRender(file, TEMPLATE(</q>), NULL, NULL);
+		if (error) return error;
+	}
+	return 0;
+}
+
 static int htmlMarkup(FILE *file, const char *content) {
 	int error = 0;
 	size_t cap = 0;
@@ -299,10 +316,7 @@ static int htmlMarkup(FILE *file, const char *content) {
 		} else if (patch) {
 			error = escapeXML(file, buf);
 		} else if (buf[0] == '>') {
-			error = 0
-				|| templateRender(file, TEMPLATE(<q>), NULL, NULL)
-				|| htmlMarkupURLs(file, buf)
-				|| templateRender(file, TEMPLATE(</q>), NULL, NULL);
+			error = htmlMarkupQuote(file, buf);
 		} else {
 			error = htmlMarkupURLs(file, buf);
 		}