Skip to content

Commit e8df685

Browse files
committed
fix: disable rich-text placeholders for the remote Precise kernel
Remote pdf2zh servers run unpatched BabelDOC, which typesets translated style tags such as <样式 id='1'> literally. Send disableRichTextTranslate with remote jobs and bump the remote cache key so pages with leaked tags are retranslated.
1 parent 613f130 commit e8df685

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎server/kernels/remote-kernel.mjs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ export function createRemoteKernel({
242242
noMono: false,
243243
noDual: true,
244244
asyncJob: true,
245+
// The local Precise kernel rewrites translated rich-text tags (<样式 id='1'>) to the
246+
// <style id='1'> BabelDOC parses. A remote server runs unpatched BabelDOC, which
247+
// typesets such tags literally, so it must not send style placeholders to the LLM.
248+
disableRichTextTranslate: true,
245249
...(service ? { service, next_service: service } : {}),
246250
};
247251
const deadline = now() + jobTimeoutMs;

‎server/kernels/translation-runner.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ export function createTranslationRunner({
231231
.copy()
232232
.update(
233233
JSON.stringify({
234-
remote: 1,
234+
// 2: rich-text placeholders disabled; earlier pages may show literal <样式> tags.
235+
remote: 2,
235236
id,
236237
url: remoteUrl,
237238
service: remoteService,

‎tests/server/kernels/remote-kernel.test.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ test('translatePage uploads one page, never sends credentials, and returns one p
134134
assert.equal(upload.targetLang, 'zh-CN');
135135
assert.equal(upload.noDual, true);
136136
assert.equal(upload.asyncJob, true);
137+
assert.equal(upload.disableRichTextTranslate, true);
137138
assert.equal(upload.next_service, 'siliconflowfree');
138139
assert.equal('llm_api' in upload, false);
139140
const uploaded = await PDFDocument.load(Buffer.from(upload.fileContent, 'base64'));

0 commit comments

Comments
 (0)