Bug report Dataview Syntax Error
See original GitHub issueWhat happened?
I’m trying to get all the text that falls under a specific header in all daily notes and compile that text from under each header into one note. The header is second level ## 3 Sentences or more on the day. Daily notes are tagged with #daily in the note and in YAML front matter.
I’ve just installed Dataview and looked at the readme and below the query is what I’ve come up with so far. Is there an error in what I wrote here, or some setting I’m missing/bug with Dataview? Inline JavaScript Queries is enabled. Have a lot of ideas with Dataview so really keen on getting this going. Thanks!
```dataviewjs const header = '## 3 Sentences or more on the day'
// 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 return text from the Summary header, until it reaches // the next header, a horizontal line, or the end of the file const regex = new RegExp(`\n${header}\r?\n(.*?)(\n#+ |\n---|$)`, 's')
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 const summary = contents.match(regex) if (summary) { // Output the header and summary dv.header(2, file.basename) dv.paragraph(summary[1].trim()) } }
```
Error message Evaluation Error: SyntaxError: Unexpected token ‘)’ at DataviewInlineApi.eval (plugin:dataview:19669:21) at evalInContext (plugin:dataview:19670:7) at asyncEvalInContext (plugin:dataview:19677:16) at DataviewJSRenderer.render (plugin:dataview:19701:19) at DataviewJSRenderer.onload (plugin:dataview:19285:14) at DataviewJSRenderer.e.load (app://obsidian.md/app.js:1:730611) at t.e.addChild (app://obsidian.md/app.js:1:731035) at Object.addChild (app://obsidian.md/app.js:1:1616830) at DataviewApi.executeJs (plugin:dataview:20210:19) at DataviewPlugin.dataviewjs (plugin:dataview:20708:18)
DQL
No response
JS
No response
Dataview Version
0.5.46
Obsidian Version
0.15.9 (installer 0.14.5)
OS
MacOS
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
The main issue is there are a bunch of squished lines (which have ~8-10 lines of code all on the same line, stuck behind
//
comments) - every line of code should be on a different line in the codeblock.I’ve sort of got what I need to do with embedded queries. Will try doing it with Dataview JS when I have time to read up on it more. Thanks for taking a look.