PrismJS / PrismJS/prism

More granular token types

Open
#2,850 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Motivation
This ties into #2849. There are a few token types that are missing right now and languages usually approximate. I.e. TOML has a date token type and all tokens have a number alias for coloring.

Description
A few new token types, I would like to suggest:

  • time (or date or date-time): A type for dates, times, and other time instances.
    We have a few languages that contain literals for dates and times. Right now, most of them use the number type.
  • character (or char): A type for character literals.
    Some languages support literals for string and characters (e.g. C/C++, C#, Java, Rust, Scheme). Themes should be able to give these literals a different color.
  • ip-address (or ip-addr or ip): A type for IPv4 and IPv6 addresses.
    Some languages support IP address literals.
  • attr-assign: A token used to assign an attribute value to an attribute name.
    Some people what to highlight the assignment operator of attributes differently (example).
  • doc: An alias for different types to indicate that a string or comment is used for documentation (e.g. JavaDoc comments or Python docstrings). E.g. <span class="token comment doc">/** foo */</span>.

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 reading the related issue #2849 and the attribute assignment example in components/prism-markup.js. Review how the proposed token types relate to existing aliases and decide which names and semantics are accepted; the work is done when the agreed token types are specified and implemented consistently.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.