commonmark / commonmark/commonmark.js

Inconsistent escape of image alt

Open
#264 0 comments 1 reaction 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

An obscure edge case, but still...

< is usually escaped in image alt:

![a <](b.png)

becomes

<p><img src="b.png" alt="a &lt;" /></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:

![a <a>](b.png)

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 &lt;a&gt;" /></p>

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.