highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.31k stars 3.52k forks source link

fix: C# raw string literals #4070

Closed jairbubbles closed 2 days ago

jairbubbles commented 3 days ago

Fix highlighting with nested double quotes. See https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/raw-string

I tweaked a bit the Regex and it seems to better handle the previous examples: https://regex101.com/r/16Vn7X/1

joshgoebel commented 2 days ago

Can you provide a failing test case? If I try both the old and new regex with the text you provided (at regex101) the results look identical to me - ie the existing regex works as-is. Am I missing something?

jairbubbles commented 2 days ago

Hi @joshgoebel, yeah you're right there's something fishy with my fix.

On the demo, we can see there's an issue, maybe it's not using the latest code?

https://highlightjs.org/demo#lang=csharp&v=1&theme=arta&code=dmFyIE11bHRpTGluZVF1b3RlcyA9ICIiIiIKIMsBIiIiUmF3IHN0cmluZyBsaXRlcmFscyIiIiBjYW4gc3RhcnQgYW5kIGVuZCB3aXRoIG1vcmUgdGhhbiB0aHJlZSBkb3VibGUtccZid2hlbiBuZWVkZWQu0GgiOwo%3D