Skip to content

Instantly share code, notes, and snippets.

Created February 17, 2022 15:46
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
//get all md files in vault
const files = app.vault.getMarkdownFiles()
//create an array with the filename and lines that include the desired tag
let arr = => {
const content = await app.vault.cachedRead(file)
//turn all the content into an array
let lines = await content.split("\n").filter(line => line.includes("- [?]"))
return ["[["".")[0]+"]]", lines]
//resolve the promises and build the table
Promise.all(arr).then(values => {
//filter out files without "ad-question" and the note with the dataview script
const exists = values.filter(value => value[1][0] && value[0] != "[[dataviewjs-testing]]")
dv.table(["file", "lines"], exists)
Copy link

JWolfcat commented Feb 23, 2023

1st of all thanks for this
I've being searching for this a long time, and it lead me to this:

WHERE contains(status, "?")

This can make the same as yours (Showing only the ?, i, *....) but easily you can filter by file, which I prefer, because I use this in a specific section of my vault and I dont want it to show every "alternative task" in the vault, but an specific #.
It would be like this:

FROM #YourChoice
WHERE contains(status, "?")

And if you want a list of all alternative tasks together

WHERE checked AND !completed

And I love this because I don't know js, and this just uses the dataview syntax which is really easy to remember..
This could be old news for you, but for me is a long time goal achieved.

Thanks again, without yours I wouldn't had ever start looking for this one

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