Open eikowagenknecht opened 4 months ago
It would be great to support that feature!
Thanks for the feedback.
After researching various options, it seems challenging to implement this feature due to the specifications of mdast and remark.
For example, consider the following markdown:
> [!note] title here
> body here
This is transformed into the following mdast, and this plugin generates the callout by manipulating this mdast.
{
"type": "root",
"children": [
{
"type": "blockquote",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "[!note] # title here\nbody here",
"position": {
"start": {
"line": 1,
"column": 3,
"offset": 2
},
"end": {
"line": 2,
"column": 12,
"offset": 34
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 3,
"offset": 2
},
"end": {
"line": 2,
"column": 12,
"offset": 34
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 2,
"column": 12,
"offset": 34
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 2,
"column": 12,
"offset": 34
}
}
}
Notice that the title part of the callout exists as a paragraph in the mdast. According to the CommonMark specifications, only inline elements are allowed as children of a paragraph. Therefore, block elements cannot exist within a paragraph, making it impossible to use block elements as the title of a callout.
Furthermore, the heading included in the title part exists as text within the mdast. To recognize this as a heading element, the plugin would need to re-parse this string with remark, which is somewhat difficult to do accurately on the plugin side.
I am in favor of adding this feature, so if anyone is able to implement it, please feel free to mention me or send a PR. Thank you for proposing this feature!
Obsidian itself also supports block elements in headings, like this:
Maybe this could be added here as well, for feature parity? :-)