Make embedded query look like embedded blocks

Things I have tried

I’ve looked through many CSS snippets and plugins and could’t find anything that provides the functionality I seek.

What I’m trying to do

I want to style an embedded query so that it looks (and behaves) like a series of embedded blocks. For example, let’s say I have an #example tag that appears in 2 different notes/blocks: Note 1#^1a234b and Note 2#^5c678d. I would like to embed the following search:

```query
tag:#example
``

and style the results so that it looks like I had written:

![[Note 1#^1a234b]]
![[Note 2#^5c678d]]

I would prefer to use an embedded query for this over dataview because, even if dataview could retrieve an entire block, I wouldn’t be able to click on the block to open/edit the note of origin in a new window.

Is this possible? Or is there a workaround that would give me similar results?

4 Likes

useful!

There are many thing which might go wrong in this seemingly simple scenario:

  • It’s in no way given that the search for a tag results in a block which is properly tagged with a blockId. Most likely, it’s not tagged
  • The query search will only list the filename, not an embedded version of the search
  • Using dataview, as you’ve stated, even if the two above weren’t an issue, is somewhat faulty when it comes to embedding

Can these issues be countered? Not easily. The last one regarding dataview and embedding can be handled by using a combination of Templater and dataview, but it’ll not handle the limit to only embed the block. It’ll most likely embed the entire note.

There are three ways I can this coming to life:

  1. Change so that the entire block is an inline field, and can be lifted out using field searches, and not embedding
  2. Change syntax to list syntax, so that we can access the lists using dataview (and potentially Templater (or QuickAdd ?)), and produce the embed links with blockIds
  3. Manually scanning files with the given tag, and pull out sections having blockIds, to then produce the links

Given a change in format to list format, then a query similar to the following could be used. Just a mockup of the embed link is produced in this example, and I’m using #f53209 as the tag:

```dataview
LIST WITHOUT ID "" + file.name + "#^" + item.blockId + ""
FROM #f53209
FLATTEN file.lists as item
WHERE contains(item.tags, "53209") AND item.blockId
```

In my test setup I’ve got four references to the #53209, but only two of them are within a list item with a blockId, so my output became:

image

I’ve not written up any examples of the two other methods, but they’re doable, albeit with some work to get them working.

try the obsidian-query-control plugin.

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