Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A list item can begin with at most one blank line. #6

Closed
mity opened this issue Dec 8, 2016 · 1 comment
Closed

A list item can begin with at most one blank line. #6

mity opened this issue Dec 8, 2016 · 1 comment
Labels

Comments

@mity
Copy link
Owner

mity commented Dec 8, 2016

MD4C does not currently follow the rule of CommonMark spec 0.27 that

a list item can begin with at most one blank line.

Therefore we fail the Example 241.

However when we literally implement the rule as per this patch:

diff --git a/md4c/md4c.c b/md4c/md4c.c
index aae2a63..a82d458 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -4833,6 +4833,18 @@ redo:
             ctx->last_line_has_list_loosening_effect = (n_parents > 0  &&
                     n_brothers + n_children == 0  &&
                     ctx->containers[n_parents-1].ch != _T('>'));
+
+            /* If current list item contains nothing but a single blank line
+             * and we would be second blank line in the same list item, then
+             * we and the list. */
+            if(n_parents > 0  &&  ctx->containers[n_parents-1].ch != _T('>')  &&
+               n_brothers + n_children == 0  &&  ctx->current_block == NULL  &&
+               ctx->n_block_bytes > sizeof(MD_BLOCK))
+            {
+                MD_BLOCK* top_block = (MD_BLOCK*) ((char*)ctx->block_bytes + ctx->n_block_bytes - sizeof(MD_BLOCK));
+                if(top_block->type == MD_BLOCK_LI)
+                    n_parents--;
+            }
         }
         goto done;
     } else {

then we stop to pass the Example 274.

After inspecting, it looks as a contradiction in the spec to me. Fired the issue commonmark/commonmark-spec#443 for it.

@mity mity added the bug label Dec 12, 2016
mity added a commit that referenced this issue Dec 15, 2016
…ssue #6).

Hacky. I very dislike it, but it brings us full CommonMark 0.27
compliance.

Hallelujah.
@mity
Copy link
Owner Author

mity commented Dec 15, 2016

Fixed.

Somewhat hacky, as the rule is quite unnatural given our implementation design, but works.

At least we can celebrate passing complete CommonMark 0.27 test suite.
https://www.youtube.com/watch?v=Szdziw4tI9o

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant