Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 header transclusion #533

Merged
1 commit merged into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading