Reference Position is wrong, if more than one Object within one CodeBlock

I stumbled uppon this thing last days and i cant figure it out if it’s a feature or a bug.

So it goes like this:

I have a Bunch of Persons as Objects in a page within a #person codeblock like described in the silverbullet manual with --- as delimiter between the persons:

name: Mary
birthday: 2000-02-14 
---
name: Peter
birthday: 1986-05-06 
---
name: John
birthday: 1996-06-13
---
name: Anna
birthday: 1991-12-17
---
name: Jim
birthday: 1983-09-28
---
name: Susan
birthday: 1987-07-10

When I query the table of persons I get following references for each person:

The first one is correct (the x-th character on the page) but the following person has the ascending number after the first so Peter has the pos: 77, John pos: 78 and so on. When i create a link to that person using this reference it jumps to the 77th character of the page, and not to John.

I found a workaround to this by adding each person to its own #person codeblock like this:

name: Mary
birthday: 2000-02-14
name: Peter
birthday: 1986-05-06 

name: John
birthday: 1996-06-13

name: Anna
birthday: 1991-12-17

name: Jim
birthday: 1983-09-28

name: Susan
birthday: 1987-07-10

And if I query the persons, I get the correct reference positions so i can easily link that person using its reference position:

@zef is this an intended feature of referencing a person by its position within the codeblock, or is this a know bug and it will be fixed in the future? I looked for related issues on github, but didn’t found anything related to this.

It’s a case of “I was lazy and this worked, and nobody ever complained about it.” I think I may just have adding 1 to each document inside such a block, just to make the refs unique. It breaks the assumption that those references point to the correct location and likely you’re the first to ever notice. I don’t think these data blocks are heavily used.

So it’s a bug. Could you create a GitHub issue for it?

1 Like

Thanks for the quick response. At least now I know I didn’t do anything wrong! I understand that this issue might not have come up before if the feature isn’t heavily used, but it does make me wonder, what are people using instead of this, or how are they using it?

Currently, I’ve been using it in the following scenarios (since I discovered SB two weeks ago):

  • For contacts, I use it as one big block containing all my contacts’ birthdays and other data (similar to my first example above), where the references currently don’t work properly.
  • And I also use it as sort of data sheets for different projects, with separate blocks on different pages, like you mentioned.

That said, I really think having unique and accurate references for each object within a block would be helpful for anyone relying on structured data setups like this. It would make querying and linking far more predictable, which could benefit users exploring advanced features in Silverbullet.

I’ll go ahead and create a GitHub issue for this.

Thanks again for your great work on Silverbullet—it’s a fantastic tool!

I don’t know what other people do, but what I tend to do myself is just create a page per contact and use frontmatter to add attributes. This allows me to use the page content for notes on that specific person.

2 Likes