shabegom / buttons

Buttons in Obsidian
The Unlicense
455 stars 47 forks source link

Relative or searchable line numbers #165

Open holroy opened 1 year ago

holroy commented 1 year ago

I'm using a button to forcefully refresh a dataviewjs query like the following:

```button
name Refresh
type line(8) text
action ```dataviewjs
replace [8,8]

This button works beautifully in that given file with those given line numbers. But I'm missing an option (or just don't know how to do it) to make the button work related to its defintion. I would love some syntax like the following:
name Refresh
type line(+1) text
action ```dataviewjs
replace [+1,+1]


Where `+1` would refer to the first line _after_ the button, (and potentially `-1` would refer to the line in front of the button). Such a syntax would also allow for the button to replace stuff like: `[+1, 1000]` which essentially would replace the rest of the file.

An alternate syntax (which would be nice but maybe harder to implement), would be something like `[/%%pre%%/,/%%post%%/]` which would do a search for `%%pre%%` and `%%post%%` and replace everything between those line numbers.

----

**Are either of these possible in the current situation, with just me not knowing the correct syntax, or would it be possible to implement either (or both) of them?**