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

Transclusions are performed in code blocks #599

Open
tyler-dot-earth opened this issue Jun 2, 2024 · 2 comments
Open

Transclusions are performed in code blocks #599

tyler-dot-earth opened this issue Jun 2, 2024 · 2 comments

Comments

@tyler-dot-earth
Copy link
Contributor

tyler-dot-earth commented Jun 2, 2024

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
Copy link
Contributor Author

tyler-dot-earth commented Jun 11, 2024

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: #596 (review)

@tyler-dot-earth tyler-dot-earth changed the title Publication center diff performs transclusion replacements in code blocks Transclusions are performed in code blocks Jun 11, 2024
@oleeskild
Copy link
Owner

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.

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

No branches or pull requests

2 participants