I have a simple string variable that contains a portion of HTML inside. For example:
string contents = "<div><p>Hi how are you. <a href="#">Click here</a> if you want to know more";
I want to include this HTML in page:
<div class="description">
@contents
</div>
However, it messes up the rest of the page because of unclosed tags.
Is there a function (or a helper) that reads and formats the HTML inside for example, to complete the HTML without errors:
@Html.DisplayProperHTML(contents)
This will render as:
<div><p>Hi how are you. <a href="#">Click here</a> if you want to know more</p></div>