Tasks inside callouts have incorrect positions in the cache

I have some additional details, which may save some time for plugin authors, and explain what is going on under the hood in Obsidian to cause this issue.

It also reveals the workaround, which is to remove any labels from callouts that contain tasks, list items, and likely tags or anything else you want to search for.

Background: CachedMetaData

In the sections below, I show the CachedMetaData for two different example callouts that each contain a task.

This data is generated by Obsidian when it parses Markdown files, and is used by plugins to find interesting markdown content.

From the description in this bug report, it sounds like it is used by Obsidian too to toggle task checkboxes.

Tasks in callouts without titles - Obsidian 1.6.3 is correct

Consider this markdown:

> [!NOTE]
> - [ ] Task in 'callout_v1'

Obsidian 1.6.3 generates the following (correct) CachedMetaData for the above markdown file:

{
    "cachedMetadata": {
        "sections": [
            {
                "type": "callout",
                "position": {
                    "start": {
                        "line": 0,
                        "col": 0,
                        "offset": 0
                    },
                    "end": {
                        "line": 1,
                        "col": 28,
                        "offset": 38
                    }
                }
            }
        ],
        "listItems": [
            {
                "position": {
                    "start": {
                        "line": 1,
                        "col": 2,
                        "offset": 12
                    },
                    "end": {
                        "line": 1,
                        "col": 28,
                        "offset": 38
                    }
                },
                "parent": -1,
                "task": " "
            }
        ]
    }
}

Note the section beginning listItems - this says that the first lit item/checkbox starts at line 1… It sounds from 0, so to a human it is saying that the first task starts on line number 2, which is correct.

Tasks in callouts with titles - Obsidian 1.6.3 is broken

Consider this markdown, which differs only in that Some Title has been added to the callout line:

> [!NOTE] Some Title
> - [ ] Task in 'callout_v2'

Obsidian 1.6.3 generates the following incorrect CachedMetaData for the above markdown file:

{  
    "cachedMetadata": {  
        "sections": [  
            {  
                "type": "callout",  
                "position": {  
                    "start": {  
                        "line": 0,  
                        "col": 0,  
                        "offset": 0  
                    },  
                    "end": {  
                        "line": 1,  
                        "col": 28,  
                        "offset": 49  
                    }  
                }  
            }  
        ],  
        "listItems": [  
            {  
                "position": {  
                    "start": {  
                        "line": 2,  
                        "col": 0,  
                        "offset": 50  
                    },  
                    "end": {  
                        "line": 2,  
                        "col": 26,  
                        "offset": -1  
                    }  
                },  
                "parent": -2,  
                "task": " "  
            }  
        ]  
    }  
}

Note the section beginning listItems - this says that the first lit item/checkbox starts at line 2… It sounds from 0, so to a human it is saying that the first task starts on line number 3.

Since there is no line in the Markdown starting at 1-based line 3, neither Obsidian nor any plugin can find the task line to interact with.

It’s not just the line numbers in listItems. Tag positions are wrong too.

Visual diffs

Here is a visual diff of the the markdown files:

And here is a visual diff of the CachedMetaData, showing the change in line numbers, even though the line numbers are the same in the markdown files:

4 Likes