Fixed exports and the clipboard losing the sources of an answer (#966)
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-09-13 19:37:15 +02:00
1 parent bb3ec5da92
commit 65a1683b95
13 files changed
+481 -7

No files matched your search

+25
View File
@@ -1,4 +1,5 @@
using Markdig;
using Markdig.Syntax;
using System.Text;
namespace AIStudio.Tools;
@@ -58,6 +59,30 @@ public static class Markdown
return escaped.ToString();
}
/// <summary>Closes a code fence which the text opened but never closed.</summary>
/// <remarks>
/// An unclosed fence runs to the end of the document, so anything appended after it would be
/// read as code instead of as Markdown. The chat never shows this, because it renders the answer
/// and what belongs below it separately. A document is one text, and there an answer which ends
/// in an open fence would swallow whatever follows it.
/// </remarks>
/// <param name="markdownText">The Markdown text to inspect.</param>
/// <returns>The text with its open fence closed, or the text itself when no fence is open.</returns>
public static string CloseOpenCodeFence(string markdownText)
{
if (string.IsNullOrWhiteSpace(markdownText))
return markdownText;
var document = Markdig.Markdown.Parse(markdownText, SAFE_MARKDOWN_PIPELINE);
// Only the last fence of a text can be an open one: an open fence takes everything
// after it with it, so no other block is able to follow it.
if (document.Descendants<FencedCodeBlock>().LastOrDefault() is not { ClosingFencedCharCount: 0 } openFence)
return markdownText;
return $"{markdownText}{Environment.NewLine}{new string(openFence.FencedChar, openFence.OpeningFencedCharCount)}";
}
public static string RemoveSharedIndentation(string value)
{
if (string.IsNullOrWhiteSpace(value))