summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--main.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/main.c b/main.c
index caaee7c..9e964bb 100644
--- a/main.c
+++ b/main.c
@@ -266,7 +266,7 @@ BlockList blk_gather(Str src, Arena *perm) {
 #define O(s) str_cat_html(out, s, perm)
 #define Oi(s) markup_inline(&ist, out, s, scratch, perm)
 #define Os(s) str_cat(out, S(s), perm)
-#define Ot(a, s, b) Os(a), Oi(s), Os(b)
+#define Ot(a, s, b) Os(a), Oi(s), markup_inline_fin(&ist, out, perm), Os(b)
 #define Otl(a, f, b) for (Line *l = blk->lines; l; l = l->next) Ot(a, f, b)
 
 typedef enum {
@@ -358,6 +358,11 @@ void markup_inline(InlineState *ms, Str *out, Str src, Arena *scratch, Arena *pe
 	}
 }
 
+void markup_inline_fin(InlineState *ms, Str *out, Arena *perm) {
+	while (im_last(ms) != IM_NONE) im_cl(ms, out, perm);
+	*ms = (InlineState) { 0 };
+}
+
 void markup_block(Str *out, Block *blk, Arena *perm, Arena *scratch) {
 	InlineState ist = { 0 };
 	switch (blk->type) {
@@ -401,9 +406,10 @@ void markup_block(Str *out, Block *blk, Arena *perm, Arena *scratch) {
 	case LN_BQUOT:
 		Os("<blockquote>");
 		for (Line *l = blk->lines; l; l = l->next) {
-			O(l->txt);
+			Oi(l->txt);
 			if (l->next) Os("<br>\n");
 		}
+		markup_inline_fin(&ist, out, perm);
 		Os("<blockquote>");
 		break;
 	case LN_ULIST:
@@ -432,6 +438,7 @@ void markup_block(Str *out, Block *blk, Arena *perm, Arena *scratch) {
 			Oi(l->txt);
 			if (l->next) Os("<br>\n");
 		}
+		markup_inline_fin(&ist, out, perm);
 		Os("</p>");
 		break;
 	}