commonmark / commonmark/cmark

Bug in lazy blockquote continuation (or corresponding spec is wrong, whichever)

Open
#204 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
2k
Forks
691
Avg merge
1d 16h
Merged PRs (30d)
1

Description

Current spec says:

If a string of lines Ls constitute a block
quote with contents Bs, then the result of deleting
the initial [block quote marker] from one or
more lines in which the next [non-whitespace character] after the [block
quote marker] is [paragraph continuation
text] is a block quote with Bs as its content.

http://spec.commonmark.org/0.27/#block-quotes

This spec is clear, and explicit. I see no ambiguity. Now consider this blockquote:

> This is _a_ paragraph continuation text
> 2. because the line starts with `2`, not `1`.

This blockquote is valid, and satisfies the "If a string of lines Ls constitute a block quote with contents Bs" condition. So according to the spec, we can delete the leading >. By doing so we get this:

> This is _a_ paragraph continuation text
2. because the line starts with `2`, not `1`.

This blockquote, according to the spec, must be identical to the former one. However cmark does not agree.

% cmark <<'EOS'
> This is _a_ paragraph continuation text
> 2. because the line starts with `2`, not `1`.
EOS
<blockquote>
<p>This is <em>a</em> paragraph continuation text
2. because the line starts with <code>2</code>, not <code>1</code>.</p>
</blockquote>
% cmark <<'EOS'
> This is _a_ paragraph continuation text
2. because the line starts with `2`, not `1`.
EOS
<blockquote>
<p>This is <em>a</em> paragraph continuation text</p>
</blockquote>
<ol start="2">
<li>because the line starts with <code>2</code>, not <code>1</code>.</li>
</ol>
%

Is it intentional?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two examples with the cmark command and compare their block quote and list parsing with the linked CommonMark 0.27 specification. Determine whether the implementation or specification is incorrect, then add a regression case and document the resolved behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, markdown
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.