@using Markdig
@using AngleSharp
@using Dpz.Core.Infrastructure
@model string
@{
var pipeline = new MarkdownPipelineBuilder().DisableHtml().Build();
var content = Markdown.ToHtml(Model,pipeline);
var context = BrowsingContext.New(Configuration.Default);
var html = await context.OpenAsync(x => x.Content(content));
var links = html.GetElementsByTagName("a");
links.ForEach(x =>
{
var href = x.GetAttribute("href");
if (href != null && !href.StartsWith("javascript", StringComparison.CurrentCultureIgnoreCase))
{
x.SetAttribute("target", "_blank");
}
});
}
@Html.Raw(html.Body?.InnerHtml)