From ffbc2c176a1f069c893866956c35928e17fa5fa9 Mon Sep 17 00:00:00 2001 From: RuanXinyu <1096421257@qq.com> Date: Tue, 20 Feb 2024 20:12:55 +0800 Subject: [PATCH] fix document rendered repeatedly bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When "`![[]]`或者`[[]]`" exists in markdown, the document is rendered repeatedly, because if the path passed to the getFirstLinkpathDest function is an empty string, the current document is returned. --- src/compiler/GardenPageCompiler.ts | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/compiler/GardenPageCompiler.ts b/src/compiler/GardenPageCompiler.ts index 1dc54ac..e32805e 100644 --- a/src/compiler/GardenPageCompiler.ts +++ b/src/compiler/GardenPageCompiler.ts @@ -247,7 +247,10 @@ export class GardenPageCompiler { headerSplit.length > 1 ? `#${headerSplit[1]}` : ""; } const fullLinkedFilePath = getLinkpath(linkedFileName); - + + if (fullLinkedFilePath === "") { + continue; + } const linkedFile = this.metadataCache.getFirstLinkpathDest( fullLinkedFilePath, file.getPath(), @@ -310,7 +313,10 @@ export class GardenPageCompiler { const transclusionFilePath = getLinkpath(transclusionFileName); - + + if (transclusionFilePath === "") { + continue; + } const linkedFile = this.metadataCache.getFirstLinkpathDest( transclusionFilePath, file.getPath(), @@ -511,7 +517,10 @@ export class GardenPageCompiler { .substring(svg.indexOf("[") + 2, svg.indexOf("]")) .split("|"); const imagePath = getLinkpath(imageName); - + + if (imagePath === "") { + continue; + } const linkedFile = this.metadataCache.getFirstLinkpathDest( imagePath, file.getPath(), @@ -556,6 +565,9 @@ export class GardenPageCompiler { continue; } + if (imagePath === "") { + continue; + } const linkedFile = this.metadataCache.getFirstLinkpathDest( imagePath, file.getPath(), @@ -602,6 +614,9 @@ export class GardenPageCompiler { .split("|"); const imagePath = getLinkpath(imageName); + if (imagePath === "") { + continue; + } const linkedFile = this.metadataCache.getFirstLinkpathDest( imagePath, file.getPath(), @@ -637,6 +652,9 @@ export class GardenPageCompiler { const decodedImagePath = decodeURI(imagePath); + if (decodedImagePath === "") { + continue; + } const linkedFile = this.metadataCache.getFirstLinkpathDest( decodedImagePath, file.getPath(), @@ -716,6 +734,9 @@ export class GardenPageCompiler { const imagePath = getLinkpath(imageName); + if (imagePath === "") { + continue; + } const linkedFile = this.metadataCache.getFirstLinkpathDest( imagePath, @@ -789,6 +810,9 @@ export class GardenPageCompiler { const decodedImagePath = decodeURI(imagePath); + if (decodedImagePath === "") { + continue; + } const linkedFile = this.metadataCache.getFirstLinkpathDest( decodedImagePath,