Commit 9d6c2bdf authored by 段廷瑞's avatar 段廷瑞

pref: markdown渲染优化

parent 1ac5825c
......@@ -70,6 +70,7 @@
<Compile Include="EmbeddingClientTests.cs" />
<Compile Include="ToolPermissionTests.cs" />
<Compile Include="TextEncodingTests.cs" />
<Compile Include="MarkdownRendererTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Tools\Tools.csproj">
......
using System;
using System.Collections.Generic;
using Tools.MyAgent;
namespace AgentTest
{
/// <summary>
/// MarkdownRenderer 渲染回归测试(D7:数字序号后键帽方框)
/// </summary>
public class MarkdownRendererTests : TestRunner
{
private static string Render(string content)
{
return MarkdownRenderer.BuildChatRtf(
new List<ChatMessage>
{
new ChatMessage { Role = "assistant", Content = content, Timestamp = DateTime.Now }
},
null);
}
[Test]
public void KeycapEmoji_NoTofuBoxAfterDigit()
{
// "### 1️⃣ 排查方法论" = '1' + U+FE0F(VS16) + U+20E3(键帽)。
// 回归:U+20E3 不得以 \u8355? 残留(微软雅黑缺字形 → 数字序号后渲染出方框 □)。
string rtf = Render("### 1️⃣ 排查方法论");
Assert.NotContains(rtf, @"\u8355?", "键帽 U+20E3 转义残留");
Assert.NotContains(rtf, @"\u-497?", "VS16 U+FE0F 转义残留");
// 数字 1 与正文应完整保留(方 26041 / 法 27861 / 论 U+8BBA 超 short 范围 → -29766)
Assert.Contains(rtf, @"\u26041?\u27861?\u-29766?", "正文缺失");
}
[Test]
public void OrderedList_StillRendered()
{
string rtf = Render("1. Step one\n2. Step two");
Assert.Contains(rtf, "1. Step one");
Assert.Contains(rtf, "2. Step two");
}
}
}
......@@ -612,9 +612,14 @@ namespace Tools.MyAgent
}
}
/// <summary>零宽/不可见格式字符(D4):无展示价值且多数字体缺字形,丢弃避免显示 □</summary>
/// <summary>零宽/不可见格式字符(D4/D7):无展示价值且多数字体缺字形,丢弃避免显示 □</summary>
private static bool IsInvisibleFormatChar(char c)
{
// 组合用符号区段(U+20D0–U+20FF,D7):组合修饰符,单独无展示价值且微软雅黑缺字形。
// 如 1️⃣ 的键帽 U+20E3(VS16 已在上方丢弃),若保留会转义为 \u8355? 并以微软雅黑渲染,
// 缺字形 → 数字序号后紧跟方框 □;整体丢弃后仅剩纯数字,无内容损失。
if (c >= 0x20D0 && c <= 0x20FF)
return true;
switch (c)
{
case '\u00AD': // 软连字符
......
......@@ -42,7 +42,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto, Version=1.8.6.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\FunnyPick\packages\Portable.BouncyCastle.1.8.6\lib\net40\BouncyCastle.Crypto.dll</HintPath>
<HintPath>..\packages\Portable.BouncyCastle.1.8.6\lib\net40\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.2.10, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\packages\SharpZipLib.1.3.2\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
......@@ -57,16 +57,16 @@
<HintPath>..\packages\Npgsql.6.0.3\lib\netstandard2.0\Npgsql.dll</HintPath>
</Reference>
<Reference Include="NPOI, Version=2.5.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\FunnyPick\packages\NPOI.2.5.1\lib\net45\NPOI.dll</HintPath>
<HintPath>..\packages\NPOI.2.5.1\lib\net45\NPOI.dll</HintPath>
</Reference>
<Reference Include="NPOI.OOXML, Version=2.5.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\FunnyPick\packages\NPOI.2.5.1\lib\net45\NPOI.OOXML.dll</HintPath>
<HintPath>..\packages\NPOI.2.5.1\lib\net45\NPOI.OOXML.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXml4Net, Version=2.5.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\FunnyPick\packages\NPOI.2.5.1\lib\net45\NPOI.OpenXml4Net.dll</HintPath>
<HintPath>..\packages\NPOI.2.5.1\lib\net45\NPOI.OpenXml4Net.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXmlFormats, Version=2.5.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\FunnyPick\packages\NPOI.2.5.1\lib\net45\NPOI.OpenXmlFormats.dll</HintPath>
<HintPath>..\packages\NPOI.2.5.1\lib\net45\NPOI.OpenXmlFormats.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment