Trying to retrieve Callout with DataView

I tried to see any examples on the internet or the documentation on DataView Plugin, but didn’t found any resource.

I’m willing to query specific type of callouts for my weekly routine.

Any guidance to to do that would help.

Thanks!

2 Likes

Could you describe a bit more what you are trying to do? Do you want to display the entire callout? A copy of it? Some pieces from it?

dataview looks for field names & values in your note, not arbitrary strings pf text like a callout name. The built-in Obsodian search can do text strings though! Could using the built-in Obsidian search for the name of the call-out work? (You can make search query blocks like dataview blocks.)
Another alternative: Could embedding the callout work?

I want to do simple query to get a lists of all the “questions/achievements/failure…” that I had in particular week.

Can you elaborate what do mean when " embedding the callout work?"

The search is nice, but I didn’t found a way to show the whole text of the callouts, nor a way to add time block. Is there to way to perform that?

2 Likes

I have the same idea / demand: the different callout types should be actionable / retrievable like additional task types.
Checklist allows different task lists by tagging, but callout type is already like an implicit “tag”.

I am to looking for a way to show specific callouts or admontions (like question, failure) and list and group similar callouts/adminitions in a separate ‘output-card’:

List of MyDangers:

  • some danger, link to card
  • some other danger, link to card

Where ‘dangers’ can be triggered from cards using admonitions like this:

```ad-danger
some danger
```

OR by cards using callouts like this:

> [!DANGER]
> some other danger

I’m trying to accomplish this with Dataview. Unfortunately “```ad-failure” so far :wink:
Any ideas?

You can use the method here to extract the list of achievements etc from your callouts:

You’ll need to change the regex to match what you’re looking for, but the method is the same.

Thank you for reaching out. I (yet) don’t understand how this works if I have more than one admonition/callout in a card and multiple bullets, for instance:

 ``` ad-abstract
 title: atomic summary
 * understanding how to query
 * another bullet
 ```
 ``` ad-danger
 title: main challenge(s)
 * some danger
 * some other danger
 ```

  1. First things first. For testing I have added this into a card ‘exploring list with dataview’:
    ## Gratitude
    ## what happend today?
    ## here’s what happened
    ## here’s what also happened

  2. Also for testing, I’ve added an ‘else’:

    // Output the header
    dv.header(2, file.basename)
    if (summary) {
     // Output the header and summary
     // dv.header(2, file.basename)
     dv.paragraph(summary[1].trim())
    } else {
     dv.paragraph(“some text”)
    }

Now I indeed get a list of all my card-titles & ‘some text’.
Unfortunately the card ‘exploring list with dataview’ - containing the \ ## here’s what happened - doesn’t show \ ## here’s what happened.

Any thoughts, before I will tweak the regex-function for listing the <li>'s under “ad-danger” and/or [!DANGER]… ??

Here’s a working demo using your specific example:

Dataview code and downloadable demo vault

2 Likes

Like a charm!
I replace (\w+) with the type of admonition, to list these per type.
I.T.H.A.N.K.Y.O.U. for the teaching.

Is there a way to make this pull multiple admonitions from the same note? right now it only pulls the first one found.
side Note: It also hates nested admonitions but I don’t currently have a need for those.

Sure, just change the first regex to be a global regex ('g'), and then loop through the results.

Demo vault updated: Extract the contents of callout boxes from daily notes

```dataviewjs
// You can update this to filter as you like - filtering for just your daily notes would be good
const pages = dv.pages('#daily')

// This regex will find the contents of a specifically formatted callout
const regex = /\n```ad-(\w+)\r?\ntitle:(.+?)\r?\n(\*.+?)```/

const rows = []
for (const page of pages) {
    const file = app.vault.getAbstractFileByPath(page.file.path)
    // Read the file contents
    const contents = await app.vault.read(file)
    // Extract the summary via regex
    for (const callout of contents.match(new RegExp(regex, 'sg'))) {
        const match = callout.match(new RegExp(regex, 's')) 
        rows.push([match[2], match[1], match[3], page.file.link])
    }
}

dv.table(['Title', 'Type', 'Bullets', 'Link'], rows)
```
1 Like