现在支持的格式

-  ```svg<svg... 
  -  ```svg <svg... 
  -  ```xml<svg... 
  -  ```xml <svg... 
  -  ``` xml<svg... 
  -  ``` svg<svg... 
  -  ```<svg... (无语言标识)

  这样无论 LLM 输出哪种格式,都能正确实时绘制和复制图片到剪贴板了。
This commit is contained in:
史悦
2026-02-03 10:55:17 +08:00
parent 0f68b6d7a2
commit d74fbce137
5 changed files with 13 additions and 10 deletions

View File

@@ -1325,8 +1325,9 @@
};
}
const svgCtx = streamState.svg;
// 兼容 ```svg、```xml、``` xml、``` svg 等格式
const startPattern =
manifest.artifact?.startPattern || /```(?:svg)?\s*<svg/i;
manifest.artifact?.startPattern || /```\s*(?:svg|xml)?\s*<svg/i;
if (!svgCtx.started) {
const match = fullContent.match(startPattern);
if (match) {
@@ -1347,7 +1348,8 @@
}
const svgSection = fullContent.substring(svgCtx.startIndex);
let cleaned = svgSection.replace(/```(?:svg)?\s*/i, '');
// 兼容清理 ```svg、```xml、``` xml、``` svg 等前缀
let cleaned = svgSection.replace(/```\s*(?:svg|xml)?\s*/i, '');
cleaned = cleaned.replace(/```$/, '');
const closingIndex = cleaned.indexOf('</svg>');
if (closingIndex !== -1) {