Include a part of a note in another note

Sometimes, we copy a part of a note into another Note. Admittedly, Internal Links with header support greatly reduced the problem. However, sometimes you just want contents instead of a file with dozens of links.

I want a way, IN ADDITION to internal links, to insert a section of one note into another.

Just as what #include does in c++ and various other languages.

For example, a file look like this

# Remarks & Caveats in cpp
---
## include guard
```cpp
#pragma once

//declaration

` `` // to put markdown in markdown you know
is not in CPP standard
use 
```cpp
#ifndef HEADER_FILE_NAME
#define HEADER_FILE_NAME

// declaration

#endif
` ``
instead

---

Could be written as

# Remarks & Caveats in cpp
---
?[[2020-06-24-CS32-Class-Note##Include guard]]

---

Also, a more advanced feature would be matching header levels.
In case in file 2020-06-24-CS32-Class-Note Include guard is actually a 3rd level header, maybe a syntax of remapping the headers should be included.

like this:

# Remarks & Caveats in cpp
---
?[[2020-06-24-CS32-Class-Note###Include guard##]]

---

As of syntax, I suggest:

?[[File###h3##]]

Component Meaning
?[[ start of insertion
File filename/name of note
### original header level (3)
h3 original header name
## after header level (2) (optional)
]] end

which would produce

##h3
Content of h3
2 Likes

oops, ![[internal link]] actually works very similar to what I want,
this feature is no longer necessary, would still be a nice addition since insert as attachment is a bit different than what I mean

4 Likes

Yep, that’s a transclusion.

3 Likes

+1 on this, at the sub-page level. We can already link reference to headers within a note even with alias text (as in [[page#myH1|alias for h1]]), but when you try to embed that same header reference it shows the entire page.

I suppose this is leading into wanting “block”-level granularity promoted in the product.

This works already: ![[Some note#some heading]].

Maybe the issue was your use of |? (The alias wouldn’t be used by an embed anyway.)

1 Like

Ah, you’re right. The alias changes the behavior, it and also doesn’t make sense as you point out. Thank you.

1 Like