PrismJS / PrismJS/prism

Markdown footnotes incorrectly recognized as URL references

Open
#3,663 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
13k
Forks
1.4k
Avg merge
15h 36m
Merged PRs (30d)
3

Description

Information:

  • Prism version: 1.29.0
  • Plugins: none
  • Environment: Browser

Description

Markdown footnotes are incorrectly recognized as URL references, e.g., the text [^1]: This in the example below:

A footnote[^1].

[^1]: This is a footnote and not a URL.

I think the regex here needs to be enhanced: https://github.com/PrismJS/prism/blob/59e5a3471377057de1f401ba38337aca27b80e03/components/prism-markdown.js#L150-L154

Example

https://prismjs.com/test.html#language=markdown&text=A%20footnote%5B%5E1%5D.%0A%0A%5B%5E1%5D%3A%20This%20is%20a%20footnote%20and%20not%20a%20URL.

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

Inspect components/prism-markdown.js around lines 150-154 and reproduce the example in the linked Prism test page. Adjust the referenced regex so Markdown footnote definitions are not recognized as URL references, while actual URL references still are. Verify the example renders with the corrected Markdown highlighting.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.