Using dataview to highlight lines

What I’m trying to do

I’m trying to highlight parts of a markdown document, and also show highlights from entire document at the top.

Things I have tried

I setup a hotkey via quick-add macro to move selected content inside [highlight :: ], which I can then query with dataview LIST. This is working okay, however, the LIST query returns highlighted lines in random order, with order changing every dataview refresh. Is there a way to LIST attributes in order they appear in document ?

Basically, I have a document containing [highlight:: first highlight], …some text…
[highlight:: second highlight], …some more text… [highlight:: third highlight]. With a LIST highlight query, I am getting all the highlights, but not in order. Is there a way to make sure they appear in order ?

Having a note with:

[highlight:: first highlight]
[highlight:: second highlight]
[highlight:: third highlight]

You can try

flatten highlight as h
sort h DESC```


* note: third highlight
* note: second highlight
* note: first highlight
1 Like

What kind of query did you do? If I do this query:

LIST aHighlight
WHERE file = this.file
FLATTEN highlight as aHighlight

It do come out in order for me. Even without the FLATTEN it comes out in the order they’re defined in the file.

If you add the SORT h (or SORT aHighlight) it’ll sort them according to alphanumerical value of the highlight, which might not be the order you’ll want them to have.

1 Like

Does the result order remain stable in your setup on adding/editing highlights ?
My query is a simple LIST from this.file without FLATTEN or SORT. Results are initially in order defined in file, but on editing/adding more highlights this order is being scrambled. Not sure if it’s due to any other plugin on my setup.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.