obsidian-tasks-group / obsidian-tasks

Task management for the Obsidian knowledge base.
https://publish.obsidian.md/tasks/
MIT License
2.24k stars 221 forks source link

When tasks are in callouts, any preceding heading in the callout is not read by tasks, so 'group by heading' uses the previous heading outside the callout - or '(No Heading)' if none #1989

Open declan-morris opened 1 year ago

declan-morris commented 1 year ago

Please check that this issue hasn't been reported before.

Expected Behavior

When using the group by in a query, the header should be displayed in the query view if the header is in a callout with the tasks.

Current behaviour

When you query a task that is in a callout and group by header the resulting display shows the header as No Heading

Steps to reproduce

  1. Create a note called "Untitled" at the root of the vault
  2. Paste the below example and notice that the header does not appear in the query and instead appears as (No Heading) rather than Header as in the callout
```dataviewjs
const query = `
not done
path includes ${dv.current().file.path}
# you can add any number of extra Tasks instructions, for example:
group by heading
`;

dv.paragraph('```tasks\n' + query + '\n```');
```

```tasks
not done
path includes Untitled
group by heading
```

> [!todo]- Title
>## Header
>- [ ] Task 1
>   - [ ] Sub task
>- [ ] Task 2

image

image

Which Operating Systems are you using?

Obsidian Version

1.3.4

Tasks Plugin Version

3.8.0

Checks

Possible solution

Potentially use the title of the callout rather than the header in the callout? This could cause issues with multiple headers in a single callout but may be easier to implement? Not sure, it would work for my use case but perhaps not for others.

Update - After discussing with maintainers there appears to be discrepancy with how obsidian itself is interpreting headers.

See here for screenshot of this behavior https://github.com/obsidian-tasks-group/obsidian-tasks/issues/1989#issuecomment-1568907333

claremacrae commented 1 year ago

Thanks for using Tasks.

There is content in your screenshots that is not provided as text for me to copy, so for reasons explained in the following post, I am unable to investigate:

https://publish.obsidian.md/tasks/Support+and+Help/Report+a+Bug

If you can provide full text, and full numbered steps for a reproduction, as per the above, I will willingly have a look when I have time.

Thank you.

declan-morris commented 1 year ago

You can probably ignore the dataviewjs query as the much simpler example does not work, happy to provide it as well below for completeness.

  1. Create a note called "Untitled" at the root of the vault
  2. Paste the below example and notice that the header does not appear in the query and instead appears as (No Heading) rather than Header as in the callout
```dataviewjs
const query = `
not done
path includes ${dv.current().file.path}
# you can add any number of extra Tasks instructions, for example:
group by heading
`;

dv.paragraph('```tasks\n' + query + '\n```');
```

```tasks
not done
path includes Untitled
group by heading
```

> [!todo]- Title
>## Header
>- [ ] Task 1
>   - [ ] Sub task
>- [ ] Task 2
ilandikov commented 1 year ago

@declan-morris I tried this on my side and I confirm the behavior, however this seems to be aligned with what Obsidian and markdown considers a heading - something that starts with # and not >#.

You may see on my screenshot that the second heading doesn't appear in the file outline on the right pane of Obsidian.

Снимок экрана 2023-05-31 в 00 34 04

testfile.md contents:

## header without callout
> ## header with callout

- [ ] #task test task

```tasks
not done
path includes testfile
group by heading
declan-morris commented 1 year ago

@ilandikov Interesting, yeah you're right it only appears on the Outline when it's outside of a callout.

I expected that it was working correctly as the reader view does seem to understand the different headers as it renders them as headers inside and outside the callout as you can see below.

image

What would you like to do, close this? Not sure what the expected behavior should be now. Given that obsidian itself seems inconsistent in its interpretation.

Should this instead be a feature request to use the callout title as a psudo header?

claremacrae commented 1 year ago

Thank you both for the replies...

Firstly, @declan-morris please could you update the summary so that it correctly reflects the information discovered?

It's currently rather non-specific - it would help if it said what was in the call-out - and was more specific than 'does not work'.

Then, let's leave it open for now, as I may write it up in the docs as a known limitation, and this being open will remind me to do so.

It's certainly true that callouts are a corner-case in terms of how Obsidian parses them, compared to simple markdown. They have taken up quite a lot of support time - hence my inclination to just document the limitation.

ilandikov commented 1 year ago

@declan-morris oh, cool, I actually don't use the reader view, so thanks for this insight. I tried >## header in https://markdownlivepreview.com and it recognises the header correctly... So I agree that there is an issue somewhere. Maybe the way to go is to open an issue on the Obsidian forum and link it here. When Obsidian team decides what to consider a header or not, Tasks plugin shall follow that.

But the final decision is up to @claremacrae. I'm just proposing ideas =)

claremacrae commented 1 year ago

Maybe the way to go is to open an issue on the Obsidian forum and link it here. When Obsidian team decides what to consider a header or not, Tasks plugin shall follow that.

If you do go ahead and submit an issue of the forum, please do add a link to it here...

declan-morris commented 1 year ago

Thanks @claremacrae and @ilandikov.

I've updated the description, tried to make it specific but not too verbose and updated the initial post with a bit more detail.

I've checked the forums and I found this which seems to indicate the same as what we've found here. Happy to create another post if you think this warrants it though.

claremacrae commented 1 year ago

Thanks - I've tweaked it to make it clear that the heading in the callout is ignored...

One thing you might like to clarify... It says that they go under '(No Heading)' - but that may be because your sample file did not have any earlier heading.

What happens if you put an ordinary (non-callout) heading before your callout... my guess, which I believe was confirmed by ilandikov's example earlier, is that the previous ordinary heading will be applied...

If that's true, a more accurate description would be that the 'previous ordinary heading is used' - in which case, '(No Heading)' is just the ordinary behaviour when there was no earlier heading...

declan-morris commented 1 year ago

Yeah you're right! The last declared heading outside of the callout does appear to be used. I thought (No Heading) would be useful in the title as that's what I was searching for existing issues with.

claremacrae commented 1 year ago

Thanks!