PrismJS / PrismJS/prism

[Enhancement] CSS elements, properties and URL values, and LESS @ rules

Open
#2,431 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Motivation

It seems that Prismjs does not have CSS element. CSS elements are white, but in the Dracula theme, it is purple.

Description

In reference to dracula/prism#11, I followed the Dracula's specific documentation. Imitating and mimicking the CSS syntax highlighting in VSCode, there are two differences between Prism's HTML and VSCode's HTML syntax highlightings. See the alternatives with solutions:

Alternatives

CSS elements

Using Dracula theme, compare CSS elements, entirely highlighted as white by the class .language-css in Prismjs, but in VSCode, it is different:

Dracula:

image

Prismjs:

image

Observation: The px should remain pink.

CSS properties

The property screen and is dominated by the class .language-css .token.atrule, and has different colours in Dracula and Prismjs themes.

Dracula:

image

Prismjs:

image

@ rules

Not just @main-color, the class .language-css .token.rule also takes control of @media which must remain purple. Observe that @media belongs to the class .language-css .token.atrule.

Dracula

image

Prismjs

image

I tried this CSS:

.language-css .token.rule:not(.atrule)
{
  color: var(--foreground);
}

CSS URL values

In Dracula, the values without quotation marks remain orange, but with quotation mark, they are highlighted as yellow. In Prismjs, both the values without and with quotation marks are dominated by the class .language-css .token.url. Also observe that parentheses ( and ) should remain purple if the regular expression finds url.

Dracula

image

Prismjs

image

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 by locating Prism's CSS grammar and inspecting the .language-css token classes described here. Verify that CSS elements, properties, @ rules, and quoted or unquoted URL values receive the intended distinctions, with parentheses handled as described; done when the highlighting matches the requested Dracula and VSCode behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript
Domain
tooling
Issue type
Feature
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.