Skip to content

Commit

Permalink
fix: πŸ› header transclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
uroybd committed Dec 28, 2023
1 parent f047cd6 commit 773c1c1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/compiler/GardenPageCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`;
Expand Down Expand Up @@ -434,7 +439,7 @@ export class GardenPageCompiler {
);

const headerSection = header
? `$<div class="markdown-embed-title">\n\n${header}\n\n</div>\n`
? `<div class="markdown-embed-title">\n\n${header}\n\n</div>\n`
: "";
let embedded_link = "";

Expand Down

0 comments on commit 773c1c1

Please sign in to comment.