@*
This file is part of NKK.
NKK is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
NKK is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with NKK. If not, see .
*@
@using System.Text
@using Microsoft.PowerShell.MarkdownRender
@*
*@
@( (MarkupString)RenderHtml() )
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
[Parameter]
public String? Content { get; set; }
[Parameter]
public FileInfo? File { get; set; }
[Parameter]
public bool? UseTypographyStyle { get; set; } = true;
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary
? ExtraAttributes { get; set; }
private String RenderHtml() {
if (ChildContent != null && Content != null && File != null) {
throw new ArgumentException("Only one of Content, File, or ChildContent can be set.");
}
if (File != null) {
using StreamReader reader = new StreamReader(File.FullName, Encoding.UTF8);
Content = reader.ReadToEnd();
} else if (ChildContent != null) {
Content = ChildContent.RenderString();
}
return MarkdownConverter.Convert(Content ?? String.Empty, MarkdownConversionType.HTML, null).Html;
}
}