alecthomas / chroma

A general purpose syntax highlighter in pure Go
MIT License
4.24k stars 378 forks source link

PHP string parsing #316

Open ghost opened 4 years ago

ghost commented 4 years ago

I have noticed that this:

$s1 = 'sunday';
echo "${s1}\n";

produces different highlighting from this:

$s1 = 'sunday';
# github.com parser recognizes the variable, chroma only sees a string literal
echo "$s1\n";
alecthomas commented 4 years ago

Okay, without me having to go and reproduce this, what exactly is the issue?

ghost commented 4 years ago

@alecthomas for the last line of the last example, Chroma does this:

<span style="color:#e6db74">"</span>
<span style="color:#e6db74">$s1\n</span>
<span style="color:#e6db74">"</span>

compare with GitHub highlighter which does this:

<span class="pl-pds">"</span>
<span class="pl-smi">$s1</span>
<span class="pl-cce">\n</span>
<span class="pl-pds">"</span>

GitHub highlighter recognized that a variable is inside the string.