cmark

My personal build of CMark ✏️

Commit
06156fd9194806ab98889e5ef3a309bb7075b02c
Parent
fe58a9295d44bd58bb4e48e449eb56c070e099d8
Author
John MacFarlane <jgm@berkeley.edu>
Date

Update emphasis parsing for spec change.

Strong now goes inside Emph rather than the reverse, when both scopes are possible.

The code is much simpler.

This also avoids a spec inconsistency that cmark had previously:

`***hi***` became Strong (Emph "hi")) but `***hi****` became Emph (Strong "hi")) "*"

Diffstat

1 file changed, 1 insertion, 6 deletions

Status File Name N° Changes Insertions Deletions
Modified src/inlines.c 7 1 6
diff --git a/src/inlines.c b/src/inlines.c
@@ -614,12 +614,7 @@ static delimiter *S_insert_emph(subject *subj, delimiter *opener,
   cmark_node *tmp, *tmpnext, *emph;
 
   // calculate the actual number of characters used from this closer
-  if (closer_num_chars < 3 || opener_num_chars < 3) {
-    use_delims = closer_num_chars <= opener_num_chars ? closer_num_chars
-                                                      : opener_num_chars;
-  } else { // closer and opener both have >= 3 characters
-    use_delims = closer_num_chars % 2 == 0 ? 2 : 1;
-  }
+  use_delims = (closer_num_chars >= 2 && opener_num_chars >=2) ? 2 : 1;
 
   // remove used characters from associated inlines.
   opener_num_chars -= use_delims;