fix: broken cn chars

This commit is contained in:
Han Xiao 2025-03-28 15:46:26 +08:00
parent 6d4fa95217
commit 949c34f14f
3 changed files with 7 additions and 8 deletions

View File

@ -959,12 +959,7 @@ But unfortunately, you failed to solve the issue. You need to think out of the b
fixCodeBlockIndentation(
repairMarkdownFootnotesOuter(
await repairUnknownChars(
await fixMarkdown(
buildMdFromAnswer((thisStep as AnswerAction)),
allKnowledge,
context,
SchemaGen
), context))
buildMdFromAnswer(thisStep as AnswerAction), context))
),
allURLs)));
} else {

View File

@ -5,7 +5,7 @@ import {TrackerContext} from "../types";
/**
* Repairs markdown content with <EFBFBD> characters by using Gemini to guess the missing text
*/
export async function repairUnknownChars(mdContent: string, trackers: TrackerContext): Promise<string> {
export async function repairUnknownChars(mdContent: string, trackers?: TrackerContext): Promise<string> {
if (!mdContent.includes('<27>')) return mdContent;
let repairedContent = mdContent;
@ -68,7 +68,7 @@ On the right of the stains: "${rightContext}"
So what was the original text between these two contexts?`,
});
trackers.tokenTracker.trackUsage('md-fixer', result.usage)
trackers?.tokenTracker.trackUsage('md-fixer', result.usage)
const replacement = result.text.trim();
// Validate the replacement

View File

@ -717,6 +717,10 @@ export function repairMarkdownFinal(markdown: string): string {
try {
let repairedMarkdown = markdown;
// remove any '<27>'
repairedMarkdown = repairedMarkdown.replace(/<2F>/g, '');
// Step 1: Handle <hr> and <br> tags outside tables
// First, identify table regions to exclude them from the replacement