Louis/Thèse/Résumé lectures.md
2026-06-09 14:45:18 +02:00

50 lines
1 KiB
Markdown

```dataviewjs
const files = app.vault.getFiles()
.filter(file =>
file.path.includes("Thèse/Lectures/@") &&
file.extension === "md"
);
const rows = [];
for (const file of files) {
const content = await app.vault.cachedRead(file);
// Extract frontmatter block
const match = content.match(/^---\n([\s\S]*?)\n---/);
let fm = {};
if (match) {
fm = obsidian.parseYaml(match[1]) ?? {};
}
function getFields(content) {
const fields = {};
const regex = /^\*\*(.+?)\*\*::[ \t]*([^\n\r]*)$/gm;
let match;
while ((match = regex.exec(content)) !== null) {
fields[match[1]] = match[2].trim();
}
return fields;
}
const fields = getFields(content)
rows.push([
fields.Title ?? fm.title,
fields.FirstAuthor,
fields.Contribution,
fields.Year,
fields.Journal ?? "",
fields.Citekey,
dv.fileLink(file.path)
]);
}
dv.table(
["Title", "First Author", "Contrib.", "Year", "Journal", "CiteKey", "File"],
rows
);
```