commonmark / commonmark/commonmark.js
Inconsistent escape of image alt
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 231
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 3
Description
An obscure edge case, but still...
< is usually escaped in image alt:

becomes
<p><img src="b.png" alt="a <" /></p>
(https://spec.commonmark.org/dingus/?text=!%5Ba%20%3C%5D(b.png))
However, if the < is part of an HTML tag, it is not escaped in the output:

becomes
<p><img src="b.png" alt="a <a>" /></p>
(https://spec.commonmark.org/dingus/?text=!%5Ba%20%3Ca%3E%5D(b.png))
cmark generates the expected output:
<p><img src="b.png" alt="a <a>" /></p>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two image-alt examples in commonmark.js and compare their HTML with the cmark output linked in the issue. Trace the parser or renderer entry point handling image alt text, then make both cases escape angle brackets consistently and verify the expected HTML output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, markdown
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100