Skip to content

Avoiding double highlighting #2384

@LeaVerou

Description

@LeaVerou

So, I run into a bit of an issue, and I was wondering what's the best way to handle this.

My (relevant) setup:

  • Both Prism Live and Prism included. Some <pre>s highlighted with Prism, some made editable with Prism Live (using <pre> and not <textarea> as source).
  • Keep Markup plugin

Both Prism and Prism Live run Prism on the <pre>s and since the Keep Markup plugin is included, the tokens from the first highlight stay for the second, so every token becomes nested (e.g. <span class="token keyword"><span class="token keyword">let</span></span>.

The thing is, none of these individually are doing anything wrong. All three scripts are doing their job, but interacting badly. I can't imagine a single case where the end result is desirable. This is not specific to Prism Live (which is an unreleased buggy script with little usage), but can occur with anything that includes their own Prism as a dependency and Prism is also included by something else or directly.

Should Prism throw away existing highlighting if present?
Should the Keep Markup plugin do it?
Should there be some sort of opt-in?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions