C
C#•11mo ago
Gax

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
Gax
GaxOP•11mo ago
For clarification, it should look like this.
No description
Gax
GaxOP•11mo ago
Nevermind, solved it by adding a MathJaxSettings on top of the page and replacing the <Equation/> component with standard latex text 😅
333fred
333fred•11mo ago
We don't support raw strings yet in razor/blazor, results may vary
Want results from more Discord servers?
Add your server