From bceb793c1c6b805f64cb1342dbf4ff6f522700b1 Mon Sep 17 00:00:00 2001 From: ankraft <an.kraft@gmail.com> Date: Fri, 17 Jan 2025 16:33:56 +0100 Subject: [PATCH] Added placeholder and edit note for not-found images --- spec2md.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spec2md.py b/spec2md.py index 15f99c5..ecf6ead 100644 --- a/spec2md.py +++ b/spec2md.py @@ -608,7 +608,7 @@ def processDocuments(documents:list[str], fn = f'{imageDirName}{os.sep}{os.path.basename(zipMediaFilename)}' if fn.lower().endswith(('.emf', '.wmf')): - _print(f'[yellow]unsupported media file: {fn}', highlight = False) + _print(f'[yellow]unsupported media file (will be converted): {fn}', highlight = False) emfFiles.append(fn) with open(f'{fn}', 'wb') as imgFile: imgFile.write(zip.read(zipMediaFilename)) @@ -705,7 +705,7 @@ def processDocuments(documents:list[str], # Image Caption elif style in docConfig.imagecaption: checkSameStyle(Style.imagecaption, lambda:lines.append('')) - _t = replaceNL(text).strip() + _t = replaceNL(text).strip().replace('<br />', ' ') lines.append(f'**{_t}**') lines.append('') if docConfig.imageCaptions2AltText: @@ -717,7 +717,13 @@ def processDocuments(documents:list[str], # Image & Figure elif style in docConfig.image: lines.append('') - lines.append(text) + if text: + # If we have an image name + lines.append(text) + else: + # If we have no image name we add a placeholder + lines.append('<mark>Please add the correct image caption and filename</mark>') + lines.append(f'') # Code elif style in docConfig.code: -- GitLab