mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: enhance image path handling in markdown processing
--bug=1064136 --user=刘瑞斌 【工作流知识库】上传zip文件,文件中的图片内容没有写入知识库 https://www.tapd.cn/62980211/s/1806941
This commit is contained in:
parent
9d8d395087
commit
dc0d9e29ce
|
|
@ -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 处理,按文本解码作为后备
|
||||
|
|
|
|||
Loading…
Reference in New Issue