commonmark / commonmark/commonmark.js

White space handling looks inconsistent between HTML block element vs HTML inline element

Open
#303 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.6k
Forks
231
Avg merge
2d 11h
Merged PRs (30d)
3

Description

Hi. I'm curious about why white space preservation / removal differs between <div> and <a> in following case:

https://spec.commonmark.org/dingus/?text=%3Cdiv%20class%3D%22abc%0A%20%20%20%20d%20%20e%20f%22%3Etext%3C%2Fdev%3E%0A%0A%3Ca%20class%3D%22abc%0A%20%20%20%20d%20%20e%20f%22%3Etext%3C%2Fa%3E

Input:

<div class="abc
    d  e f">text</dev>

<a class="abc
    d  e f">text</a>

Output:

<div class="abc
    d  e f">text</dev>
<p><a class="abc
d  e f">text</a></p>

I've read https://spec.commonmark.org/0.31.2/ but it's not obvious whether it's a bug or intentional.
I came from https://github.com/orgs/micromark/discussions/211.

Contributor guide

Open the contributing guide

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 linked CommonMark Dingus example and compare the block-element and inline-element output with the referenced CommonMark 0.31.2 specification. Determine whether the difference is intentional or a parser bug; done means the expected behavior is established and, if needed, a concrete change and regression test are identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.