How can I make a dataview plugin display blocks?

How can I make a dataview plugin display blocks

How can I make a dataview plugin display blocks of text with a certain tag? I want blocks of text with tags, not links to files.

I think you’ll need js dataviewjs, but I haven’t yet figured it out.

I believe right now, the feature is not yet available. But it’s in pipeline (thanks @CawlinTeffid for the link). Right now your best bet is using query (not the best looking, but it gets u there. refer to Searching Tagged blocks - Resolved help - Obsidian Forum

1 Like

I’ve done something similar with the Obsidian search query, but haven’t figured it out yet with dataview.
Also, this is not for tags, but for a selection

Here’s what it looks like:
I have folder named: yourfoldername

I have 2 notes inside that folder with text in the following format:

Note1:

Test heading

  • test 1
    test 2

your-text-here
test 3

  • test 4
    ~~

Note 2:

Test heading

  • test 1

your-text-here

  • test 2
    test 3
    test 4
  • test 5

~~

any notes within that folder that have this command below will be included in the search embed.

``’ 'query
path:“yourfoldername” section:(your-text-here “-”)
'```
(the command syntax to open up and close the search query isn’t showing well)

The embed preview of this search query comes up in full with text
showing like this:

“path:“yourfoldername” section:(your-text-here “-”)”

yourfoldername/Note 1.md

  • test 1
    your-text-here
    -test 4

yourfoldername/Note 2.md

your-text-here

  • test 2
  • test 5

instead of “-” you could have a space in between like " " in order to include everything in the heading section that doesn’t have a bullet point but it looks a bit messy. It might be able to be solved with CSS edits though, but not sure yet. Also, if the “your-text-here” isn’t a heading, it will include everything within that heading even if it’s above it. Also “Your-text-here” should be unique or specific (for example, not just the words without hyphens like your text here), otherwise the words “your”, “text”, “here” will be included even if they are not in bullet lists.

This is where I found it for reference

by @CawlinTeffid

section:(your-text-here “-”)

just “-” might also get unwanted results like including notes with dates at the bottom.

So add a space to be more specific like "- "

For even more specific searches, see the “regex” / “regular expressions” section of the Search page in Help. It can be a bit involved but very useful.

@Lito To post code that includes code backticks, start each line with 4 spaces (in Obsidian you can also use a single tab but you can’t type tabs in the text box here). (Here I’ve wrapped the whole thing in another set of backticks, labelled as markdown to make it not turn red.)

    ```query
    path:“yourfoldername” section:(your-text-here “-”)
    ```
1 Like

Thanks for the tip!

That regex was a bit complicated since it was my first time… But I managed a makeshift way around to put a query embed inside my weekly note which includes a specific heading that occurs in all my daily notes with only to do tasks and other text under it. It does not include done tasks.

For example, inside my weekly note there is (let’s say it’s related to chores for simplicity):

Weekly Note

### Weekly-Task-1-1
- sweep and mop floors
- do laundry
- go grocery shopping

%%Here is where I put the query embed right under this list (still inside the weekly note)%%

   ```query
path:"Weekly Note" -file:"Weekly Note" (section:(### Daily-Task1-1-1 /^((?! \[\x] ).)*$/ 
    ```

This is what the embed query looks like based on the daily notes further below

YYYY/YYYY-MM/YYYY-MM-W/YYYY-MM-W-Daily Note 1.md
#### Daily-Task1-1-1
- [ ] mop
    - Here's some extra text
And more text
YYYY/YYYY-MM/YYYY-MM-W/YYYY-MM-W-Daily Note 2.md
#### Daily-Task1-1-1
- [ ] whites
- [ ] darks
YYYY/YYYY-MM/YYYY-MM-W/YYYY-MM-W-Daily Note 3.md
#### Daily-Task1-1-1
    - red delicious
    - macintosh 
- [ ] avocados 

And inside all my Daily notes there is ### Daily-Task1-1-1
So the headings in my different daily notes labeled Daily-Task1-1-1 are related to weekly task 1-1, not Weekly-Task 1-2.

Daily notes look like:

Daily Note 1

### Daily-Task1-1-1
- [x] sweep
- [ ] mop
    - Here's some extra text
And more text

Daily Note 2

### Daily-Task1-1-1
- [ ] whites
- [ ] darks
- [x] colors

Daily Note 3

### Daily-Task1-1-1
- [x] apples
    - red delicious
    - macintosh 
- [x] bananas
- [ ] avocados 

So the only issue is that the text indented under the done tasks stills shows up.

I also had to exclude the weekly note as part of that search (-file:“Weekly Note”) otherwise it interfered with other embeds of the Daily-Task1-1-1 heading that I had in different sections for other purposes of the weekly note.

Also, you wouldn’t by chance know how to include another heading inside that code for the query embed? Like if I wanted to included the Daily-Task1-1-1 heading but also another heading inside the daily notes. The search won’t let me include any child headings under Daily-Task1-1-1.

Just one point: if you use now the format of “tasks”, then you can use dataview (because it’s possible to filter task queries by section/heading).
I’m not fluent in search queries syntax, so I don’t know how to advise you in how to include multiple headings. But you can get that with dataview (with the bonus you can exclude done tasks)
Another point: for now, in dataview you also see all indented list under the tasks (they’re considered as subtasks… and there’s no way to separate parent/child tasks)

Answered my own question. There are two ways to add it. The first code block is more redundant but can be useful if you want to include certain text in one heading and not in the other. The second code block is specifically for my question.

    ```query
path:"Weekly Note" -file:"Weekly Note" (section:(### Daily-Task1-1-1 /^((?! \[\x] ).)*$/ OR #### My-Second-Heading1-1-1 /^((?! \[\x] ).)*$/)
    ```
    ```query
path:"Weekly Note" -file:"Weekly Note" section:((### Daily-Task1-1-1 OR ### My-Second-Heading1-1-1) /^((?! \[\x] ).)*$/)
    ```

Thanks for the tip. I’ll keep that in mind. But I also want to include text under the heading that isn’t in a bulleted list. For now, I don’t think dataview shows text other than tasks. But when it does, I’ll definitely switch to using it for this specific purpose.

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