From 08807762f5c54960b3eb44ff8e3446107ad298e5 Mon Sep 17 00:00:00 2001 From: ilyapashuk <40538919+ilyapashuk@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:31:28 +0300 Subject: [PATCH] Update convert.js to fix incorrect handling of some images this script uses the "latex_styled" response field to extract the output. but for some images the "latex_styled" field is not return, only the "text" is returned for such images it fails with the "could not write to destination path" error (with the incorrect error message). this commit fixes this by using the "text" field if the "latex_styled" field is not available. --- lib/convert.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/convert.js b/lib/convert.js index ed0c324..51d175e 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -565,6 +565,7 @@ async function ConvertImageWithOCRAPI(apiKey, outputType, source, destination, h process.stdout.cursorTo(0); let responseJSON = await res.json(); + if (! ('latex_styled' in responseJSON)) responseJSON['latex_styled'] = responseJSON['text']; if (destination.endsWith("docx")) { await MarkdownToDocx(responseJSON["latex_styled"], destination, true); } else if (destination.endsWith("tex")) {