PrismJS / PrismJS/prism

Compatibility with XAML WPF C# WebBrowser control - problem and solution

Open
#3,692 0 comments 0 reactions 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

  • Prism version: 1.29
  • Plugins: none
  • Environment:
    <WebBrowser> control used by .NET XAML WPF C# (Internet Explorer). Compatibility meta tags were set to:

Problem:

prism.js code is crashing with "Syntax error in regular expression" on line 209:
element.className = element.className.replace(RegExp(lang, 'gi'), '');

Solution:

Replace line 24:
From: var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
To: var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/ig;

Replace line 209:
From: element.className = element.className.replace(RegExp(lang, 'gi'), '');
To: element.className = element.className.replace(lang, '');

This should work in Internet Explorer engine still used by modern C# controls as well as other browsers.

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 inspecting prism.js around lines 24 and 209, then reproduce the failure in the .NET XAML WPF WebBrowser control using its Internet Explorer engine. Check the reported regular-expression compatibility issue and verify the correction in the affected highlighting path across the stated browser environments.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.