Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested Razor blocks breaks formatting #19

Open
nwoolls opened this issue Feb 8, 2023 · 0 comments
Open

Nested Razor blocks breaks formatting #19

nwoolls opened this issue Feb 8, 2023 · 0 comments

Comments

@nwoolls
Copy link

nwoolls commented Feb 8, 2023

Hi there - first and foremost thanks for the grammar!

I am finding that nested blocks of Razor break the formatting. Specifically I am using the following to illustrate this:

<markdown>
    ```cshtml
    @@if (this)
    {
        <span>this</span>
        @@if (this)
        {
            <span>this</span>
        }
        else if (that)
        {
            <span>that</span>
        }
        else {
            <span>nope</span>
        }
    }
    else if (that)
    {
        <span>that</span>
        @@if (this)
        {
            <span>this</span>
        }
        else if (that)
        {
            <span>that</span>
        }
        else {
            <span>nope</span>
        }
    }
    else {
        <span>nope</span>
        @@if (this)
        {
            <span>this</span>
        }
        else if (that)
        {
            <span>that</span>
        }
        else {
            <span>nope</span>
        }
    }
    ```
</markdown>

This 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"><span class="hljs-keyword">this</span></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><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"><span class="hljs-keyword">this</span></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><span class="language-csharp">
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (that)
    {</span><span class="language-csharp">
        </span><span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span><span class="language-csharp">that</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><span class="language-csharp">
    <span class="hljs-keyword">else</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">nope</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>
}
else if (that)
{
    <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>that<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
    <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"><span class="hljs-keyword">this</span></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><span class="language-csharp">
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (that)
    {</span><span class="language-csharp">
        </span><span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span><span class="language-csharp">that</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><span class="language-csharp">
    <span class="hljs-keyword">else</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">nope</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>
}
else {
    <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>nope<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
    <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"><span class="hljs-keyword">this</span></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><span class="language-csharp">
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (that)
    {</span><span class="language-csharp">
        </span><span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span><span class="language-csharp">that</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><span class="language-csharp">
    <span class="hljs-keyword">else</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">nope</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>

Specifically, note the instances of e.g. }, else if (that), {, and else { that have no surrounding HTML tags.

This ends up rendering (with the GitHub Dark theme) as such:

Screenshot 2023-02-08 at 14-34-12 IDMWORKS MVC Template - Access Control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant