Skip to content

Instantly share code, notes, and snippets.

@martonfekete
Created May 4, 2023 11:54
Show Gist options
  • Select an option

  • Save martonfekete/7c7ceda239c12e6f58f3461c5018a540 to your computer and use it in GitHub Desktop.

Select an option

Save martonfekete/7c7ceda239c12e6f58f3461c5018a540 to your computer and use it in GitHub Desktop.
Use Obsidian Dataview to collect all callouts from your files

Your table

// Get all pages
const pages = dv.pages()

// This regex will find the contents of the callout [!quote]
// If you want a different type to be found, update the "quote" to the corresponding callout format
const regex = /\s*\>\s*\[\!quote\]\n\s*>\s*(.*)\n/gm

const rows = []
for (const page of pages) {
  // Read the file contents
  const file = app.vault.getAbstractFileByPath(page.file.path)
  const contents = await app.vault.read(file);
  
  // Find quotes
  const quotes = contents.match(regex) || [];
  
  // Add all quotes to the rows
  if (quotes.length > 0) {
    rows.push([page.file.link, quotes.join('\n')])
  }
}

// Create table
dv.table(['Link', 'Quotes'], rows)
@saslaw
Copy link

saslaw commented Nov 3, 2025

This is so helpful, thank you! I'm trying to also sort the table by file creation date, and I'm struggling with the snippets I've found for sorting in the dataviewjs syntax. Do you have any suggestions for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment