I have been summarizing scientific articles in obsidian using a simple template. This template has several markdown sections, such as #Meta Data, ## Key Figures and Tables, and ## Summary. I would like to produce a table that contains the article name and summary for each article.
Things I have tried
Using dataviewer I have tried to construct a query that accomplishes this:
table file.link as Article, regexmatch(“## Summary\n(.*)”, this.file.content) as Summary
from “Paper Summaries/Articles”
where regexmatch(“## Summary”, this.file.content)
But I return no results.
List
from “Paper Summaries/Articles”
Provides the list of my articles, but the additional regex matching produces no results. I can’t seem to get this portion to work. Can someone point me in the right direction?
I have found a solution to my problem. This dataviewerjs worked for what I needed:
// Specify the folder containing the notes
let folderPath = "Paper Summaries/Articles";
// Fetch all notes from the specified folder
let pages = dv.pages(`"${folderPath}"`);
// Check if any notes are found
if (pages.length === 0) {
dv.paragraph(`No notes found in folder: ${folderPath}.`);
} else {
// Loop through each note to find the "## Summary" section
for (let page of pages) {
// Load the content of the note
let content = await dv.io.load(page.file.path);
// Check if "## Summary" exists in the content
let summaryRegex = /## Summary\s+([\s\S]*?)(?=\n## |\n---|\n*$)/; // Regex to match the content under "## Summary"
let match = content.match(summaryRegex);
// If a match is found, display the summary content
if (match && match[1]) {
dv.header(4, `Summary from ${page.file.name}`); // Create a subheading for the summary
dv.paragraph(match[1].trim()); // Display the captured content
} else {
dv.paragraph(`No summary found in ${page.file.name}.`);
}
}
}