How to retain (or apply) syntax highlighting to transcluded blocs

If I have a note, “My Code” that contains text like:




then I can transclude it and see the formatted result. But I can’t transclude just a single line, apparently because the entire set of lines is considered the one and only block. If I remove the formatting (e.i. ```) then I can reference the individual lines. But then they aren’t formatted. If I try to wrap the transclusion with formatting, then I see the literal text. e.g.:

![[My Code]]

and not the transcluded text.

How can I wrap a transcluded block with highlighting, and/or, how can I transclude blocks from within a formatted block of text?


Bump. Even if the answer is, “That isn’t possible”, it would be good to know!


Bump, bump… :slight_smile:

The lowest level you can transclude in Obsidian is a block, so you can’t split a block into smaller units when using normal means of transclusion.

This means that if you want to transclude a few lines from a code block, you need to split that code block into smaller units, and exclude one of those blocks.

Regarding formatting stuff which are transcluded, I think that’s just not possible due to the nature of transclusion as of now. That is, you could possible do something with using custom CSS, but …

Somebody are trying to get an option for transcluding stuff inline, but it’s an open question whether that’ll be a thing (and/ or when).

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.