AtrributeExtractors in V2

Converting the recent chat conversation to a forum post:
Custom Attribute Extractors seems to be along the list of features that got dropped when Silverbullet moved from v1 to v2. I started using custom attribute extractors to work around two problems:

  1. Establishing some connection between pages by using a link as an attribute. Links in frontmatter where not indexed originally.
  2. Easy navigation to the linked pages - simply adding the link in the page makes it clickable and thereby making navigation easy. If it also doubled up as an attribute of the page object, it becomes queryable as well, without having to match for it in the entire page text.

1 above seems to be fixed now, but 2 remains (links in frontmatter are not clickable, understandably so - it seems tricky). Furthermore, there were use cases that took it further like Obsidian Style Task Management. For objects like tasks that can have several attributes, the concise representation using emojis was definitely convenient. With Lua, I wonder if there is an elegant way of achieving the same functionality.

Attribute extractors are pretty much the only feature I’m still missing in v2. I used them a lot in v1 for my task-related workflows.

I’m not sure why it was dropped - maybe there were technical reasons, or perhaps it was just to simplify the codebase and make it easier to maintain. Either way, I’d definitely love to see them make a comeback. Big upvote from me! :blush:

3 Likes

Following Zef’s example here, I’m wondering if the same mechanism can be used to parse out attributes from the main text. But I can’t seem to get this:

local mt = {
  __index = function(self, attr)
    if attr == "pageDecoration" then
      return {
        prefix = "🎄 "
      }
    end
  end
}

index.defineTag {
  name = "tree",
  metatable = mt
}

#tree

Sup

${query[[from index.tag “tree” select {name=name, pageDecoration=_.pageDecoration}]]}

to work, in a new tag or on existing tags.

Another thing I miss: task:stateChangFired (not the exact name but you know the gist) event hook because I can’t automatically embed task complete time now anymore and many of the workflow is not that smooth. Even though to the end of the v1 lifespan that event still have some bug, but it is still helpful even it can’t be triggered over widget and query.

Turns out we might have a solution - still trying it out; but the metatable trick does seem to work.

2 Likes