oleeskild / obsidian-digital-garden

MIT License
1.36k stars 125 forks source link

Transclusions are performed in code blocks #599

Open tyler-dot-earth opened 4 months ago

tyler-dot-earth commented 4 months ago

If a code block contains Obsidian transclusion syntax, the publication center will show a diff that contains the full transclusion.

For example, assume you have a note embeds.md and then write a codeblock in a publishable note like this:

/* Increase <br> in ![[embeds]] */
.internal-embed br {
    margin: 1em 0;
    display: block;
    content: "";
}

While I believe #596 likely prevents actual transclusion upon publishing, it doesn't seem to have an effect on the diff produced in the publication center.

Related:

tyler-dot-earth commented 3 months ago

Update: transclusion is actually handled after the block-id replacements: https://github.com/oleeskild/obsidian-digital-garden/blob/01d12de4800b899529f1b3161a14e9e59fe9c801/src/compiler/GardenPageCompiler.ts#L106-L107/ so this will NOT be fixed in #596 but the solution would/could be similar... but a DRYer way to handle both seems sensible.

The snapshot in #596 contains evidence of #599's bug: https://github.com/oleeskild/obsidian-digital-garden/pull/596#pullrequestreview-2109253940

oleeskild commented 3 months ago

Nice catch. Agreed. I think your solution, where we exclude the codeblocks, do our various transformations and then reintroduce the codeblocks at the end would fix most of the issues with codeblocks. I'll merge in your other PR for now. If you want to give implementing a fix for this issue a go, I'd be happy to accept a PR.