Trying to retrieve Callout with DataView (New issues)

What I’m trying to do

I’m trying to use the method described here to pull specific callouts from my daily notes to a table. I have dataview plugin and am using Callout Manager to manage and create my callouts.

Things I have tried

I have tried the steps highlighted in the linked article and am getting this Evaluation Error

here is the code I’m running :

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

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

const rows = []
for (const callout of contents.match(new RegExp(regex, 'sg')) || []) {
    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[1], match[2], page.file.link])
    }
}

dv.table(['Term', 'Definition', 'Link'], rows)

Did you mean this instead:

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[1], match[2], page.file.link])
    }
}

JavaScript isn’t my thing, so someone with more knowledge would know better, but it looks to me like you meant to read the page contents then look inside of them for the callout contents.

1 Like

Yes this worked!! Thank you so much. I don’t know JavaScript at all, so I was just piecing together shit from other posts trying to get things to work.

1 Like