commonmark / commonmark/cmark

Rendering to CommonMark with a column width can create a heading

Open
#314 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

I see you've carefully avoided accidentally starting a list:

$ printf 'abcd x)' | cmark -t commonmark --width 4
abcd
x)
$ printf 'abcd 1)' | cmark -t commonmark --width 4
abcd 1)

But a heading can be accidentally created:

$ printf 'abcd =' | cmark -t commonmark --width 4 | cmark -t html
<h1>abcd</h1>
$ printf 'abcd -' | cmark -t commonmark --width 4 | cmark -t html
<h2>abcd</h2>

I think you can find this bug (and perhaps others) by writing a program that converts to HTML both directly and via CommonMark with width 4 and compares the two results and aborts if they're different, then fuzzing that program with AFL.

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 with the cmark command and reproduce the two width-4 examples that turn trailing '=' or '-' into headings when converted through CommonMark. Compare direct HTML output with the width-4 CommonMark round trip, then use the suggested AFL fuzzing approach; done means the outputs agree without accidental headings, including the reported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cli, 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.