From dc0d9e29ceaf45b65072c908d1922ab037e3807a Mon Sep 17 00:00:00 2001 From: CaptainB Date: Mon, 8 Dec 2025 11:16:38 +0800 Subject: [PATCH] feat: enhance image path handling in markdown processing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1064136 --user=刘瑞斌 【工作流知识库】上传zip文件,文件中的图片内容没有写入知识库 https://www.tapd.cn/62980211/s/1806941 --- apps/common/handle/impl/text/zip_split_handle.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/common/handle/impl/text/zip_split_handle.py b/apps/common/handle/impl/text/zip_split_handle.py index 9d7143de4..b557ad7b7 100644 --- a/apps/common/handle/impl/text/zip_split_handle.py +++ b/apps/common/handle/impl/text/zip_split_handle.py @@ -213,6 +213,19 @@ class ZipSplitHandle(BaseSplitHandle): # 回到文件头 inner_file.seek(0) md_text = split_handle.get_content(inner_file, save_image) + image_list = parse_md_image(md_text) + for image in image_list: + search = re.search("\(.*\)", image) + if search: + source_image_path = search.group().replace('(', '').replace(')', '') + source_image_path = source_image_path.strip().split(" ")[0] + image_path = urljoin( + real_name, '.' + source_image_path if source_image_path.startswith( + '/') else source_image_path + ) + for img_model in image_mode_list: + if img_model.file_name == os.path.basename(image_path): + md_text = md_text.replace(source_image_path, f'./oss/file/{img_model.id}') break # 如果没有任何 split_handle 处理,按文本解码作为后备