commonmark / commonmark/cmark

why does this HTML block start and end on the same line?

Open
#488 3 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

Why is the HTML block (spec 4.6) closed on the same line when
https://github.com/commonmark/commonmark-spec/blob/d5706b9553d4665ca730524323d484880440186c/spec.txt#L2368 says that

[An HTML block] ends with the first subsequent line that meets a matching end condition. (emphasis mine)

cmark << EOF
<!-- comment --> 0
1
-->
2
EOF
<!-- raw HTML omitted -->
<p>1
--&gt;
2
EOF</p>

I think cmark parses the comment as an HTML block. It couldn't be a raw HTML comment (spec 6.6) otherwise "0" would surface inside a <p>. So it seems that, contrary to the specification, the HTML block ends on the same line where it starts, instead of ending between "1" and "2".

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

Reproduce the behavior with the cmark command and input shown in the issue, then compare the result with the HTML block rules at the linked spec.txt location. Trace the HTML block parsing path to determine whether the same-line close is intentional or a bug, and add regression coverage showing the expected boundary between “1” and “2”.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.