Skip to content

Commit a6b98b0

Browse files
committed
修正Mac上提取图片的逻辑
1 parent d2aea06 commit a6b98b0

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

bin/win32/docugenius-cli.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set PYTHONUTF8=1
88

99
if "%~1"=="" (
1010
echo DocuGenius CLI - Document to Markdown Converter with Image Extraction
11-
echo Usage: docugenius-cli ^<file^> [extract_images] [output_path]
11+
echo Usage: docugenius-cli ^<file^> [extract_images] [output_path] [image_output_folder]
1212
echo.
1313
echo Supported formats:
1414
echo - Text files: .txt, .md, .markdown
@@ -40,5 +40,5 @@ if not exist "%CONVERTER%" (
4040
exit /b 1
4141
)
4242

43-
python "%CONVERTER%" "%~1" "%~2" "%~3"
43+
python "%CONVERTER%" "%~1" "%~2" "%~3" "%~4"
4444
exit /b %ERRORLEVEL%

build_binaries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def create_windows_batch():
170170
171171
if "%~1"=="" (
172172
echo DocuGenius CLI - Document to Markdown Converter with Image Extraction
173-
echo Usage: docugenius-cli ^<file^> [extract_images] [output_path]
173+
echo Usage: docugenius-cli ^<file^> [extract_images] [output_path] [image_output_folder]
174174
echo.
175175
echo Supported formats:
176176
echo - Text files: .txt, .md, .markdown
@@ -202,7 +202,7 @@ def create_windows_batch():
202202
exit /b 1
203203
)
204204
205-
python "%CONVERTER%" "%~1" "%~2" "%~3"
205+
python "%CONVERTER%" "%~1" "%~2" "%~3" "%~4"
206206
exit /b %ERRORLEVEL%
207207
'''
208208

src/converter.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { pathContainsDirectorySegment } from './pathUtils';
1313
interface ConverterCommand {
1414
command: string;
1515
args: string[];
16-
usesPythonConverter: boolean;
16+
supportsConversionOptions: boolean;
1717
description: string;
1818
env?: NodeJS.ProcessEnv;
1919
}
@@ -367,8 +367,9 @@ export class MarkitdownConverter {
367367
try {
368368
let args = [...converterCommand.args];
369369

370-
if (converterCommand.usesPythonConverter) {
371-
// Pass extract images configuration to Python converter
370+
if (converterCommand.supportsConversionOptions) {
371+
// Both the Windows script path and the packaged macOS binary
372+
// delegate to converter.py and support the same argument contract.
372373
const extractImages = this.configManager.shouldExtractImages();
373374
const outputPath = this.getOutputPath(filePath);
374375
const imageOutputFolder = this.configManager.getImageOutputFolder();
@@ -385,9 +386,9 @@ export class MarkitdownConverter {
385386
// Process the markdown content to handle images if needed
386387
let markdownContent = stdout;
387388

388-
if (this.configManager.shouldExtractImages() && !converterCommand.usesPythonConverter) {
389+
if (this.configManager.shouldExtractImages() && !converterCommand.supportsConversionOptions) {
389390
// Only do additional image processing if we didn't use Python converter
390-
// Python converter already includes intelligent image extraction
391+
// Integrated converters already include image extraction.
391392
markdownContent = await this.processImages(filePath, markdownContent);
392393
}
393394

@@ -544,7 +545,7 @@ export class MarkitdownConverter {
544545
commands.push({
545546
command: runtime.pythonPath,
546547
args: [embeddedConverterPath],
547-
usesPythonConverter: true,
548+
supportsConversionOptions: true,
548549
description: `${runtime.pythonPath} ${embeddedConverterPath}`,
549550
env: {
550551
DOCUGENIUS_AUTO_INSTALL_DEPS: '0'
@@ -562,7 +563,7 @@ export class MarkitdownConverter {
562563
commands.push({
563564
command: embeddedBinaryPath,
564565
args: [],
565-
usesPythonConverter: false,
566+
supportsConversionOptions: true,
566567
description: embeddedBinaryPath
567568
});
568569
}

0 commit comments

Comments
 (0)