highlightjs-cshtml-razor icon indicating copy to clipboard operation
highlightjs-cshtml-razor copied to clipboard

C# keywords highlighted in HTML nested in Razor blocks

Open nwoolls opened this issue 2 years ago • 0 comments

Again, thanks very much for the grammar!

It seems like C# keywords are being highlighted when they are found in HTML that is nested inside of Razor blocks.

For instance, the following source:

<markdown>
    ```cshtml
    @@if (this)
    {
        <span>Lorem is ipsum as dolor not sit this amet, for consectetur in adipiscing while elit.</span>
    }
    ```
</markdown>

Results in the following HTML:

<code class="language-cshtml hljs language-cshtml-razor"><span class="hljs-built_in">@</span><span class="language-csharp"><span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>)
</span><span class="hljs-built_in">{</span><span class="language-csharp">
    </span><span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span><span class="language-csharp">Lorem <span class="hljs-keyword">is</span> ipsum <span class="hljs-keyword">as</span> dolor <span class="hljs-keyword">not</span> sit <span class="hljs-keyword">this</span> amet, <span class="hljs-keyword">for</span> consectetur <span class="hljs-keyword">in</span> adipiscing <span class="hljs-keyword">while</span> elit.</span><span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span><span class="language-csharp">
</span><span class="hljs-built_in">}</span>
</code>

This ends up looking like the following (with the GitHub Dark theme):

Screen Shot 2023-02-08 at 2 43 42 PM

nwoolls avatar Feb 08 '23 19:02 nwoolls