fix(chat): refine markdown typography
This commit is contained in:
@@ -13,7 +13,15 @@ const markdown = new MarkdownIt({ breaks: true, html: false, linkify: true });
|
||||
const parsed = computed(() => splitReasoning(props.content));
|
||||
const answer = computed(() => parsed.value.answer.replace(/^\s+/, ""));
|
||||
const reasoning = computed(() => props.reasoning || parsed.value.reasoning);
|
||||
const renderedContent = computed(() => answer.value.trim() ? markdown.render(answer.value) : "");
|
||||
const renderedContent = computed(() => answer.value.trim() ? markdown.render(normalizeStandaloneHeadings(answer.value)) : "");
|
||||
|
||||
function normalizeStandaloneHeadings(content: string) {
|
||||
return content.replace(/^([ \t]*)\*\*(.+)\*\*[ \t]*$/gm, (line, indent: string, title: string) => {
|
||||
const normalizedTitle = title.trim();
|
||||
if (!normalizedTitle || normalizedTitle.length > 48 || normalizedTitle.includes("**")) return line;
|
||||
return `${indent}### ${normalizedTitle}`;
|
||||
});
|
||||
}
|
||||
|
||||
function splitReasoning(content: string) {
|
||||
const lower = content.toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user