Upgraded MudBlazor, ReverseMarkdown, and System.CommandLine (#1236)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-26 11:16:27 +01:00
1 parent 506c06fbfc
commit 9ebfce3855
21 files changed
+506 -96

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.15" /> <PackageReference Include="System.CommandLine" Version="3.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -6,9 +6,10 @@ namespace AIStudio.Chat;
/// nothing but a formula, see LatexFormula. /// nothing but a formula, see LatexFormula.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// MudMarkdown shows a formula as it is, and MathJax typesets only what the chat hands it as a /// MudMarkdown typesets a formula within a line, between single $, by itself, but shows a formula block
/// formula block. A formula therefore has to leave the Markdown around it. Inside a code block, $$ is /// as it is, and MathJax typesets only what the chat hands it as a formula block. A formula block
/// code, not a formula, and a formula block the model never closed leaves the whole text as Markdown. /// therefore has to leave the Markdown around it. Inside a code block, $$ is code, not a formula, and a
/// formula block the model never closed leaves the whole text as Markdown.
/// </remarks> /// </remarks>
internal static class MarkdownRenderPlanner internal static class MarkdownRenderPlanner
{ {
@@ -51,11 +51,11 @@ public sealed class ExportableMarkdown : HighlightedMarkdown
#region Overrides of HighlightedMarkdown #region Overrides of HighlightedMarkdown
/// <inheritdoc /> /// <inheritdoc />
protected override void RenderCodeBlock(in RenderTreeBuilder builder, ref int elementIndex, in Markdig.Syntax.CodeBlock code, in string? info) protected override void RenderCodeBlock(in RenderTreeBuilder builder, ref int elementIndex, in Markdig.Syntax.CodeBlock code, in string? info, Typo typo)
{ {
if (this.CodeBlockActions is null || FileAt(this.Files, this.ValueStart + code.Span.Start) is not { } file) if (this.CodeBlockActions is null || FileAt(this.Files, this.ValueStart + code.Span.Start) is not { } file)
{ {
base.RenderCodeBlock(builder, ref elementIndex, code, info); base.RenderCodeBlock(builder, ref elementIndex, code, info, typo);
return; return;
} }
@@ -65,7 +65,7 @@ public sealed class ExportableMarkdown : HighlightedMarkdown
// //
builder.OpenElement(0, "div"); builder.OpenElement(0, "div");
builder.AddAttribute(1, "class", "code-block-with-actions"); builder.AddAttribute(1, "class", "code-block-with-actions");
base.RenderCodeBlock(builder, ref elementIndex, code, info); base.RenderCodeBlock(builder, ref elementIndex, code, info, typo);
builder.OpenElement(2, "div"); builder.OpenElement(2, "div");
builder.AddAttribute(3, "class", "code-block-actions"); builder.AddAttribute(3, "class", "code-block-actions");
@@ -11,8 +11,9 @@ namespace AIStudio.Components;
/// same classes, the same colors of the theme, and the same copy button. /// same classes, the same colors of the theme, and the same copy button.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Its parameters are strings only. Blazor then renders it again only when the code or the language /// Its parameters are strings and an enum only. Blazor then renders it again only when the code, the
/// change, so while an answer streams in, only the block which grows is highlighted again. /// language, or the typography change, so while an answer streams in, only the block which grows is
/// highlighted again.
/// </remarks> /// </remarks>
public sealed class HighlightedCodeBlock : ComponentBase public sealed class HighlightedCodeBlock : ComponentBase
{ {
@@ -28,6 +29,12 @@ public sealed class HighlightedCodeBlock : ComponentBase
[Parameter] [Parameter]
public string Language { get; set; } = string.Empty; public string Language { get; set; } = string.Empty;
/// <summary>
/// The typography of the block: that of the body text, which MudMarkdown gives the code blocks it renders itself.
/// </summary>
[Parameter]
public Typo Typo { get; set; }
#region Overrides of ComponentBase #region Overrides of ComponentBase
protected override void BuildRenderTree(RenderTreeBuilder builder) protected override void BuildRenderTree(RenderTreeBuilder builder)
@@ -39,12 +46,9 @@ public sealed class HighlightedCodeBlock : ComponentBase
builder.AddComponentParameter(3, nameof(CodeBlockCopyButton.Text), this.Code); builder.AddComponentParameter(3, nameof(CodeBlockCopyButton.Text), this.Code);
builder.CloseComponent(); builder.CloseComponent();
//
// MudMarkdown leaves the typography of its code blocks at the default value, and so do we:
//
builder.OpenComponent<MudText>(4); builder.OpenComponent<MudText>(4);
builder.AddComponentParameter(5, nameof(MudText.HtmlTag), "pre"); builder.AddComponentParameter(5, nameof(MudText.HtmlTag), "pre");
builder.AddComponentParameter(6, nameof(MudText.Typo), default(Typo)); builder.AddComponentParameter(6, nameof(MudText.Typo), this.Typo);
builder.AddComponentParameter(7, nameof(MudText.ChildContent), (RenderFragment)this.RenderCode); builder.AddComponentParameter(7, nameof(MudText.ChildContent), (RenderFragment)this.RenderCode);
builder.CloseComponent(); builder.CloseComponent();
@@ -27,7 +27,7 @@ public class HighlightedMarkdown : MudMarkdown
#region Overrides of MudMarkdown #region Overrides of MudMarkdown
/// <inheritdoc /> /// <inheritdoc />
protected override void RenderCodeBlock(in RenderTreeBuilder builder, ref int elementIndex, in Markdig.Syntax.CodeBlock code, in string? info) protected override void RenderCodeBlock(in RenderTreeBuilder builder, ref int elementIndex, in Markdig.Syntax.CodeBlock code, in string? info, Typo typo)
{ {
var text = TextOf(code); var text = TextOf(code);
var language = CodeLanguageDetector.FenceLanguageOf(info, text); var language = CodeLanguageDetector.FenceLanguageOf(info, text);
@@ -37,7 +37,7 @@ public class HighlightedMarkdown : MudMarkdown
// The copy button of the library confirms in the language of the app, as ours does: // The copy button of the library confirms in the language of the app, as ours does:
// //
this.Styling.CodeBlock.CopyButtonText = CodeBlockCopyButton.ConfirmationText; this.Styling.CodeBlock.CopyButtonText = CodeBlockCopyButton.ConfirmationText;
base.RenderCodeBlock(builder, ref elementIndex, code, language); base.RenderCodeBlock(builder, ref elementIndex, code, language, typo);
return; return;
} }
@@ -48,6 +48,7 @@ public class HighlightedMarkdown : MudMarkdown
builder.OpenComponent<HighlightedCodeBlock>(0); builder.OpenComponent<HighlightedCodeBlock>(0);
builder.AddComponentParameter(1, nameof(HighlightedCodeBlock.Code), text); builder.AddComponentParameter(1, nameof(HighlightedCodeBlock.Code), text);
builder.AddComponentParameter(2, nameof(HighlightedCodeBlock.Language), language); builder.AddComponentParameter(2, nameof(HighlightedCodeBlock.Language), language);
builder.AddComponentParameter(3, nameof(HighlightedCodeBlock.Typo), typo);
builder.CloseComponent(); builder.CloseComponent();
} }
@@ -100,7 +100,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AngouriMath" Version="2.8.0" /> <PackageReference Include="AngouriMath" Version="2.8.0" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="9.2.0" /> <PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="9.14.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.5.1" /> <PackageReference Include="DocumentFormat.OpenXml" Version="3.5.1" />
<PackageReference Include="HtmlAgilityPack" Version="1.12.4" /> <PackageReference Include="HtmlAgilityPack" Version="1.12.4" />
<PackageReference Include="MailKit" Version="5.0.0" /> <PackageReference Include="MailKit" Version="5.0.0" />
@@ -113,9 +113,9 @@
WebRootFiles finds neither the changelogs nor the ERI specifications in any build. WebRootFiles finds neither the changelogs nor the ERI specifications in any build.
--> -->
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="10.0.15" /> <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="10.0.15" />
<PackageReference Include="MudBlazor" Version="9.12.0" /> <PackageReference Include="MudBlazor" Version="9.14.0" />
<PackageReference Include="MudBlazor.Markdown" Version="9.10.0" /> <PackageReference Include="MudBlazor.Markdown" Version="9.12.0" />
<PackageReference Include="ReverseMarkdown" Version="5.0.0" /> <PackageReference Include="ReverseMarkdown" Version="6.3.0" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="3.0.5" /> <PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="3.0.5" />
<PackageReference Include="LuaCSharp" Version="0.5.8" /> <PackageReference Include="LuaCSharp" Version="0.5.8" />
</ItemGroup> </ItemGroup>
+94 -39
View File
@@ -1,8 +1,9 @@
using System.Collections.Concurrent; using System.Collections.Frozen;
using System.Net; using System.Net;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.Sockets; using System.Net.Sockets;
using AIStudio.Tools.Web; using AIStudio.Tools.Web;
using AngleSharp.Dom;
using HtmlAgilityPack; using HtmlAgilityPack;
using ReverseMarkdown; using ReverseMarkdown;
@@ -15,39 +16,39 @@ public sealed class HTMLParser
private const int DEFAULT_MAX_RESPONSE_BYTES = 5 * 1024 * 1024; private const int DEFAULT_MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
/// <summary> /// <summary>
/// The fixed configuration every HTML to Markdown conversion runs with. /// The elements which ReverseMarkdown reads as inline elements around their content, such as a link.
/// </summary> /// </summary>
/// <remarks> private static readonly FrozenSet<string> INLINE_ELEMENTS = new[] { "a", "abbr", "b", "cite", "del", "em", "i", "s", "span", "strike", "strong", "sub", "sup" }.ToFrozenSet(StringComparer.OrdinalIgnoreCase);
/// This one is shared, because it is only ever read: a configuration holds no counters and no
/// collections which get written to. The converters reading it are not shared, see the pool
/// below.
/// </remarks>
private static readonly Config MARKDOWN_CONFIG = new()
{
UnknownTags = Config.UnknownTagsOption.Bypass,
RemoveComments = true,
SmartHrefHandling = true,
};
/// <summary> /// <summary>
/// The converters not currently in use, kept so that the reflection in their constructor does /// The elements which ReverseMarkdown reads as blocks of their own, or as containers of blocks. Tables and pre are
/// not run for every page. /// left out: their content keeps its own structure inside an inline element as well.
/// </summary>
private static readonly FrozenSet<string> BLOCK_ELEMENTS = new[]
{
"article", "aside", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "footer", "h1", "h2", "h3", "h4", "h5", "h6",
"header", "hr", "li", "main", "nav", "ol", "p", "section", "ul",
}.ToFrozenSet(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// The one converter every HTML to Markdown conversion runs through.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// One converter per conversion rather than one for all of them: a converter tracks the /// Since version 6, ReverseMarkdown keeps the state of a conversion inside that conversion and
/// ancestors of the node it is at in state of its own, updates that state at every single node, /// documents its converter as safe for concurrent use. A web search converts up to four pages at
/// and does so without any synchronization. A web search converts up to four pages at the same /// the same time, and HTMLParserConcurrencyTests checks that they stay apart. Up to version 5, a
/// time, which let those conversions tear each other's ancestor lists apart — sometimes loudly, /// converter tracked the ancestors of the node it was at in state of its own, and conversions
/// as an index outside the bounds of an array, and sometimes quietly, as a list indented by the /// sharing one tore each other's lists apart, which is why there used to be a pool of them.<br/><br/>
/// depth another page happened to be at.<br/><br/> /// Built from a configuration alone, the converter takes its built-in readers and needs no
/// Which converter gets which page does not matter, so the pool needs no key: that ancestor /// reflection, so a trimmed build keeps everything it uses, see MarkdownChecks of the trim smoke test.
/// state is entered and left in pairs around every node, which leaves it empty once a
/// conversion returns. Nothing of a page outlives its own conversion. A key would, in fact, do
/// harm — two conversions of the same page at the same time would share one converter again.
/// <br/><br/>
/// The pool holds no more converters than are ever converting at once, which is a handful.
/// </remarks> /// </remarks>
private static readonly ConcurrentBag<Converter> CONVERTER_POOL = []; private static readonly Converter CONVERTER = new(new Config
{
Tags = { Unknown = Config.UnknownTagsOption.Bypass },
Formatting = { RemoveComments = true },
Links = { SmartHref = true },
Preprocess = { { "Unwrap the blocks inside inline elements", UnwrapBlocksInsideInlineElements } },
});
/// <summary> /// <summary>
/// Loads a web page. /// Loads a web page.
@@ -269,21 +270,75 @@ public sealed class HTMLParser
/// </summary> /// </summary>
/// <param name="html">The HTML content to parse.</param> /// <param name="html">The HTML content to parse.</param>
/// <returns>The converted Markdown content.</returns> /// <returns>The converted Markdown content.</returns>
public static string ParseToMarkdown(string html) => CONVERTER.Convert(html);
/// <summary>
/// Replaces every block inside an inline element by its content, with a space before and after it.
/// </summary>
/// <param name="root">The document element of the HTML, as ReverseMarkdown parsed it.</param>
/// <remarks> /// <remarks>
/// The converter returns to the pool only after it converted without throwing, and that is /// Compatibility shim, see documentation/compatibility-shims/2026-11-reversemarkdown-blocks-in-inline-elements.md;
/// deliberately not done in a finally block: a conversion which throws leaves the ancestors it /// remove it once ReverseMarkdown separates such blocks itself, see
/// entered behind, because the library does not unwind them itself. Such a converter would /// https://github.com/mysticmind/reversemarkdown-net/issues/440.<br/><br/>
/// count those ancestors into every page it is handed afterwards, so it is left to the garbage /// Many pages wrap a whole teaser in a link: a heading, a line of metadata, and a summary, each a block of its own.
/// collector rather than passed on. /// A link holds no blocks in Markdown, so ReverseMarkdown 6 writes their texts one after another into the text of
/// the link, without anything in between, e.g., "Java77.721 Abrufeheise security". Spaces next to such blocks alone
/// were not enough: a first attempt which only added them still left most teasers on the start page of a news site
/// glued together. Hence, each block gives way to its content, which the library then reads as part of the inline
/// element, spaces included. The result is what the library makes of such a block anyway, only with the words
/// apart. Where whitespace is there already, nothing is added, and inside pre the text stays exactly as it is.<br/><br/>
/// The blocks are taken from the outside in, so an inner block sees the neighbors it got when its outer block gave
/// way. Every conversion parses a document of its own, so this step changes nothing which another thread could see.
/// </remarks> /// </remarks>
public static string ParseToMarkdown(string html) private static void UnwrapBlocksInsideInlineElements(IElement root)
{ {
if (!CONVERTER_POOL.TryTake(out var converter)) var blocks = root.QuerySelectorAll("*").Where(IsBlockInsideInlineElement).ToList();
converter = new Converter(MARKDOWN_CONFIG); foreach (var block in blocks)
{
if (block.Parent is not { } parent)
continue;
var markdown = converter.Convert(html); if (NeedsSeparator(block.PreviousSibling, atItsEnd: true))
parent.InsertBefore(block.Owner!.CreateTextNode(" "), block);
CONVERTER_POOL.Add(converter); if (NeedsSeparator(block.NextSibling, atItsEnd: false))
return markdown; parent.InsertBefore(block.Owner!.CreateTextNode(" "), block.NextSibling);
foreach (var child in block.ChildNodes.ToArray())
parent.InsertBefore(child, block);
block.Remove();
}
} }
private static bool IsBlockInsideInlineElement(IElement element)
{
if (!BLOCK_ELEMENTS.Contains(element.LocalName))
return false;
var insideInlineElement = false;
for (var ancestor = element.ParentElement; ancestor is not null; ancestor = ancestor.ParentElement)
{
if (ancestor.LocalName.Equals("pre", StringComparison.OrdinalIgnoreCase))
return false;
if (INLINE_ELEMENTS.Contains(ancestor.LocalName))
insideInlineElement = true;
}
return insideInlineElement;
}
/// <summary>
/// Whether the node next to a block runs into the block without whitespace in between.
/// </summary>
/// <param name="neighbor">The node right before or after the block, if any.</param>
/// <param name="atItsEnd">True when the neighbor comes before the block, so its last character touches the block.</param>
private static bool NeedsSeparator(INode? neighbor, bool atItsEnd) => neighbor switch
{
null => false,
IText { Data.Length: 0 } => false,
IText text => !char.IsWhiteSpace(atItsEnd ? text.Data[^1] : text.Data[0]),
_ => true,
};
} }
+23 -18
View File
@@ -16,11 +16,11 @@
}, },
"CodeBeam.MudBlazor.Extensions": { "CodeBeam.MudBlazor.Extensions": {
"type": "Direct", "type": "Direct",
"requested": "[9.2.0, )", "requested": "[9.14.0, )",
"resolved": "9.2.0", "resolved": "9.14.0",
"contentHash": "oA6TtFHh8uSA9Rk06aC9Bv9mvDiCfz5jI2QVYY2oogt5dZr2sHLHFdx3Z2shvn1i0gsTC35OjruKJJpWXPBcHA==", "contentHash": "Xe95ljYZI6NQZejyUIoGn0nl7Fo9kSZRPjGWHPVTUS+pZ0/RBdUq3dmXXfO82VjQ3eCJLqIJwcBrnzCQxjAHUA==",
"dependencies": { "dependencies": {
"MudBlazor": "9.0.0" "MudBlazor": "9.14.0"
} }
}, },
"DocumentFormat.OpenXml": { "DocumentFormat.OpenXml": {
@@ -98,27 +98,27 @@
}, },
"MudBlazor": { "MudBlazor": {
"type": "Direct", "type": "Direct",
"requested": "[9.12.0, )", "requested": "[9.14.0, )",
"resolved": "9.12.0", "resolved": "9.14.0",
"contentHash": "T6PQUCJe60UTSy3u1F8R2nuC06Cox6WEhon5GA2/AZNVI1WstlPSJZdGPyp6pHFpWdjPpla65piLpyJsbW+1rA==" "contentHash": "VmMM/u4upqpc0lJoXmo30Zj1d/Zq3BjdS11+q/eB/+p20pV1WXbLS0C17WbV4xqLM1i9Kpco6emt6M4s2R/BUA=="
}, },
"MudBlazor.Markdown": { "MudBlazor.Markdown": {
"type": "Direct", "type": "Direct",
"requested": "[9.10.0, )", "requested": "[9.12.0, )",
"resolved": "9.10.0", "resolved": "9.12.0",
"contentHash": "/uO8FrwS7NANxw6tI5F1fnHTD9r1g/1Xn5SBF2s2jdr6oS4CCnIGC8HSip6qNR/mzZaEx0Ioc0s7abYcMM50Wg==", "contentHash": "oQH8sU4zFK6M4zBO0WemK0L5ZbV7oDhX4kmyPg6w91molrl+F3rjzfYYJie0tvQB8PfxijD/B1T2855z+2d/xQ==",
"dependencies": { "dependencies": {
"Markdig": "1.4.0", "Markdig": "1.5.1",
"MudBlazor": "9.10.0" "MudBlazor": "9.12.0"
} }
}, },
"ReverseMarkdown": { "ReverseMarkdown": {
"type": "Direct", "type": "Direct",
"requested": "[5.0.0, )", "requested": "[6.3.0, )",
"resolved": "5.0.0", "resolved": "6.3.0",
"contentHash": "Zw7ODMO/P8b4ua9qFdsmZPkPmYGCcSfwhKo8+81PCS0e6P21c9sOlYwVJ3MCEWZAGW+CXJBdF3FKtXKWZWzFTg==", "contentHash": "h2GwfOpLAkONJa3ARH4VnhrJro7XcqTmI1z0d6LzXVto8Qm/8cmUO3cBm7nkN48rQfSPi2NpEPBKuPzSZr1LMg==",
"dependencies": { "dependencies": {
"HtmlAgilityPack": "1.12.4" "AngleSharp": "1.5.2"
} }
}, },
"SQLitePCLRaw.bundle_e_sqlite3": { "SQLitePCLRaw.bundle_e_sqlite3": {
@@ -131,6 +131,11 @@
"SQLitePCLRaw.config.e_sqlite3": "3.0.5" "SQLitePCLRaw.config.e_sqlite3": "3.0.5"
} }
}, },
"AngleSharp": {
"type": "Transitive",
"resolved": "1.5.2",
"contentHash": "LVZ7rrr6GHbhERhTgVDarVygl1e6KwE96pronA90LBOMacDhxR4lB+xYLjn/vlnUu+xbOB2RM9fuCPEx5bdyWA=="
},
"Antlr4.Runtime.Standard": { "Antlr4.Runtime.Standard": {
"type": "Transitive", "type": "Transitive",
"resolved": "4.13.1", "resolved": "4.13.1",
@@ -166,8 +171,8 @@
}, },
"Markdig": { "Markdig": {
"type": "Transitive", "type": "Transitive",
"resolved": "1.4.0", "resolved": "1.5.1",
"contentHash": "lLhaiI/mNDTNzgLqnmknhf4LjgTqOAyjx5+GNz0X3AxYMxUhmFppF2WVMdER+SDqwhE5wUF1pzs/cuLwFxs7xA==" "contentHash": "NtHwU5t5yKr6Gnylhs8/hlR0mOAftTFQURDz2ID8bkunxps1neOzKw0dYKKlwNuwiYIGLHjJTXK91f809Ko1ww=="
}, },
"Microsoft.EntityFrameworkCore": { "Microsoft.EntityFrameworkCore": {
"type": "Transitive", "type": "Transitive",
+2 -2
View File
@@ -355,7 +355,7 @@ window.localShortcut = {
} }
// What floats above the page without ever being a drop target. Two of these take part in hit testing as // What floats above the page without ever being a drop target. Two of these take part in hit testing as
// MudBlazor 9.12 stands: an open .mud-popover -- a closed one already declines pointer events through // MudBlazor 9.14 stands: an open .mud-popover -- a closed one already declines pointer events through
// .mud-popover:not(.mud-popover-open) -- and .mud-snackbar, which asks for them explicitly with // .mud-popover:not(.mud-popover-open) -- and .mud-snackbar, which asks for them explicitly with
// pointer-events: auto even though its container declines them, and snackbars appear constantly in this // pointer-events: auto even though its container declines them, and snackbars appear constantly in this
// app. Without this list, a drag would be answered by whatever happens to float on screen rather than by // app. Without this list, a drag would be answered by whatever happens to float on screen rather than by
@@ -368,7 +368,7 @@ const skippedDropOverlays = '.mud-popover, .mud-tooltip, .mud-snackbar, #mud-sna
// The drop zones of the app, addressed by the cursor position of a native drag and drop event. // The drop zones of the app, addressed by the cursor position of a native drag and drop event.
// //
// The arbitration between overlapping zones is left to the browser, and it can be: MudBlazor 9.12 gives // The arbitration between overlapping zones is left to the browser, and it can be: MudBlazor 9.14 gives
// neither .mud-dialog-container nor .mud-overlay a pointer-events: none. Both fill the viewport while a // neither .mud-dialog-container nor .mud-overlay a pointer-events: none. Both fill the viewport while a
// dialog is open, so a point beside the dialog box hits the container, and nothing there is a drop zone. A // dialog is open, so a point beside the dialog box hits the container, and nothing there is a drop zone. A
// drop, therefore, cannot reach through an open dialog into the page behind it -- the very thing the app // drop, therefore, cannot reach through an open dialog into the page behind it -- the very thing the app
@@ -53,6 +53,7 @@
- Fixed the Mathematics prototype getting stuck for a long time when it checked a result with a very large factorial or power. Meanwhile, no other calculation could run. - Fixed the Mathematics prototype getting stuck for a long time when it checked a result with a very large factorial or power. Meanwhile, no other calculation could run.
- Upgraded several libraries to improve security. - Upgraded several libraries to improve security.
- Upgraded Tauri to v2.12.7. - Upgraded Tauri to v2.12.7.
- Upgraded MudBlazor to v9.14.0.
- Upgraded PDFium to v158.0.8125.0 and Qdrant Edge to v0.9.0. - Upgraded PDFium to v158.0.8125.0 and Qdrant Edge to v0.9.0.
- Upgraded to Rust v1.100.0. - Upgraded to Rust v1.100.0.
- Upgraded to .NET v10.0.15. - Upgraded to .NET v10.0.15.
@@ -1 +1 @@
.hljs{color:var(--mud-markdown-codehightlight-text);background:var(--mud-markdown-codehightlight-background)}.hljs-subst{color:var(--mud-markdown-codehightlight-text)}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-template-tag,.hljs-template-variable,.hljs-variable.language_{color:var(--mud-markdown-codehightlight-keyword)}.hljs-type{color:var(--mud-markdown-codehightlight-type)}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:var(--mud-markdown-codehightlight-function)}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-symbol,.hljs-variable{color:var(--mud-markdown-codehightlight-number)}.hljs-string{color:var(--mud-markdown-codehightlight-string)}.hljs-code,.hljs-comment,.hljs-formula{color:var(--mud-markdown-codehightlight-comment)}.hljs-meta{color:var(--mud-markdown-codehightlight-meta)}.mud-markdown-body code:not(.hljs){background:var(--mud-palette-action-disabled-background);color:var(--mud-palette-text-primary)!important;padding:2.5px 7.5px;border-radius:5px}pre code.hljs{display:block!important;overflow-x:auto;padding:1em;width:100%}.mud-markdown-body .mud-markdown-code-highlight,.mud-markdown-body .mud-markdown-code-highlight-sticky{border:1px solid var(--mud-palette-lines-default);border-radius:var(--mud-default-borderradius)}.mud-markdown-body .mud-markdown-code-highlight{position:relative!important}.mud-markdown-body .mud-markdown-code-highlight:hover>.mud-markdown-code-highlight-copybtn{display:block!important}.mud-markdown-code-highlight-copybtn{position:absolute;display:none;top:0;right:0}.mud-markdown-body .mud-markdown-code-highlight-sticky{position:relative;display:flex;flex-direction:column}.mud-markdown-body .mud-markdown-code-highlight-sticky .mud-markdown-code-highlight-copybtn-sticky{position:sticky;align-self:flex-end;z-index:calc(var(--mud-zindex-appbar) - 2);top:calc(var(--mud-appbar-height) + 16px);margin-bottom:-3.5rem}.mud-markdown-body blockquote{border-left:.25em solid var(--mud-palette-text-disabled);color:var(--mud-palette-text-secondary);background-color:var(--mud-palette-table-hover);padding:.25em 1em;margin:.5em 0 1.25em}.mud-markdown-body blockquote p{margin-bottom:0!important}.mud-markdown-body .mud-table{margin:0 0 1.25em 0}.mud-markdown-body table p{margin-bottom:0!important}.mud-markdown-body .mud-link:hover{cursor:pointer!important}.mud-markdown-body ul{list-style-type:disc}.mud-markdown-body ol,.mud-markdown-body ul{padding-left:2em;margin-bottom:1.25em!important}.mud-markdown-body ul ul{list-style-type:circle;margin-bottom:0!important}.mud-markdown-body ul ul ul{list-style-type:square;margin-bottom:0!important}.mud-markdown-body li{display:list-item!important;text-align:-webkit-match-parent}.mud-markdown-body h1,.mud-markdown-body h2{border-bottom:1px solid var(--mud-palette-text-disabled);padding-bottom:.125em;margin-bottom:.4em}.mud-markdown-body h1,.mud-markdown-body h2,.mud-markdown-body h3,.mud-markdown-body h4,.mud-markdown-body h5,.mud-markdown-body h6{scroll-margin-top:5rem;margin-top:.25em;word-wrap:break-word;margin-bottom:.3em!important}.mud-markdown-body .mud-divider{margin:.5em 0;height:.25em}.mud-markdown-body p{margin-bottom:1.25em!important}.mud-markdown-body .mud-expand-panel p,.mud-markdown-body li p{margin-bottom:0!important}.mud-markdown-body p .mud-markdown-error{white-space:pre}.mud-markdown-body img{max-width:100%}.mud-markdown-toc{position:relative}.mud-markdown-toc-drawer{position:sticky;overflow:visible;z-index:calc(var(--mud-zindex-appbar) - 2);top:calc(var(--mud-appbar-height) + 16px);float:right}.mud-markdown-toc-drawer-content{width:0;overflow:hidden;opacity:0;visibility:collapse;transition:opacity .3s ease,visibility .3s ease}.mud-markdown-toc-drawer-content.open{width:var(--mud-drawer-width-right);opacity:1;visibility:visible}.mud-markdown-toc-content{margin-right:0;transition:margin-left .3s ease}.mud-markdown-toc-content.open{margin-right:calc(var(--mud-drawer-width-right) + 16px)}.mud-markdown-toc-btn-toggle{position:absolute;right:0;z-index:calc(var(--mud-zindex-appbar) - 1)}.mud-markdown-toc-nav-menu .mud-nav-link{padding:4px 16px!important}.mud-markdown-toc-nav-menu .mud-nav-link-h2 .mud-nav-link-text{margin-left:20px!important}.mud-markdown-toc-nav-menu .mud-nav-link-h3 .mud-nav-link-text{margin-left:28px!important}.mud-markdown-toc-nav-menu .mud-nav-item{border-left:4px solid var(--mud-palette-text-disabled)}.mud-markdown-toc-nav-menu .mud-nav-item.active{border-left-color:var(--mud-palette-primary)!important;color:var(--mud-palette-primary)!important}.mud-markdown-body .mud-expand-panel-header{padding:16px 12px!important}.mud-markdown-body .mud-expand-panel-content{padding:0 12px 16px 12px!important} .hljs{color:var(--mud-markdown-codehightlight-text);background:var(--mud-markdown-codehightlight-background)}.hljs-subst{color:var(--mud-markdown-codehightlight-text)}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-template-tag,.hljs-template-variable,.hljs-variable.language_{color:var(--mud-markdown-codehightlight-keyword)}.hljs-type{color:var(--mud-markdown-codehightlight-type)}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:var(--mud-markdown-codehightlight-function)}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-symbol,.hljs-variable{color:var(--mud-markdown-codehightlight-number)}.hljs-string{color:var(--mud-markdown-codehightlight-string)}.hljs-code,.hljs-comment,.hljs-formula{color:var(--mud-markdown-codehightlight-comment)}.hljs-meta{color:var(--mud-markdown-codehightlight-meta)}.mud-markdown-body code:not(.hljs){background:var(--mud-palette-action-disabled-background);color:var(--mud-palette-text-primary)!important;padding:2.5px 7.5px;border-radius:5px}pre code.hljs{display:block!important;overflow-x:auto;padding:1em;width:100%}.mud-markdown-body .mud-markdown-code-highlight,.mud-markdown-body .mud-markdown-code-highlight-sticky{border:1px solid var(--mud-palette-lines-default);border-radius:var(--mud-default-borderradius)}.mud-markdown-body .mud-markdown-code-highlight{position:relative!important}.mud-markdown-body .mud-markdown-code-highlight:hover>.mud-markdown-code-highlight-copybtn{display:block!important}.mud-markdown-code-highlight-copybtn{position:absolute;display:none;top:0;right:0}.mud-markdown-body .mud-markdown-code-highlight-sticky{position:relative;display:flex;flex-direction:column}.mud-markdown-body .mud-markdown-code-highlight-sticky .mud-markdown-code-highlight-copybtn-sticky{position:sticky;align-self:flex-end;z-index:calc(var(--mud-zindex-appbar) - 2);top:calc(var(--mud-appbar-height) + 16px);margin-bottom:-3.5rem}.mud-markdown-body blockquote{border-left:.25em solid var(--mud-palette-text-disabled);color:var(--mud-palette-text-secondary);background-color:var(--mud-palette-table-hover);padding:.25em 1em;margin:.5em 0 1.25em}.mud-markdown-body blockquote p{margin-bottom:0!important}.mud-math{font-family:"Latin Modern Math","STIX Two Math","Cambria Math","Times New Roman",serif;font-size:113.1%;font-style:normal;line-height:normal;white-space:nowrap}.mud-math-block{display:block;text-align:center;margin:.7em 0;padding:.3em 2px;overflow-x:auto;overflow-y:hidden}.mud-math-italic,.mud-math-mi{font-style:italic}.mud-math-op{margin:0 .278em}.mud-math-punct{margin-right:.2em}.mud-math-fn{margin-right:.15em}.mud-math-text{white-space:pre}.mud-math-error{color:red}.mud-math-space{display:inline-block}.mud-math-bold{font-weight:700}.mud-math-bold-italic{font-weight:700;font-style:italic}.mud-math-sans-serif{font-family:sans-serif}.mud-math-monospace{font-family:monospace}.mud-math-scripts{display:inline-flex;align-items:center}.mud-math-sub,.mud-math-subsup,.mud-math-sup{font-size:.7em;margin-left:.05em}.mud-math-sup{align-self:flex-start;margin-top:-.2em}.mud-math-sub{align-self:flex-end;margin-bottom:-.4em}.mud-math-subsup{display:inline-flex;flex-direction:column}.mud-math-subsup>.mud-math-sub,.mud-math-subsup>.mud-math-sup{font-size:1em;margin:0}.mud-math-limits{display:inline-flex;flex-direction:column;align-items:center;vertical-align:middle;margin:0 .15em}.mud-math-over,.mud-math-under{font-size:.7em}.mud-math-largeop{font-size:1.4em;line-height:1}.mud-math-block .mud-math-largeop{font-size:1.8em}.mud-math-frac{display:inline-flex;flex-direction:column;align-items:center;vertical-align:middle;margin:0 .1em}.mud-math:not(.mud-math-block) .mud-math-frac{font-size:.85em}.mud-math-den,.mud-math-num{padding:0 .15em;text-align:center}.mud-math-num{border-bottom:.06em solid currentColor}.mud-math-binom>.mud-math-num{border-bottom:none}.mud-math-sqrt{display:inline-flex;align-items:stretch}.mud-math-index{font-size:.6em;margin-right:-.4em;align-self:flex-start}.mud-math-surd{display:flex;align-items:flex-end;font-size:1.1em}.mud-math-radicand{border-top:.06em solid currentColor;padding:.1em .1em 0 .05em}.mud-math-fenced{display:inline-flex;align-items:center}.mud-math-fence{line-height:1}.mud-math-fenced:has(.mud-math-frac,.mud-math-limits)>.mud-math-fence{font-size:1.8em;font-weight:lighter}.mud-math-accent{position:relative;display:inline-block}.mud-math-accent-mark{position:absolute;top:-.45em;left:0;right:0;text-align:center;font-style:normal;line-height:1}.mud-math-index .mud-math-op,.mud-math-over .mud-math-op,.mud-math-sub .mud-math-op,.mud-math-subsup .mud-math-op,.mud-math-sup .mud-math-op,.mud-math-under .mud-math-op{margin:0 .1em}.mud-math-overline{border-top:.06em solid currentColor;padding-top:.05em}.mud-math-underline{border-bottom:.06em solid currentColor}.mud-math-brace{line-height:.8}.mud-markdown-body .mud-table{margin:0 0 1Line truncated
@@ -1 +1,125 @@
(()=>{function e(e){if(!e)return;const t=`#${e}`;if(window.location.hash!==t){const e=new URL(window.location.href);e.hash=t,history.replaceState(null,"",e)}}window.appendMathJaxScript=function(e){if(document.getElementById(e))return;const t=document.createElement("script");t.id=e,t.type="text/javascript",t.src="_content/MudBlazor.Markdown/MudBlazor.Markdown.MathJax.min.js",document.head.appendChild(t)},window.refreshMathJaxScript=function(){try{MathJax.typeset()}catch(e){}},window.MudBlazorMarkdown={scrollToElementId:function(t,n){const o=document.getElementById(t);o&&(e(t),n&&n.invokeMethodAsync("OnActiveElementChangedAsync",t),MudBlazorMarkdown.tableOfContents.scrollLock++,o.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"}),setTimeout((()=>{MudBlazorMarkdown.tableOfContents.scrollLock--,MudBlazorMarkdown.tableOfContents.scrollLock<0&&(MudBlazorMarkdown.tableOfContents.scrollLock=0)}),1e3))},copyTextToClipboard:async function(e){try{return await navigator.clipboard.writeText(e),!0}catch(e){return!1}},tableOfContents:{scrollLock:0,handleRefs:{},activeElementIds:{},startScrollSpy:function(t,n){if(!t)return;const o=document.getElementById(t);if(!o)return;const r=o.querySelectorAll(".mud-markdown-toc-heading");if(!r.length)return;const c=document.querySelector(".mud-appbar"),l=c?.getBoundingClientRect().height??0,a=()=>{if(MudBlazorMarkdown.tableOfContents.scrollLock>0)return;let o,c=-Number.MAX_VALUE;for(const e of r){const t=e.getBoundingClientRect().top-l;t>0||t<c||(c=t,o=e.id)}o||(o=r[0]?.id),o!==this.activeElementIds[t]&&(this.activeElementIds[t]=o,e(o),n.invokeMethodAsync("OnActiveElementChangedAsync",o))};this.handleRefs[t]=a,document.addEventListener("scroll",a,!0),document.addEventListener("resize",a,!0),a()},stopScrollSpy:function(e){if(!e)return;const t=this.handleRefs[e];t&&(document.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t,!0),delete this.handleRefs[e],delete this.activeElementIds[e])}}}})(); // MudBlazor.Markdown
window.MudBlazorMarkdown = {
scrollToElementId: function (elementId, dotNetReference) {
const element = document.getElementById(elementId);
if (!element) {
return;
}
trySetUrlHash(elementId);
if (dotNetReference) {
dotNetReference.invokeMethodAsync("OnActiveElementChangedAsync", elementId);
}
MudBlazorMarkdown.tableOfContents.scrollLock++;
element.scrollIntoView({
behavior: "smooth",
block: "start",
inline: "nearest"
});
// Not the best approach, but will do for now
setTimeout(() => {
MudBlazorMarkdown.tableOfContents.scrollLock--;
if (MudBlazorMarkdown.tableOfContents.scrollLock < 0) {
MudBlazorMarkdown.tableOfContents.scrollLock = 0;
}
}, 1000);
},
copyTextToClipboard: async function (text) {
try {
await navigator.clipboard.writeText(text);
return true;
} catch (e) {
return false;
}
},
tableOfContents: {
scrollLock: 0,
handleRefs: {},
activeElementIds: {},
startScrollSpy: function (elementId, dotNetReference) {
if (!elementId) {
return;
}
const element = document.getElementById(elementId);
if (!element) {
return;
}
const headingElements = element.querySelectorAll('.mud-markdown-toc-heading');
if (!headingElements.length) {
return;
}
const appBar = document.querySelector(".mud-appbar");
const pageTop = appBar?.getBoundingClientRect().height ?? 0;
const handler = () => {
if (MudBlazorMarkdown.tableOfContents.scrollLock > 0) {
return;
}
let maxVisibility = -Number.MAX_VALUE, maxVisibilityElementId = undefined;
for (const headingElement of headingElements) {
const rect = headingElement.getBoundingClientRect();
const relativeVisibility = rect.top - pageTop;
if (relativeVisibility > 0 || relativeVisibility < maxVisibility) {
continue;
}
maxVisibility = relativeVisibility;
maxVisibilityElementId = headingElement.id;
}
if (!maxVisibilityElementId) {
maxVisibilityElementId = headingElements[0]?.id;
}
const currentActiveElementId = this.activeElementIds[elementId];
if (maxVisibilityElementId !== currentActiveElementId) {
this.activeElementIds[elementId] = maxVisibilityElementId;
trySetUrlHash(maxVisibilityElementId);
dotNetReference.invokeMethodAsync("OnActiveElementChangedAsync", maxVisibilityElementId);
}
};
this.handleRefs[elementId] = handler;
document.addEventListener('scroll', handler, true);
document.addEventListener('resize', handler, true);
handler();
},
stopScrollSpy: function (identifier) {
if (!identifier) {
return;
}
const handler = this.handleRefs[identifier];
if (!handler) {
return;
}
document.removeEventListener('scroll', handler, true);
window.removeEventListener('resize', handler, true);
delete this.handleRefs[identifier];
delete this.activeElementIds[identifier];
},
},
};
function trySetUrlHash(elementId) {
if (!elementId) {
return;
}
const activeElementIdHref = `#${elementId}`;
if (window.location.hash !== activeElementIdHref) {
const url = new URL(window.location.href);
url.hash = activeElementIdHref;
history.replaceState(null, "", url);
}
}
@@ -2,4 +2,4 @@
* MudBlazor (https://mudblazor.com/) * MudBlazor (https://mudblazor.com/)
* Copyright (c) 2021 MudBlazor * Copyright (c) 2021 MudBlazor
* Licensed under MIT (https://github.com/MudBlazor/MudBlazor/blob/master/LICENSE) * Licensed under MIT (https://github.com/MudBlazor/MudBlazor/blob/master/LICENSE)
*/.mud-primary{background-color:var(--mud-palette-primary) !important}.mud-primary-text{color:var(--mud-palette-primary) !important;--mud-ripple-color: var(--mud-palette-primary) !important}.mud-primary-hover{background-color:var(--mud-palette-primary-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-primary-hover:hover{background-color:var(--mud-palette-primary-hover) !important}}.hover\:mud-primary-hover:focus-visible,.hover\:mud-primary-hover:active{background-color:var(--mud-palette-primary-hover) !important}.mud-border-primary{border-color:var(--mud-palette-primary) !important}.mud-theme-primary{color:var(--mud-palette-primary-text) !important;background-color:var(--mud-palette-primary) !important}.mud-secondary{background-color:var(--mud-palette-secondary) !important}.mud-secondary-text{color:var(--mud-palette-secondary) !important;--mud-ripple-color: var(--mud-palette-secondary) !important}.mud-secondary-hover{background-color:var(--mud-palette-secondary-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-secondary-hover:hover{background-color:var(--mud-palette-secondary-hover) !important}}.hover\:mud-secondary-hover:focus-visible,.hover\:mud-secondary-hover:active{background-color:var(--mud-palette-secondary-hover) !important}.mud-border-secondary{border-color:var(--mud-palette-secondary) !important}.mud-theme-secondary{color:var(--mud-palette-secondary-text) !important;background-color:var(--mud-palette-secondary) !important}.mud-tertiary{background-color:var(--mud-palette-tertiary) !important}.mud-tertiary-text{color:var(--mud-palette-tertiary) !important;--mud-ripple-color: var(--mud-palette-tertiary) !important}.mud-tertiary-hover{background-color:var(--mud-palette-tertiary-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-tertiary-hover:hover{background-color:var(--mud-palette-tertiary-hover) !important}}.hover\:mud-tertiary-hover:focus-visible,.hover\:mud-tertiary-hover:active{background-color:var(--mud-palette-tertiary-hover) !important}.mud-border-tertiary{border-color:var(--mud-palette-tertiary) !important}.mud-theme-tertiary{color:var(--mud-palette-tertiary-text) !important;background-color:var(--mud-palette-tertiary) !important}.mud-info{background-color:var(--mud-palette-info) !important}.mud-info-text{color:var(--mud-palette-info) !important;--mud-ripple-color: var(--mud-palette-info) !important}.mud-info-hover{background-color:var(--mud-palette-info-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-info-hover:hover{background-color:var(--mud-palette-info-hover) !important}}.hover\:mud-info-hover:focus-visible,.hover\:mud-info-hover:active{background-color:var(--mud-palette-info-hover) !important}.mud-border-info{border-color:var(--mud-palette-info) !important}.mud-theme-info{color:var(--mud-palette-info-text) !important;background-color:var(--mud-palette-info) !important}.mud-success{background-color:var(--mud-palette-success) !important}.mud-success-text{color:var(--mud-palette-success) !important;--mud-ripple-color: var(--mud-palette-success) !important}.mud-success-hover{background-color:var(--mud-palette-success-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-success-hover:hover{background-color:var(--mud-palette-success-hover) !important}}.hover\:mud-success-hover:focus-visible,.hover\:mud-success-hover:active{background-color:var(--mud-palette-success-hover) !important}.mud-border-success{border-color:var(--mud-palette-success) !important}.mud-theme-success{color:var(--mud-palette-success-text) !important;background-color:var(--mud-palette-success) !important}.mud-warning{background-color:var(--mud-palette-warning) !important}.mud-warning-text{color:var(--mud-palette-warning) !important;--mud-ripple-color: var(--mud-palette-warning) !important}.mud-warning-hover{background-color:var(--mud-palette-warning-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-warning-hover:hover{background-color:var(--mud-palette-warning-hover) !important}}.hover\:mud-warning-hover:focus-visible,.hover\:mud-warning-hover:active{background-color:var(--mud-palette-warning-hover) !important}.mud-border-warning{border-color:var(--mud-palette-warning) !important}.mud-theme-warning{color:var(--mud-palette-warning-text) !important;background-color:var(--mud-palette-warning) !important}.mud-error{background-color:var(--mud-palette-error) !important}.mud-error-text{color:var(--mud-palette-error) !important;--mud-ripple-color: var(--mud-palette-error) !important}.mud-error-hover{background-color:var(--mud-palette-error-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-error-hover:hover{background-color:var(--mud-palette-error-hover) !important}}.hover\:mud-error-hover:focus-visible,.hover\:mud-error-hover:active{background-color:var(--mud-palette-error-hover) !important}.mud-border-error{border-color:var(--mud-palette-error) !important}.mud-theme-error{color:var(--mud-paleLine truncated */.mud-primary{background-color:var(--mud-palette-primary) !important}.mud-primary-text{color:var(--mud-palette-primary) !important;--mud-ripple-color: var(--mud-palette-primary) !important}.mud-primary-hover{background-color:var(--mud-palette-primary-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-primary-hover:hover{background-color:var(--mud-palette-primary-hover) !important}}.hover\:mud-primary-hover:focus-visible,.hover\:mud-primary-hover:active{background-color:var(--mud-palette-primary-hover) !important}.mud-border-primary{border-color:var(--mud-palette-primary) !important}.mud-theme-primary{color:var(--mud-palette-primary-text) !important;background-color:var(--mud-palette-primary) !important}.mud-secondary{background-color:var(--mud-palette-secondary) !important}.mud-secondary-text{color:var(--mud-palette-secondary) !important;--mud-ripple-color: var(--mud-palette-secondary) !important}.mud-secondary-hover{background-color:var(--mud-palette-secondary-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-secondary-hover:hover{background-color:var(--mud-palette-secondary-hover) !important}}.hover\:mud-secondary-hover:focus-visible,.hover\:mud-secondary-hover:active{background-color:var(--mud-palette-secondary-hover) !important}.mud-border-secondary{border-color:var(--mud-palette-secondary) !important}.mud-theme-secondary{color:var(--mud-palette-secondary-text) !important;background-color:var(--mud-palette-secondary) !important}.mud-tertiary{background-color:var(--mud-palette-tertiary) !important}.mud-tertiary-text{color:var(--mud-palette-tertiary) !important;--mud-ripple-color: var(--mud-palette-tertiary) !important}.mud-tertiary-hover{background-color:var(--mud-palette-tertiary-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-tertiary-hover:hover{background-color:var(--mud-palette-tertiary-hover) !important}}.hover\:mud-tertiary-hover:focus-visible,.hover\:mud-tertiary-hover:active{background-color:var(--mud-palette-tertiary-hover) !important}.mud-border-tertiary{border-color:var(--mud-palette-tertiary) !important}.mud-theme-tertiary{color:var(--mud-palette-tertiary-text) !important;background-color:var(--mud-palette-tertiary) !important}.mud-info{background-color:var(--mud-palette-info) !important}.mud-info-text{color:var(--mud-palette-info) !important;--mud-ripple-color: var(--mud-palette-info) !important}.mud-info-hover{background-color:var(--mud-palette-info-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-info-hover:hover{background-color:var(--mud-palette-info-hover) !important}}.hover\:mud-info-hover:focus-visible,.hover\:mud-info-hover:active{background-color:var(--mud-palette-info-hover) !important}.mud-border-info{border-color:var(--mud-palette-info) !important}.mud-theme-info{color:var(--mud-palette-info-text) !important;background-color:var(--mud-palette-info) !important}.mud-success{background-color:var(--mud-palette-success) !important}.mud-success-text{color:var(--mud-palette-success) !important;--mud-ripple-color: var(--mud-palette-success) !important}.mud-success-hover{background-color:var(--mud-palette-success-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-success-hover:hover{background-color:var(--mud-palette-success-hover) !important}}.hover\:mud-success-hover:focus-visible,.hover\:mud-success-hover:active{background-color:var(--mud-palette-success-hover) !important}.mud-border-success{border-color:var(--mud-palette-success) !important}.mud-theme-success{color:var(--mud-palette-success-text) !important;background-color:var(--mud-palette-success) !important}.mud-warning{background-color:var(--mud-palette-warning) !important}.mud-warning-text{color:var(--mud-palette-warning) !important;--mud-ripple-color: var(--mud-palette-warning) !important}.mud-warning-hover{background-color:var(--mud-palette-warning-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-warning-hover:hover{background-color:var(--mud-palette-warning-hover) !important}}.hover\:mud-warning-hover:focus-visible,.hover\:mud-warning-hover:active{background-color:var(--mud-palette-warning-hover) !important}.mud-border-warning{border-color:var(--mud-palette-warning) !important}.mud-theme-warning{color:var(--mud-palette-warning-text) !important;background-color:var(--mud-palette-warning) !important}.mud-error{background-color:var(--mud-palette-error) !important}.mud-error-text{color:var(--mud-palette-error) !important;--mud-ripple-color: var(--mud-palette-error) !important}.mud-error-hover{background-color:var(--mud-palette-error-hover) !important}@media(hover: hover)and (pointer: fine){.hover\:mud-error-hover:hover{background-color:var(--mud-palette-error-hover) !important}}.hover\:mud-error-hover:focus-visible,.hover\:mud-error-hover:active{background-color:var(--mud-palette-error-hover) !important}.mud-border-error{border-color:var(--mud-palette-error) !important}.mud-theme-error{color:var(--mud-paleLine truncated
@@ -2,7 +2,7 @@
* MudBlazor (https://mudblazor.com/) * MudBlazor (https://mudblazor.com/)
* Copyright (c) 2021 MudBlazor * Copyright (c) 2021 MudBlazor
* Licensed under MIT (https://github.com/MudBlazor/MudBlazor/blob/master/LICENSE) * Licensed under MIT (https://github.com/MudBlazor/MudBlazor/blob/master/LICENSE)
*/window.mudDragAndDrop={initDropZone:(e)=>{let t=document.getElementById(e);t.addEventListener("dragover",(o)=>o.preventDefault()),t.addEventListener("dragstart",(o)=>o.dataTransfer.setData("",o.target.id))},makeDropZonesNotRelative:()=>{let e=Array.from(document.getElementsByClassName("mud-drop-item")).filter((o)=>o.getAttribute("index")=="-1");for(let o of e)o.style.position="static";let t=document.getElementsByClassName("mud-drop-zone");for(let o of t)o.style.position="unset"},getDropZoneIdentifierOnPosition:(e,t)=>{let n=document.elementsFromPoint(e,t).find((i)=>i.classList.contains("mud-drop-zone"));if(n)return n.getAttribute("identifier")||"";return""},getDropIndexOnPosition:(e,t,o)=>{let i=document.elementsFromPoint(e,t).find((r)=>r.classList.contains("mud-drop-item")&&r.id!=o);if(i)return i.getAttribute("index")||"";return""},makeDropZonesRelative:()=>{let e=document.getElementsByClassName("mud-drop-zone");for(let o of e)o.style.position="relative";let t=Array.from(document.getElementsByClassName("mud-drop-item")).filter((o)=>o.getAttribute("index")=="-1");for(let o of t)o.style.position="relative"},moveItemByDifference:(e,t,o)=>{let n=document.getElementById(e),i=(Number.parseFloat(n.getAttribute("data-x"))||0)+t,r=(Number.parseFloat(n.getAttribute("data-y"))||0)+o;n.style.webkitTransform=n.style.transform="translate3d("+i+"px, "+r+"px, 10px)",n.setAttribute("data-x",i),n.setAttribute("data-y",r)},resetItem:(e)=>{let t=document.getElementById(e);if(t)t.style.webkitTransform=t.style.transform="",t.setAttribute("data-x",0),t.setAttribute("data-y",0)}};class X{constructor(){this.listenerId=0,this.eventListeners={}}_supportsTextSelection(e){if(!e)return!1;let t=e.tagName?.toUpperCase();if(t==="TEXTAREA")return!0;if(t!=="INPUT")return typeof e.setSelectionRange==="function"||!!e.createTextRange||typeof e.selectionStart==="number";let o=(e.type||"text").toLowerCase();return o==="text"||o==="search"||o==="tel"||o==="url"||o==="password"}focus(e){if(e)e.focus()}blur(e){if(e)e.blur()}focusFirst(e,t=0,o=0){if(e){let n=window.getTabbableElements(e);if(n.length<=o)e.focus();else n[t].focus()}}focusLast(e,t=0,o=0){if(e){let n=window.getTabbableElements(e);if(n.length<=o)e.focus();else n[n.length-t-1].focus()}}saveFocus(e){if(e)e.mudblazor_savedFocus=document.activeElement}restoreFocus(e){if(e){let t=e.mudblazor_savedFocus;if(delete e.mudblazor_savedFocus,t)t.focus()}}selectRange(e,t,o){if(e){if(this._supportsTextSelection(e)){if(e.createTextRange){let n=e.createTextRange();n.collapse(!0),n.moveStart("character",t),n.moveEnd("character",o),n.select()}else if(e.setSelectionRange)e.setSelectionRange(t,o);else if(e.selectionStart)e.selectionStart=t,e.selectionEnd=o}e.focus()}}select(e){if(e)e.select()}getBoundingClientRect(e){if(!e)return;let t=JSON.parse(JSON.stringify(e.getBoundingClientRect()));return t.scrollY=window.scrollY||document.documentElement.scrollTop,t.scrollX=window.scrollX||document.documentElement.scrollLeft,t.windowHeight=window.innerHeight,t.windowWidth=window.innerWidth,t}changeCss(e,t){if(e)e.className=t}removeEventListener(e,t,o){e.removeEventListener(t,this.eventListeners[o]),delete this.eventListeners[o]}addDefaultPreventingHandler(e,t){let o=function(n){if(!n.defaultPrevented)n.preventDefault()};return e.addEventListener(t,o,{passive:!1}),this.eventListeners[++this.listenerId]=o,this.listenerId}removeDefaultPreventingHandler(e,t,o){this.removeEventListener(e,t,o)}addDefaultPreventingHandlers(e,t){let o=[];for(let n of t){let i=this.addDefaultPreventingHandler(e,n);o.push(i)}return o}removeDefaultPreventingHandlers(e,t,o){for(let n=0;n<t.length;++n){let i=t[n],r=o[n];this.removeDefaultPreventingHandler(e,i,r)}}addOnBlurEvent(e,t){if(!e)return;e._mudBlurHandler=function(o){let n=o.relatedTarget;window.setTimeout(()=>{if(!e||!document.contains(e)){window.mudElementRef.removeOnBlurEvent(e);return}let i=document.activeElement,r=n&&document.contains(n)?n:i;if(!!r&&r!==e&&r!==document.body&&r!==document.documentElement)return;if(t)t.invokeMethodAsync("CallOnBlurredAsync").catch((l)=>{console.warn("Error invoking CallOnBlurredAsync, possibly disposed:",l),window.mudElementRef.removeOnBlurEvent(e)});else console.error("No dotNetReference found for blur fallback")},0)},e.addEventListener("blur",e._mudBlurHandler)}removeOnBlurEvent(e){if(!e)return;if(e._mudBlurHandler)e.removeEventListener("blur",e._mudBlurHandler),delete e._mudBlurHandler}}window.mudElementRef=new X;class j{constructor(){this._prompts=new Map,this._handleBeforeUnload=this._handleBeforeUnload.bind(this)}enable(e,t){let o=this._prompts.size>0;if(this._prompts.set(e,t),!o)window.addEventListener("beforeunload",this._handleBeforeUnload)}disable(e){if(!this._prompts.has(e))this._throwPromptNotFound(e);if(this._prompts.delete(e),this._prompts.size===0)window.removeEventListener("beforeunload",this._handleBeforeUnload)}setText(e,t){if(!this._prompts.has(e))this._throwPromptNotFound(e);this._prompts.set(e,t)}handleBeforeNavigation(e){if(!Line truncated */class j{#n=new WeakMap;#e=null;#t=null;#o=null;#s=!1;attach(e,t){if(!e||this.#n.has(e))return;if(!this.#s){document.addEventListener("pointerdown",(i)=>{if(i.pointerType==="mouse")return;if(!i.isPrimary&&this.#e&&!this.#e.scrub)this.#i();if(this.#t&&!this.#t.chart.contains(i.target))this.#r()},{capture:!0});let o=(i)=>this.#c(i.pointerId);document.addEventListener("pointerup",o,{capture:!0}),document.addEventListener("pointercancel",o,{capture:!0}),this.#s=!0}let n={pointerdown:(o)=>this.#a(e,t,o),pointermove:(o)=>this.#u(e,t,o),touchmove:(o)=>{if(this.#e?.chart===e&&this.#e.scrub&&o.cancelable)o.preventDefault()},click:(o)=>{if(this.#o!==e)return;this.#o=null;let i=Se(e,o.clientX,o.clientY,t);if(i)Pe(i),this.#t={chart:e,target:i}},longPress:(o)=>{if(this.#e?.chart===e&&this.#e.scrub)o.preventDefault()}};e.addEventListener("pointerdown",n.pointerdown),e.addEventListener("pointermove",n.pointermove),e.addEventListener("touchmove",n.touchmove,{passive:!1}),e.addEventListener("click",n.click),e.addEventListener("contextmenu",n.longPress),e.addEventListener("selectstart",n.longPress),this.#n.set(e,n)}detach(e){let t=e?this.#n.get(e):void 0;if(!e||!t)return;if(e.removeEventListener("pointerdown",t.pointerdown),e.removeEventListener("pointermove",t.pointermove),e.removeEventListener("touchmove",t.touchmove),e.removeEventListener("click",t.click),e.removeEventListener("contextmenu",t.longPress),e.removeEventListener("selectstart",t.longPress),this.#n.delete(e),this.#e?.chart===e)this.#i();if(this.#t?.chart===e)this.#r();if(this.#o===e)this.#o=null}#a(e,t,n){if(this.#o=null,n.pointerType==="mouse"||!n.isPrimary)return;if(this.#e)this.#i();let o={chart:e,pointerId:n.pointerId,x:n.clientX,y:n.clientY,scrub:null,hovered:null,hold:setTimeout(()=>{if(this.#e===o&&o.scrub===null&&e.isConnected)this.#l(o),this.#d(o,o.x,o.y,t)},300)};this.#e=o}#u(e,t,n){let o=this.#e;if(o?.chart!==e||o.pointerId!==n.pointerId)return;if(o.scrub===null){let i=Math.abs(n.clientX-o.x),r=Math.abs(n.clientY-o.y);if(Math.hypot(i,r)<8)return;if(r<i*2)this.#l(o);else if(o.scrub=!1,clearTimeout(o.hold),this.#t?.chart===e)this.#r()}if(o.scrub)this.#d(o,n.clientX,n.clientY,t)}#l(e){if(e.scrub=!0,clearTimeout(e.hold),this.#t?.chart===e.chart)e.hovered=this.#t.target,this.#t=null}#d(e,t,n,o){let i=Se(e.chart,t,n,o);if(i&&i!==e.hovered)Pe(i),e.hovered=i}#c(e){let t=this.#e;if(t?.pointerId!==e)return;if(clearTimeout(t.hold),this.#e=null,t.scrub)fe(t.hovered);else if(t.scrub===null)this.#o=t.chart}#i(){clearTimeout(this.#e?.hold),fe(this.#e?.hovered??null),this.#e=null}#r(){fe(this.#t?.target??null),this.#t=null}}function Pe(e){e.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))}function fe(e){e?.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0}))}function Se(e,t,n,o){let i=null,r=1/0,s=1/0;for(let l of e.querySelectorAll(".mud-chart-hover-point")){let d=l.getBoundingClientRect(),a=Math.abs(d.left+d.width/2-t),p=Math.abs(d.top+d.height/2-n);if(o?a<r-0.5||a<=r+0.5&&p<s:Math.hypot(a,p)<Math.hypot(r,s))i=l,r=a,s=p}return i}class W{initDropZone(e){let t=document.getElementById(e);t.addEventListener("dragover",(n)=>n.preventDefault()),t.addEventListener("dragstart",(n)=>n.dataTransfer.setData("",n.target.id))}makeDropZonesNotRelative(){let e=Array.from(document.getElementsByClassName("mud-drop-item")).filter((n)=>n.getAttribute("index")=="-1");for(let n of e)n.style.position="static";let t=document.getElementsByClassName("mud-drop-zone");for(let n of t)n.style.position="unset"}getDropZoneIdentifierOnPosition(e,t){let o=document.elementsFromPoint(e,t).find((i)=>i.classList.contains("mud-drop-zone"));if(o)return o.getAttribute("identifier")||"";return""}getDropIndexOnPosition(e,t,n){let i=document.elementsFromPoint(e,t).find((r)=>r.classList.contains("mud-drop-item")&&r.id!=n);if(i)return i.getAttribute("index")||"";return""}makeDropZonesRelative(){let e=document.getElementsByClassName("mud-drop-zone");for(let n of e)n.style.position="relative";let t=Array.from(document.getElementsByClassName("mud-drop-item")).filter((n)=>n.getAttribute("index")=="-1");for(let n of t)n.style.position="relative"}moveItemByDifference(e,t,n){let o=document.getElementById(e),i=(Number.parseFloat(o.getAttribute("data-x")??"")||0)+t,r=(Number.parseFloat(o.getAttribute("data-y")??"")||0)+n;o.style.webkitTransform=o.style.transform="translate3d("+i+"px, "+r+"px, 10px)",o.setAttribute("data-x",String(i)),o.setAttribute("data-y",String(r))}resetItem(e){let t=document.getElementById(e);if(t)t.style.webkitTransform=t.style.transform="",t.setAttribute("data-x","0"),t.setAttribute("data-y","0")}}var We=new Set(["button","checkbox","radio","range","color","file","submit","reset","image"]),Je=new Set(["Control","Alt","AltGraph","Meta","Shift","OS"]),ge="unknown",He=new WeakMap,ve=null;function Ye(){document.addEventListener("keydown",(e)=>{if(e.metaKey||e.altKey||e.ctrlKey||Je.has(e.key))return;ge="keyboard"},!0),document.addEventListener("pointerdown",()=>{ge="pointer"},!0),documenLine truncated
//# debugId=39804C7932FD99C964756E2164756E21 //# debugId=72B246039E99631764756E2164756E21
//# sourceMappingURL=MudBlazor.min.js.map //# sourceMappingURL=MudBlazor.min.js.map
@@ -8,13 +8,14 @@ namespace AIStudio.Tests.Tools;
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// A web search reads up to four result pages in parallel, and every one of them is converted /// A web search reads up to four result pages in parallel, and every one of them is converted
/// through the same entry point. The converter doing that work tracks the ancestors of the node it /// through the same converter, which ReverseMarkdown documents as safe for concurrent use since
/// is at, and it does so without any synchronization, so sharing one converter between those /// version 6. Up to version 5, a converter tracked the ancestors of the node it was at without any
/// conversions let them write into each other's ancestor lists.<br/><br/> /// synchronization, and conversions sharing one wrote into each other's ancestor lists.<br/><br/>
/// That went wrong in two ways, and this test covers both. Loudly, as a torn list throwing an index /// That went wrong in two ways, and this test covers both, should a version of the library ever
/// out of range — which is what showed up in the logs. And quietly, as a list indented by the depth /// share state between conversions again. Loudly, as a torn list throwing an index out of range —
/// a different page happened to be at, which nothing reports and which only a comparison against a /// which is what showed up in the logs. And quietly, as a list indented by the depth a different
/// known-good conversion catches. /// page happened to be at, which nothing reports and which only a comparison against a known-good
/// conversion catches.
/// </remarks> /// </remarks>
[TestFixture] [TestFixture]
public sealed class HTMLParserConcurrencyTests public sealed class HTMLParserConcurrencyTests
@@ -0,0 +1,86 @@
using AIStudio.Tools;
namespace AIStudio.Tests.Tools;
/// <summary>
/// Checks the Markdown which the HTML of a web page or a mail becomes before a model reads it.
/// </summary>
/// <remarks>
/// The trim smoke test converts the same HTML in a trimmed build and expects the same Markdown, see MarkdownChecks
/// in app/TrimSmokeTest. A change here belongs there as well.
/// </remarks>
[TestFixture]
public sealed class HTMLParserConversionTests
{
/// <summary>
/// A teaser wrapped in a link keeps the words of its blocks apart, while the text of pre stays as it is.
/// </summary>
/// <remarks>
/// Without the compatibility shim in HTMLParser, the first item reads "Probe lands on the asteroid22 minutes
/// agoExample News", see documentation/compatibility-shims/2026-11-reversemarkdown-blocks-in-inline-elements.md.
/// </remarks>
[Test]
public void BlocksInsideALinkKeepTheirWordsApart()
{
const string HTML =
"""
<ul>
<li><a href="https://example.org/news/1"><div><header><h3>Probe lands on the asteroid</h3></header><footer><time>22 minutes ago</time><div><span>Example News</span></div></footer></div></a></li>
<li><a href="https://example.org/news/2"><h3>Second headline</h3><p>A summary of it.</p></a></li>
<li><a href="https://example.org/news/3">Plain link text</a></li>
</ul>
<p>Code in a link: <a href="https://example.org/code"><pre>line one
line two</pre></a></p>
""";
const string EXPECTED =
"""
- [Probe lands on the asteroid 22 minutes ago Example News](https://example.org/news/1)
- [Second headline A summary of it.](https://example.org/news/2)
- [Plain link text](https://example.org/news/3)
Code in a link: [](https://example.org/code)
```
line one
line two
```
""";
Assert.That(HTMLParser.ParseToMarkdown(HTML).ReplaceLineEndings("\n"), Is.EqualTo(EXPECTED.ReplaceLineEndings("\n")));
}
/// <summary>
/// The conversion keeps the text of unknown tags, drops comments and scripts, writes a link whose text is its
/// address as that address, and decodes the HTML entities.
/// </summary>
[Test]
public void TheConversionFollowsItsConfiguration()
{
const string HTML =
"""
<h2>Heading &amp; more</h2>
<p>Text with an <custom-tag>unknown tag</custom-tag>,<!-- a comment --> and a <a href="https://example.org">https://example.org</a> link.</p>
<ol><li>First<ul><li>Nested</li></ul></li><li>Second</li></ol>
<table><tr><th>Name</th><th>Value</th></tr><tr><td>A &lt; B</td><td>1</td></tr></table>
<script>var hidden = 1;</script>
""";
const string EXPECTED =
"""
## Heading & more
Text with an unknown tag, and a https://example.org link.
1. First
- Nested
2. Second
| Name | Value |
| --- | --- |
| A &lt; B | 1 |
""";
Assert.That(HTMLParser.ParseToMarkdown(HTML).ReplaceLineEndings("\n"), Is.EqualTo(EXPECTED.ReplaceLineEndings("\n")));
}
}
+104
View File
@@ -0,0 +1,104 @@
using AIStudio.Tools;
namespace AIStudio.TrimSmokeTest;
/// <summary>
/// Lets HTMLParser convert what its tests convert, because ReverseMarkdown is marked as trimmable since version 6.1.
/// </summary>
/// <remarks>
/// The trimmer therefore removes every part of ReverseMarkdown which nothing but reflection reaches, and
/// Trimming.props suppresses the warnings which would name such a part. The converter of HTMLParser takes only the
/// built-in readers and writers, which need no reflection, and a preprocessing step of our own. The HTML and the
/// expected Markdown are those of HTMLParserConversionTests in app/Tests/Tools, which run untrimmed.
/// </remarks>
public static class MarkdownChecks
{
private const string TEASER_HTML =
"""
<ul>
<li><a href="https://example.org/news/1"><div><header><h3>Probe lands on the asteroid</h3></header><footer><time>22 minutes ago</time><div><span>Example News</span></div></footer></div></a></li>
<li><a href="https://example.org/news/2"><h3>Second headline</h3><p>A summary of it.</p></a></li>
<li><a href="https://example.org/news/3">Plain link text</a></li>
</ul>
<p>Code in a link: <a href="https://example.org/code"><pre>line one
line two</pre></a></p>
""";
private const string TEASER_MARKDOWN =
"""
- [Probe lands on the asteroid 22 minutes ago Example News](https://example.org/news/1)
- [Second headline A summary of it.](https://example.org/news/2)
- [Plain link text](https://example.org/news/3)
Code in a link: [](https://example.org/code)
```
line one
line two
```
""";
private const string CONFIGURATION_HTML =
"""
<h2>Heading &amp; more</h2>
<p>Text with an <custom-tag>unknown tag</custom-tag>,<!-- a comment --> and a <a href="https://example.org">https://example.org</a> link.</p>
<ol><li>First<ul><li>Nested</li></ul></li><li>Second</li></ol>
<table><tr><th>Name</th><th>Value</th></tr><tr><td>A &lt; B</td><td>1</td></tr></table>
<script>var hidden = 1;</script>
""";
private const string CONFIGURATION_MARKDOWN =
"""
## Heading & more
Text with an unknown tag, and a https://example.org link.
1. First
- Nested
2. Second
| Name | Value |
| --- | --- |
| A &lt; B | 1 |
""";
/// <summary>
/// Returns a description of every conversion which fails or gives other Markdown than untrimmed.
/// </summary>
/// <returns>One line per failure, naming the conversion and what went wrong.</returns>
public static IReadOnlyList<string> FindFailures()
{
var failures = new List<string>();
Expect(failures, "a teaser wrapped in a link", TEASER_HTML, TEASER_MARKDOWN);
Expect(failures, "headings, lists, a table, and links", CONFIGURATION_HTML, CONFIGURATION_MARKDOWN);
return failures;
}
/// <summary>
/// Converts HTML and compares the Markdown with the expected one.
/// </summary>
/// <param name="failures">Where to add a failure.</param>
/// <param name="what">What the HTML holds, completing "HTMLParser could not convert ...".</param>
/// <param name="html">The HTML to convert.</param>
/// <param name="expected">The Markdown the conversion gives untrimmed.</param>
private static void Expect(List<string> failures, string what, string html, string expected)
{
string markdown;
try
{
markdown = HTMLParser.ParseToMarkdown(html).ReplaceLineEndings("\n");
}
catch (Exception exception)
{
//
// A member the trimmer removed surfaces as the innermost exception, e.g., below a TypeInitializationException:
//
var cause = exception.GetBaseException();
failures.Add($"HTMLParser could not convert {what}: {cause.GetType().Name}: {cause.Message}");
return;
}
if (markdown != expected.ReplaceLineEndings("\n"))
failures.Add($"HTMLParser converted {what} into '{markdown}' instead of '{expected.ReplaceLineEndings("\n")}'.");
}
}
+4 -2
View File
@@ -3,8 +3,8 @@ using Microsoft.Extensions.Logging.Abstractions;
namespace AIStudio.TrimSmokeTest; namespace AIStudio.TrimSmokeTest;
/// <summary> /// <summary>
/// Checks whether a trimmed build can still read and write the JSON of AI Studio, and compute with the /// Checks whether a trimmed build can still read and write the JSON of AI Studio, compute with the
/// Mathematics tools, see TrimSmokeTest.csproj. /// Mathematics tools, and convert HTML to Markdown, see TrimSmokeTest.csproj.
/// </summary> /// </summary>
public static class Program public static class Program
{ {
@@ -30,10 +30,12 @@ public static class Program
failures.AddRange(JsonRoundTrips.FindLosses()); failures.AddRange(JsonRoundTrips.FindLosses());
failures.AddRange(MathematicsChecks.FindFailures()); failures.AddRange(MathematicsChecks.FindFailures());
failures.AddRange(MarkdownChecks.FindFailures());
if (failures.Count is 0) if (failures.Count is 0)
{ {
Console.WriteLine($"- All {roots.Count} JSON roots can be read and written."); Console.WriteLine($"- All {roots.Count} JSON roots can be read and written.");
Console.WriteLine("- The Mathematics tools compute what they compute untrimmed."); Console.WriteLine("- The Mathematics tools compute what they compute untrimmed.");
Console.WriteLine("- HTML becomes the same Markdown as untrimmed.");
return 0; return 0;
} }
+3 -3
View File
@@ -2,9 +2,9 @@
<!-- <!--
Checks what only a published build of AI Studio lacks. The trimmer removes code of .NET which System.Text.Json Checks what only a published build of AI Studio lacks. The trimmer removes code of .NET which System.Text.Json
reaches by reflection only, and the same holds for AngouriMath, which is marked as trimmable, while debug builds reaches by reflection only, and the same holds for AngouriMath and ReverseMarkdown, which are marked as
and the tests are not trimmed. Hence, this program has to run published, trimmed by the same Trimming.props as trimmable, while debug builds and the tests are not trimmed. Hence, this program has to run published, trimmed
the app; the command verify of the build script does both. by the same Trimming.props as the app; the command verify of the build script does both.
--> -->
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
@@ -0,0 +1,26 @@
# ReverseMarkdown Blocks in Inline Elements
- Status: Active
- Introduced: 2026-11-26
- Remove after: when a ReverseMarkdown release keeps the words of the blocks apart which it writes into the text of an inline element, such as a link, see [mysticmind/reversemarkdown-net#440](https://github.com/mysticmind/reversemarkdown-net/issues/440)
- Code references:
- `app/MindWork AI Studio/Tools/HTMLParser.cs` (`UnwrapBlocksInsideInlineElements`, `IsBlockInsideInlineElement`, `NeedsSeparator`, `INLINE_ELEMENTS`, `BLOCK_ELEMENTS`)
- `app/Tests/Tools/HTMLParserConversionTests.cs` (`BlocksInsideALinkKeepTheirWordsApart`)
- `app/TrimSmokeTest/MarkdownChecks.cs` (`TEASER_HTML`, `TEASER_MARKDOWN`)
## User Impact
AI Studio converts web pages and the HTML of mails to Markdown with ReverseMarkdown before a model reads them, e.g., for the web search, the Read Web Page tool, and the mailboxes. Many pages wrap a whole teaser in a link: a heading, a line of metadata, and a summary, each a block of its own. A link holds no blocks in Markdown, so ReverseMarkdown 6 writes the texts of those blocks one after another into the text of the link, without anything in between. A teaser then reads, e.g., "Java77.721 Abrufeheise security" instead of "Java 77.721 Abrufe heise security". On the start page of a news site, this glued about 140 words together; the text of an article itself is rarely affected. ReverseMarkdown 5 had no such problem, since it kept the blocks, although as invalid Markdown.
## Compatibility Behavior
The converter of `HTMLParser` runs a preprocessing step of its own, through the preprocessing API of ReverseMarkdown. The step finds every block element inside an inline element, such as a `div`, a heading, or a list inside a link, and replaces it by its content. Before and after that content, it puts a space, unless there is whitespace already. Spaces next to the blocks alone were not enough: a first attempt which only added them still left most teasers on the start page of a news site glued together. Tables and `pre` keep their structure, and inside `pre` nothing changes at all.
The result is what ReverseMarkdown makes of such a block anyway, only with the words apart. Pages without blocks inside inline elements convert exactly as without this step; on eight real pages, only the two start pages of news sites changed.
## Removal Checklist
- Check that the new ReverseMarkdown release separates the blocks inside an inline element itself, e.g., with the test `BlocksInsideALinkKeepTheirWordsApart` and the preprocessing step switched off.
- Remove `UnwrapBlocksInsideInlineElements`, `IsBlockInsideInlineElement`, `NeedsSeparator`, `INLINE_ELEMENTS`, and `BLOCK_ELEMENTS` from `HTMLParser`, and the `Preprocess` entry from its configuration.
- Keep `BlocksInsideALinkKeepTheirWordsApart` and the teaser of `MarkdownChecks`: they then check the library itself.
- Update this document's status to `Removed`.
+1 -1
View File
@@ -4,7 +4,7 @@
10.0.404 (commit 2ab2854867) 10.0.404 (commit 2ab2854867)
10.0.15 (commit 8e0f8ed231) 10.0.15 (commit 8e0f8ed231)
1.100.0 (commit 0ef1bc386) 1.100.0 (commit 0ef1bc386)
9.12.0 9.14.0
2.12.7 2.12.7
9d1768e2f40, release 9d1768e2f40, release
158.0.8125.0 158.0.8125.0