PrismJS / PrismJS/prism

Make each HTML element for highlighting only span one line

Open
#3,446 0 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
I want to show an excerpt of the highlighted code. After processing and highlighting the complete code using Prism, I want to extract some lines from innerHTML.

Description
It seems like that works mostly, the one exception I currently found was block comments, where the whole block comment is wrapped by a span (in my case, its Python code, so the class is token triple-quoted-string string).

Alternatives
Maybe add an option to Prism.highlightElement where one can configure what lines to return?

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 tracing Prism.highlightElement and how highlighted Python block comments become spans in innerHTML, especially the token triple-quoted-string string class. Determine how line boundaries should be represented without breaking highlighting, and define completion as each highlighting span covering only one line while preserving the highlighted output.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.