cmark

My personal build of CMark ✏️

Commit
6459d419cdd09b6006258762e26a72aa17e6d48a
Parent
2de98358a54fe35f584e30181d86460bb842ebee
Author
John MacFarlane <jgm@berkeley.edu>
Date

Clarified emph/strong rules.

Make it clear that in `**foo **bar baz**` the shorter of the two potential strong emphasis spans (`bar baz`) is preferred.

Diffstat

1 file changed, 26 insertions, 6 deletions

Status File Name N° Changes Insertions Deletions
Modified spec.txt 32 26 6
diff --git a/spec.txt b/spec.txt
@@ -4328,15 +4328,21 @@ the following principles resolve ambiguity:
 12. An interpretation `<strong><em>...</em></strong>` is always
     preferred to `<em><strong>..</strong></em>`.
 
-13. Earlier closings are preferred to later closings.  Thus,
-    when two potential emphasis or strong emphasis spans overlap,
-    the first takes precedence: for example, `*foo _bar* baz_`
-    is parsed as `<em>foo _bar</em> baz_` rather than
-    `*foo <em>bar* baz</em>`.  For the same reason,
+13. When two potential emphasis or strong emphasis spans overlap,
+    so that the second begins before the first ends and ends after
+    the first ends, the first is preferred. Thus, for example,
+    `*foo _bar* baz_` is parsed as `<em>foo _bar</em> baz_` rather
+    than `*foo <em>bar* baz</em>`.  For the same reason,
     `**foo*bar**` is parsed as `<em><em>foo</em>bar</em>*`
     rather than `<strong>foo*bar</strong>`.
 
-14. Inline code spans, links, images, and HTML tags group more tightly
+14. When there are two potential emphasis or strong emphasis spans
+    with the same closing delimiter, the shorter one (the one that
+    opens later) is preferred. Thus, for example,
+    `**foo **bar baz**` is parsed as `**foo <strong>bar baz</strong>`
+    rather than `<strong>foo **bar baz</strong>`.
+
+15. Inline code spans, links, images, and HTML tags group more tightly
     than emphasis.  So, when there is a choice between an interpretation
     that contains one of these elements and one that does not, the
     former always wins.  Thus, for example, `*[foo*](bar)` is
@@ -4970,6 +4976,20 @@ The following cases illustrate rule 13:
 The following cases illustrate rule 14:
 
 .
+**foo **bar baz**
+.
+<p>**foo <strong>bar baz</strong></p>
+.
+
+.
+*foo *bar baz*
+.
+<p>*foo <em>bar baz</em></p>
+.
+
+The following cases illustrate rule 15:
+
+.
 *[foo*](bar)
 .
 <p>*<a href="bar">foo*</a></p>