How to merge text with same heading from different daily notes in weekly notes?

I’ve got some daily notes with the template including some headings:

heading1

text1
text2

heading2

text3
text2

what i want is to MERGE the text with same headings in my weekly notes automatically,
Now i’m using templators with following(to merge 7 days daily note with “heading1”):
![[<% tp.date.now(“YYYY-MM-DD”, 0, tp.file.title, “YYYY-WW”) %>#heading1]]
![[<% tp.date.now(“YYYY-MM-DD”, 1, tp.file.title, “YYYY-WW”) %>#heading1]]
![[<% tp.date.now(“YYYY-MM-DD”, 2, tp.file.title, “YYYY-WW”) %>#heading1]]
![[<% tp.date.now(“YYYY-MM-DD”, 3, tp.file.title, “YYYY-WW”) %>#heading1]]
![[<% tp.date.now(“YYYY-MM-DD”, 4, tp.file.title, “YYYY-WW”) %>#heading1]]
![[<% tp.date.now(“YYYY-MM-DD”, 5, tp.file.title, “YYYY-WW”) %>#heading1]]
![[<% tp.date.now(“YYYY-MM-DD”, 6, tp.file.title, “YYYY-WW”) %>#heading1]]
It looks a little ugly,if there is not text in some daily note,it also show a blank frame.

I also noticed the plugin Tasks which could do same thing more beautiful:

heading includes heading1
short mode
not done

but it only works with to-do tasks, not plain text.

Anyone has solutions? Thanks!!

A few questions for you: What do you want to be able to do with those “merged” in notes? Are you planning to edit them? Read/review them and then write about it in the weekly note? Analyze certain items in them?
What do the “merged” notes look like? Are they paragraphs of text like this forum post? Lists? Sentence fragments? Images? Pieces of knowledge? Facts about your day? …? (Or what do you imagine they will look like, if you don’t have too many yet?)

Sending a notification to @CawlinTeffid who tends to have good advice with this sort of question.

I have been summoned! :smiley:

1 Like

Does the Templater template not do what you want?

For shorter syntax you can do the same thing with the template date math of Periodic Notes, which based on your use of weekly notes, I assume you’re using. This probably has the same “blank frame if no text” problem.

![[{{date-6d:YYYY-MM-DD}}#heading1]]
![[{{date-5d:YYYY-MM-DD}}#heading1]]
![[{{date-4d:YYYY-MM-DD}}#heading1]]
![[{{date-3d:YYYY-MM-DD}}#heading1]]
![[{{date-2d:YYYY-MM-DD}}#heading1]]
![[{{date-1d:YYYY-MM-DD}}#heading1]]
![[{{date:YYYY-MM-DD}}#heading1]]

You might be able to use an embedded search to avoid the blank frame problem. I don’t have time right now to work out the syntax to select an entire section (section:("## heading1") only selects the heading), but I can come back to it later.

1 Like

This embedded search selects every line after heading1 and before heading2 in each day-file of the last week:

```query
(file:({{date-6d:YYYY-MM-DD}}) OR file:({{date-5d:YYYY-MM-DD}}) OR file:({{date-4d:YYYY-MM-DD}}) OR file:({{date-3d:YYYY-MM-DD}}) OR file:({{date-2d:YYYY-MM-DD}}) OR file:({{date-1d:YYYY-MM-DD}}) OR file:({{date:YYYY-MM-DD}})) /^(?<=#+ heading1\n\n)(.*\n)+(?=\n#+ heading2)/
```

A downside is that all the text will be highlighted (because it’s a search match). As code it’s at least as ugly as your Templater version, but it will ignore empty files.

EDIT: Another downside is that it shows the search term, which is big and gnarly. You could probably hide it with a CSS snippet, and maybe even target the specific pages you use them on. But you’d have to do it in a way that didn’t hide the ability to edit it.

Unfortunately the search syntax has to be all on 1 line, which makes it harder to read.

The first part of the search, between parentheses, is seven file: search selectors (1 for each day, using Periodic Notes template date math). separated from each other by OR.

The last part of the search, between slashes, is a regular expression (regex). It matches any line between heading1 and heading2.

  • The first part — (?<=#+ heading1\n\n) — is a “lookbehind assertion” that says to match text found after: 1 or more #, a space, the name of heading1, and 2 newlines.
  • The second part — (.*\n)+ — selects 1 or more lines which contain 0 or more characters.
  • The third part — (?=\n#+ heading2) — is a “lookahead assertion” that says to match text found before: a newline, 1 or more #, a space, and the name of heading2.
1 Like

If you use the dataview plugin, you could try doing it with inline metadata:

Heading 1
heading1:: text 1
heading1:: text 2

Heading 2
heading2:: text 3
heading2:: text 4, this can be multiline if you need it to be, it can keep going and going and I think until you do a line break, it should grab everything

And then pulling it in via something like this:

$=dv.list(dv.pages('"your/daily/note/folder"').where(p => p.heading1).sort(p => p.file.name, 'desc').map(p => p.file.link + " " + p.heading1));`

That will give you a list that looks something like:

  • link to daily note text 1
  • link to daily note text 2

You can use Templater to set the queries up in your weekly note.

1 Like

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