cmark

My personal build of CMark ✏️

Commit
3c0b582b52021a6abea644f056a4da4301e2bc30
Parent
af5bff782a9682531da0dec6469748cd0ea48489
Author
John MacFarlane <jgm@berkeley.edu>
Date

Properly handle " with no matching close quote with --smart.

This occurs in fiction: when a speaker has dialogue with multiple paragraphs, a close quote is used only on the final one.

Added test cases.

Diffstat

2 files changed, 16 insertions, 1 deletion

Status File Name N° Changes Insertions Deletions
Modified src/inlines.c 2 1 1
Modified test/smart_punct.txt 15 15 0
diff --git a/src/inlines.c b/src/inlines.c
@@ -368,7 +368,7 @@ static cmark_node* handle_delim(subject* subj, unsigned char c, bool smart)
 	if (c == '\'' && smart) {
 		contents = cmark_chunk_literal("’");
 	} else if (c == '"' && smart) {
-		contents = cmark_chunk_literal("”");
+		contents = cmark_chunk_literal(can_close ? "”" : "“");
 	} else {
 		contents = cmark_chunk_dup(&subj->input, subj->pos - numdelims, numdelims);
 	}
diff --git a/test/smart_punct.txt b/test/smart_punct.txt
@@ -41,6 +41,21 @@ Here is some quoted '`code`' and a "[quoted link](url)".
 .
 
 .
+'tis the season to be 'jolly'
+.
+<p>’tis the season to be ‘jolly’</p>
+.
+
+.
+"A paragraph with no closing quote.
+
+"Second paragraph by same speaker, in fiction."
+.
+<p>“A paragraph with no closing quote.</p>
+<p>“Second paragraph by same speaker, in fiction.”</p>
+.
+
+.
 Some dashes:  one---two ---
 three---four --- five.
 .