Cleanup
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user