PrismJS / PrismJS/prism

CSS selector for `language-xxxx` class does not account for substrings

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

Nobody has claimed this yet.

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

Description

Information:

  • Prism version: all
  • Environment: all with a DOM

Description
Prism's CSS selector for code blocks works on detecting a language-xxxx class, but that detection has false positives because it works on substrings.

This likely also affects plugins that add to the selector string.

Example
copy-language-python is detected as a language-xxxx class. See #3363.

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

Open components/prism-core.js at the linked selector code and compare its matching behavior with the copy-language-python example. Adjust the selector so only a complete language-xxxx class is detected, including when plugins extend the selector string, and verify that the false positive described in #3363 no longer occurs.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.