From 773c1c1778e76a2c50f000dc894e4faaf55b0dd1 Mon Sep 17 00:00:00 2001 From: Utsob Roy Date: Thu, 28 Dec 2023 15:12:22 +0600 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20header=20transclusion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compiler/GardenPageCompiler.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/compiler/GardenPageCompiler.ts b/src/compiler/GardenPageCompiler.ts index 9b113f9a..1dc54acf 100644 --- a/src/compiler/GardenPageCompiler.ts +++ b/src/compiler/GardenPageCompiler.ts @@ -379,8 +379,13 @@ export class GardenPageCompiler { const refHeader = transclusionFileName.split("#")[1]; + // This is to mitigate the issue where the header matching doesn't work properly with headers with special characters (e.g. :) + // Obsidian's autocomplete for transclusion omits such charcters which leads to full page transclusion instead of just the heading + const headerSlug = slugify(refHeader); + const headerInFile = metadata?.headings?.find( - (header) => header.heading === refHeader, + (header) => + slugify(header.heading) === headerSlug, ); sectionID = `#${slugify(refHeader)}`; @@ -434,7 +439,7 @@ export class GardenPageCompiler { ); const headerSection = header - ? `$
\n\n${header}\n\n
\n` + ? `
\n\n${header}\n\n
\n` : ""; let embedded_link = "";