PrismJS / PrismJS/prism

JavaScript regular expression literal + single-line comment = incorrect syntax-highlighting

Open
#3,491 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Information:

  • Prism version: latest (v1.28.0)
  • Plugins: none
  • Environment: all

Example

https://prismjs.com/test.html#language=javascript&text=%2F.%2Fg%3B%20%2F%2F%20remove%20this%20comment%20to%20fix%20the%20highlighting%0A%2F.%2Fg%3B

/./g; // remove this comment to fix the highlighting
/./g;

The first regular expression literal gets syntax-highlighted correctly. The second one doesn’t. Removing the comment at the end of the first line makes both get syntax-highlighted correctly.

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 JavaScript example in the issue and reproduce it in the linked Prism test page, comparing the two regular-expression literals with and without the trailing single-line comment. Done means both literals are highlighted correctly while preserving the comment behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.