fix:修复图片和双链有时会冲突的问题 - #50
Open
ckyFi9zero wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修改内容
通过判断引用目标的图片扩展名,区分 Obsidian 中的文档引用和图片引用,避免将图片或非文档嵌入语法错误地按文档链接处理。
主要修复了以下两个问题:
Bug 1: 文档嵌入语法被错误转换为 Markdown 图片语法
问题场景
Obsidian 原始内容:
旧版本处理流程:
/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g只匹配[[...]],不会捕获前面的!title = "我的文档",originalText = "[[我的文档]]"[[我的文档]]→[我的文档](飞书URL)![[我的文档]]→问题影响
会被识别为 Markdown 图片语法,导致飞书尝试将文档链接当作图片加载,最终显示“图片加载失败”。Bug 2: 图片引用因模糊匹配触发无关文档误上传
问题场景
文件库结构:
Obsidian 原始内容:
旧版本处理流程:
[[架构图.png]]title = "架构图.png"findFileByTitle("架构图.png")架构图.png的文档"架构图.png".includes("图")返回true图.md图.md被误上传,而真正的图片架构图.png没有被正确处理修复方式
在处理 WikiLink 前增加图片扩展名判断:
![[文档]]被错误转换成 Markdown 图片语法测试场景
已验证以下场景:
![[我的文档]]不会被错误转换为![[架构图.png]]不会触发文档模糊匹配图.md和架构图.png时,不会错误匹配并上传图.md