fix(chat): refine markdown typography
This commit is contained in:
@@ -23,9 +23,17 @@ const reasoning = computed(() => props.reasoning || parsed.value.reasoning);
|
||||
const hasAnswer = computed(() => answer.value.trim().length > 0);
|
||||
const renderedContent = computed(() => {
|
||||
if (props.role !== "assistant") return answer.value;
|
||||
return hasAnswer.value ? markdown.render(answer.value) : "";
|
||||
return hasAnswer.value ? 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();
|
||||
let answer = "";
|
||||
|
||||
Reference in New Issue
Block a user