Skip to content

fix: allow multiple same-page transclusions with different sections#2311

Open
andweeb wants to merge 1 commit intojackyzha0:v4from
andweeb:v4
Open

fix: allow multiple same-page transclusions with different sections#2311
andweeb wants to merge 1 commit intojackyzha0:v4from
andweeb:v4

Conversation

@andweeb
Copy link
Copy Markdown

@andweeb andweeb commented Feb 20, 2026

Description

When a page embeds two different sections from the same note (e.g., ![[Note#Section A]] and
![[Note#Section B]]), the second transclusion is incorrectly flagged as circular. This happens because the visited set in renderTranscludes tracks targets by slug alone, so the second embed of the same file is treated as a cycle even though it references a different section.

The fix here includes the block/section reference (dataBlock) in the visited key so that different sections of the same page are treated as distinct transclusion targets. Full-page transclusions (no section reference) still use the slug alone, preserving circular reference detection for actual cycles.

FYI there are still edge cases where non-circular transclusions are falsely flagged. For example, embedding the same section twice on one page, or diamond patterns where two different transclusions both embed the same target. That seemed like a lot more work to fix (and maybe even unrealistic/invalid use cases), so this PR is just scoped to addressing my personal scenario :)

Example

Here is an instance in which I've observed this occurring for Mexico-Trip.md in my Obsidian vault (notice the "Circular transclusion detected" error at the bottom):
Screenshot 2026-02-18 at 8 12 41 PM

Here's the underlying relevant markdown snippet:

#### Mérida Day Trip
![[Merida Day Trip#MEX to MID]]

![[Merida Day Trip#MID to MEX]]

I inspected the logs and found this:

Feb 18 19:05:17 notes quartz-build[573478]: Warning: Skipping circular transclusion: Personal/Places/Mexico/Mexico-Trip -> Personal/Places/Mexico/Merida-Day-Trip

After applying the fix in this PR, I'm able to correctly render the two sections:
Screenshot 2026-02-18 at 8 46 38 PM

When a page embeds two different sections from the same note (e.g.,
`![[Note#Section A]]` and `![[Note#Section B]]`), the second transclusion
is incorrectly flagged as circular. This happens because the `visited` set
in `renderTranscludes` tracks targets by slug alone, so the second embed
of the same file is treated as a cycle even though it references a
different section.

Include the block/section reference (`dataBlock`) in the visited key so
that different sections of the same page are treated as distinct
transclusion targets. Full-page transclusions (no section reference) still
use the slug alone, preserving circular reference detection for actual
cycles.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 20, 2026

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
quartz ✅ Ready (View Log) Visit Preview fc5a1f4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant