Skip to content

Commit dc0d9e2

Browse files
committed
feat: enhance image path handling in markdown processing
--bug=1064136 --user=刘瑞斌 【工作流知识库】上传zip文件,文件中的图片内容没有写入知识库 https://www.tapd.cn/62980211/s/1806941
1 parent 9d8d395 commit dc0d9e2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

apps/common/handle/impl/text/zip_split_handle.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,19 @@ def is_image_name(name: str):
213213
# 回到文件头
214214
inner_file.seek(0)
215215
md_text = split_handle.get_content(inner_file, save_image)
216+
image_list = parse_md_image(md_text)
217+
for image in image_list:
218+
search = re.search("\(.*\)", image)
219+
if search:
220+
source_image_path = search.group().replace('(', '').replace(')', '')
221+
source_image_path = source_image_path.strip().split(" ")[0]
222+
image_path = urljoin(
223+
real_name, '.' + source_image_path if source_image_path.startswith(
224+
'/') else source_image_path
225+
)
226+
for img_model in image_mode_list:
227+
if img_model.file_name == os.path.basename(image_path):
228+
md_text = md_text.replace(source_image_path, f'./oss/file/{img_model.id}')
216229
break
217230

218231
# 如果没有任何 split_handle 处理,按文本解码作为后备

0 commit comments

Comments
 (0)