Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heading-Hierarchy to organize List Items and Tasks #2325

Open
10 tasks
SpocWeb opened this issue May 6, 2024 · 0 comments
Open
10 tasks

Heading-Hierarchy to organize List Items and Tasks #2325

SpocWeb opened this issue May 6, 2024 · 0 comments
Labels
feature-request New feature or request.

Comments

@SpocWeb
Copy link

SpocWeb commented May 6, 2024

Currently List-Items and Tasks are organized by their Indenting Hierarchy.

This is fine when you use Outlining for organizing your Files.

But Outlining is quite restrictive with empty Lines, Tables, Images, Blocks etc.

Therefore some people like me rather use Headings,
which can form an alternative Hierarchy between List Items, even when they are not indented.

It would be nice to have this alternative Hierarchy available in dataview,
preferably even with nested Items, as they are in Tasks and List-Items.

If this is too much of a change or unwanted, it would be helpful
to have at least the nested Headers attached to each List-Item.

I have prepared a possible Pull-Request as a Proof of Concept:
master...SpocWeb:obsidian-dataview:master
It adds a new "headings": HeadingCache[] Element to each Task and List-Item
wich contains the XPath of the Headings it is located in.

The code is very efficient. After the Section is determined, which already happens now,
it just continues to go up the Header-List, collecting Headings, until the beginning or it encounters a Heading1,
so it should have no measurable impact.

I was not sure how to serialize() this new headings Element,
therefore I convert it into a List of the Heading-Strings
prepended with '#'s according to the Heading Level.

This is a minimal change which allows me, in a first Step
to group Tasks and Lists by the Headings they are nested in:

Input-File: pbj.md

Peanut Butter and Jelly

Level2

Ingredients

  • Bread
  • Marmelade
  • Peanut Butter
  • Jelly

anotherHeading2

Instructions

  1. Go hog wild
  2. numbered
  3. Numbered Task 3
  4. unnumbered

Query:

task
where meta(section).subpath 
group by headings

Result:

  • Peanut Butter and Jelly

  • Ingredients

(4)

  • Bread
  • Marmelade
  • Peanut Butter
  • Jelly

  • Peanut Butter and Jelly

  • Instructions

(1)

  • Numbered Task 3
@SpocWeb SpocWeb added the feature-request New feature or request. label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request.
Projects
None yet
Development

No branches or pull requests

1 participant