mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-06 04:29:07 +00:00
Thorsten Sommer
c84184e5d1
This is necessary due to issue https://github.com/MyNihongo/MudBlazor.Markdown/issues/247 I created a PR as well: https://github.com/MyNihongo/MudBlazor.Markdown/pull/246
26 lines
826 B
C#
26 lines
826 B
C#
using Markdig.Syntax;
|
|
|
|
namespace MudBlazor;
|
|
|
|
internal static class HtmlBlockEx
|
|
{
|
|
public static bool TryGetDetails(this HtmlBlock @this, out HtmlDetailsData htmlDetailsData)
|
|
{
|
|
htmlDetailsData = new HtmlDetailsData();
|
|
|
|
// Closing `>` for <details> is missing because there might be attributes for this tag
|
|
if (!@this.Lines.StartsAndEndsWith("<details", "</details>", out var range))
|
|
return false;
|
|
|
|
// Closing `>` for <summary> is missing because there might be attributes for this tag
|
|
var summaryEndIndex = @this.Lines.TryGetContent("<summary", "</summary>", range.Start, out var headerContent);
|
|
if (summaryEndIndex.Line == -1)
|
|
return false;
|
|
|
|
var dataContent = @this.Lines.GetContent(summaryEndIndex, range.End);
|
|
|
|
htmlDetailsData = new HtmlDetailsData(headerContent, dataContent);
|
|
return true;
|
|
}
|
|
}
|