PrismJS / PrismJS/prism

What to do about JS extras in v2

Open
#3,542 2 comments 1 reaction 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

I removed JS extras in 6996dddf8985be2474416d1d77b32d8f1b985e84, and I'm not sure whether we want to migrate it in its current form.

The problem is that JS extras was a modify dependency, so it worked by directly modifying JS. This meant that JS extras was extremely brittle, as any change to JS would likely break JS extras. Prism v2 does not have modify dependencies (which is good), so JS Extras has to be implemented as an optional dependency of JS. This is difficult. JS extras makes very specific changes, so applying those changes in an optional dependency format creates about as much code complexity as just moving over all the advanced tokens to JS and removing JS extras. Another route would be a custom tokenizer, but this might conflict with JSX which also has a custom tokenizer.

So I'm not sure what to do here. To make the tests pass, I removed it for now. We can re-add it when we have a solution.

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 reviewing commit 6996dddf8985be2474416d1d77b32d8f1b985e84 and the existing JS extras behavior. Compare optional-dependency and custom-tokenizer approaches, including the interaction with JSX and advanced tokens. Done means agreeing on an implementation that restores JS extras without modify dependencies and makes the tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.