This commit is contained in:
2026-07-18 15:21:20 -04:00
parent 6062d5b60c
commit 74f065e0f5
51 changed files with 634 additions and 285 deletions
+31 -8
View File
@@ -257,7 +257,8 @@
tableLines.Add(trimmedLine);
continue;
}
else if (inTable)
if (inTable)
{
RenderTable(builder, ref seq, tableLines);
tableLines.Clear();
@@ -272,13 +273,15 @@
builder.OpenElement(seq++, "ul");
inList = true;
}
var isCardListItem = trimmedLine.Contains("[[") && trimmedLine.Contains("]]");
builder.OpenElement(seq++, "li");
RenderInlines(builder, ref seq, trimmedLine[2..], true);
builder.CloseElement();
continue;
}
else if (inList)
if (inList)
{
builder.CloseElement(); // Close ul
inList = false;
@@ -339,6 +342,7 @@
RenderInlines(builder, ref seq, cell.Trim(), false);
builder.CloseElement();
}
builder.CloseElement();
builder.CloseElement();
startIdx = 2;
@@ -356,8 +360,10 @@
RenderInlines(builder, ref seq, cell.Trim(), false);
builder.CloseElement();
}
builder.CloseElement();
}
builder.CloseElement();
builder.CloseElement();
builder.CloseElement();
@@ -366,7 +372,7 @@
private void RenderInlines(RenderTreeBuilder builder, ref int seq, string text, bool renderAsImage)
{
var remaining = text;
while (!string.IsNullOrEmpty(remaining))
{
var boldMatch = Regex.Match(remaining, @"\*\*(.*?)\*\*");
@@ -375,11 +381,28 @@
var bestIdx = int.MaxValue;
Match? bestMatch = null;
int matchType = 0; // 1: bold, 2: italic, 3: card
var matchType = 0; // 1: bold, 2: italic, 3: card
if (boldMatch.Success && boldMatch.Index < bestIdx) { bestIdx = boldMatch.Index; bestMatch = boldMatch; matchType = 1; }
if (italicMatch.Success && italicMatch.Index < bestIdx) { bestIdx = italicMatch.Index; bestMatch = italicMatch; matchType = 2; }
if (cardMatch.Success && cardMatch.Index < bestIdx) { bestIdx = cardMatch.Index; bestMatch = cardMatch; matchType = 3; }
if (boldMatch.Success && boldMatch.Index < bestIdx)
{
bestIdx = boldMatch.Index;
bestMatch = boldMatch;
matchType = 1;
}
if (italicMatch.Success && italicMatch.Index < bestIdx)
{
bestIdx = italicMatch.Index;
bestMatch = italicMatch;
matchType = 2;
}
if (cardMatch.Success && cardMatch.Index < bestIdx)
{
bestIdx = cardMatch.Index;
bestMatch = cardMatch;
matchType = 3;
}
if (bestMatch != null)
{
@@ -387,7 +410,7 @@
builder.AddContent(seq++, remaining[..bestIdx]);
var innerText = bestMatch.Groups[1].Value;
if (matchType == 1) // Bold
{
builder.OpenElement(seq++, "strong");