obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

Ability to return paragraphs from a note with a particular tag in them

Open osharp opened this issue 3 years ago • 6 comments

I like to mark paragraphs of various types with a hashtag (for example, #try for an experiment, #idea for an idea I want to follow up on, #insight for insights worth returning to in a spaced repetition model, and so forth). There may be multiple instances within a particular note. I'd like to create a table of every such paragraph, organized by the note that it is in or as a flat list.

I have found two ways to do this in the current model, both a bit clunky:

  1. Make the paragraph a task. Then I used DataviewJS to pick out all the tasks that have the hashtag string in them:

dv.table(["Link", "Experiment"], myTasks.filter(t => t.text.includes("#try")) .filter(t => !t.completed) .map(t => [t.section, t.text]));

This is fine for things that are tasks (like #try), but the others aren't tasks and it's ugly in the original note.

  1. Add an extra prefix to the paragraph, so it can be picked out by a table query. For example, prefix the paragraph with "Core:: " and then run this query:

TABLE Core AS "Core Idea", file.mday.month + "-" + file.mday.day + "-" + file.mday.year AS "Updated" FROM #core WHERE !contains(file.path,"Template") and !contains(file.path,"Daily Pages")

This works, but is also clunky.

So, the request:

Could you add an ability to query for paragraphs containing a particular hashtag, at the scope of the paragraph and not at the scope of the whole note? It would be great if you could do it with a table query, to leverage all the power you've created for that, but JS would also work. And of course, if I'm missing something, open to other ideas!

Thanks for a really powerful plugin - it's been a game-changer in finding new ways to leverage Obsidian, for me.

osharp avatar Jan 03 '22 02:01 osharp

This functionality is incoming soon - all tag, metadata, and link references will include the paragraph that they came from.

blacksmithgu avatar Jan 08 '22 18:01 blacksmithgu

+1, I am trying to use DataView to annotate list items and paragraphs in my Daily Notes .e.g.,

- [meeting:: [[Person Name]]], spoke about ordering more books, left it with them

Then have an "index" on that person's own page that will show the text from each line of all Daily Notes that have that field in them. Much more useful in that case that a list of pages.

Very excited to see this is an upcoming feature. Nice work!

MattWilcox avatar Jan 14 '22 17:01 MattWilcox

+1 - a vital feature

aubreyz avatar Feb 26 '22 10:02 aubreyz

This functionality is incoming soon - all tag, metadata, and link references will include the paragraph that they came from.

Just curious - has there been any update on this? I've scanned the changelogs and haven't seen anything obvious in them that might match this?

MattWilcox avatar May 29 '22 23:05 MattWilcox

It hasn't appeared yet - I have pieces scattered about but have been focusing on some live preview improvements first and finally stabilizing Dataview Beta.

blacksmithgu avatar May 30 '22 08:05 blacksmithgu

+1, I am trying to use DataView to annotate list items and paragraphs in my Daily Notes .e.g.,

- [meeting:: [[Person Name]]], spoke about ordering more books, left it with them

Then have an "index" on that person's own page that will show the text from each line of all Daily Notes that have that field in them. Much more useful in that case that a list of pages.

Very excited to see this is an upcoming feature. Nice work!

Im trying to achieve exactly this, would be interesting to see if the official solution comes out soon!

iamashwin99 avatar Dec 12 '23 16:12 iamashwin99