C
C#•6mo ago
Thiago

Rendering a razor component from a raw string

I'm trying to render a <Equation/> from MathJaxBlazor in a raw string using MarkupString but it doesn't render the component, or anything but the raw HTML really. Anyone have any ideas on how to solve this or how I could render it in another way? Here's the source code for the page:
@page "/"
@using MathJaxBlazor

<h1>Hello, world!</h1>

@((MarkupString)content)

@code {
private string content =
""""
<h2> Hi ! </h2>
<p> This is a test </p>
<MathJaxBlazor.Equation Value="a^2 + b^2 = c^2" />
"""";
}
@page "/"
@using MathJaxBlazor

<h1>Hello, world!</h1>

@((MarkupString)content)

@code {
private string content =
""""
<h2> Hi ! </h2>
<p> This is a test </p>
<MathJaxBlazor.Equation Value="a^2 + b^2 = c^2" />
"""";
}
When running the code, the page looks like the image shows
No description
3 Replies
Thiago
Thiago•6mo ago
For clarification, it should look like this.
No description
Thiago
Thiago•6mo ago
Nevermind, solved it by adding a MathJaxSettings on top of the page and replacing the <Equation/> component with standard latex text 😅
333fred
333fred•6mo ago
We don't support raw strings yet in razor/blazor, results may vary