fix: 修復行尾格式(CRLF → LF)
This commit is contained in:
parent
a1761b7da5
commit
c2d3d13c89
6 changed files with 243 additions and 77 deletions
|
|
@ -69,7 +69,11 @@ describe("BabelDOC converter - Chinese translation", () => {
|
|||
) => {
|
||||
if (cmd === "pdftotext") {
|
||||
// 返回超過 100 個字元,表示 PDF 不需要 OCR
|
||||
callback(null, "This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.", "");
|
||||
callback(
|
||||
null,
|
||||
"This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.",
|
||||
"",
|
||||
);
|
||||
} else if (cmd === "babeldoc") {
|
||||
babeldocCalled = true;
|
||||
babeldocArgs = args;
|
||||
|
|
@ -135,7 +139,11 @@ describe("BabelDOC converter - English translation", () => {
|
|||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
if (cmd === "pdftotext") {
|
||||
callback(null, "This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.", "");
|
||||
callback(
|
||||
null,
|
||||
"This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.",
|
||||
"",
|
||||
);
|
||||
} else if (cmd === "babeldoc") {
|
||||
babeldocArgs = args;
|
||||
const outputIndex = args.indexOf("-o");
|
||||
|
|
@ -187,7 +195,11 @@ describe("BabelDOC converter - Traditional Chinese", () => {
|
|||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
if (cmd === "pdftotext") {
|
||||
callback(null, "This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.", "");
|
||||
callback(
|
||||
null,
|
||||
"This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.",
|
||||
"",
|
||||
);
|
||||
} else if (cmd === "babeldoc") {
|
||||
babeldocArgs = args;
|
||||
const outputIndex = args.indexOf("-o");
|
||||
|
|
@ -239,7 +251,11 @@ describe("BabelDOC converter - Output structure", () => {
|
|||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
if (cmd === "pdftotext") {
|
||||
callback(null, "This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.", "");
|
||||
callback(
|
||||
null,
|
||||
"This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.",
|
||||
"",
|
||||
);
|
||||
} else if (cmd === "babeldoc") {
|
||||
const outputIndex = args.indexOf("-o");
|
||||
if (outputIndex !== -1 && args[outputIndex + 1]) {
|
||||
|
|
@ -277,7 +293,11 @@ describe("BabelDOC converter - Output structure", () => {
|
|||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
if (cmd === "pdftotext") {
|
||||
callback(null, "This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.", "");
|
||||
callback(
|
||||
null,
|
||||
"This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.",
|
||||
"",
|
||||
);
|
||||
} else if (cmd === "babeldoc") {
|
||||
const outputIndex = args.indexOf("-o");
|
||||
if (outputIndex !== -1 && args[outputIndex + 1]) {
|
||||
|
|
@ -329,7 +349,11 @@ describe("BabelDOC converter - Error handling", () => {
|
|||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
if (cmd === "pdftotext") {
|
||||
callback(null, "This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.", "");
|
||||
callback(
|
||||
null,
|
||||
"This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.",
|
||||
"",
|
||||
);
|
||||
} else if (cmd === "babeldoc") {
|
||||
const error = new Error("Translation failed") as ExecFileException;
|
||||
error.code = 1;
|
||||
|
|
@ -351,7 +375,11 @@ describe("BabelDOC converter - Error handling", () => {
|
|||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
if (cmd === "pdftotext") {
|
||||
callback(null, "This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.", "");
|
||||
callback(
|
||||
null,
|
||||
"This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.",
|
||||
"",
|
||||
);
|
||||
} else if (cmd === "babeldoc") {
|
||||
// Don't create output file, simulating failed translation
|
||||
callback(null, "Complete", "");
|
||||
|
|
@ -392,7 +420,11 @@ describe("BabelDOC converter - Markdown output format", () => {
|
|||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
if (cmd === "pdftotext") {
|
||||
callback(null, "This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.", "");
|
||||
callback(
|
||||
null,
|
||||
"This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.",
|
||||
"",
|
||||
);
|
||||
} else if (cmd === "babeldoc") {
|
||||
babeldocArgs = args;
|
||||
const outputIndex = args.indexOf("-o");
|
||||
|
|
@ -446,7 +478,11 @@ describe("BabelDOC converter - HTML output format", () => {
|
|||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
if (cmd === "pdftotext") {
|
||||
callback(null, "This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.", "");
|
||||
callback(
|
||||
null,
|
||||
"This is a comprehensive test PDF with more than enough text content to ensure that the OCR detection threshold of 100 characters is exceeded and the PDF is not treated as a scanned document requiring OCR processing.",
|
||||
"",
|
||||
);
|
||||
} else if (cmd === "babeldoc") {
|
||||
babeldocArgs = args;
|
||||
const outputIndex = args.indexOf("-o");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue