Query block grouped by heading - inline comment visible in heading but not in individual tasks - any idea why inconsistent? #907
-
Not a bug/issue, more of an unexpected behavior, so posting here. No idea what the "correct" behavior would be, quite possibly the existing behavior is correct. I was just surprised. Note snippet: ## Tasks %% fold %%
- [ ] (GlobalFilter) Description
- [ ] (GlobalFilter) Wibble %% inline comment %% wobble Tasks query for files that include that note snippet: ```tasks
heading includes Tasks
group by heading
hide task count
``` The output successfully includes both tasks grouped by heading, but the inline comment in the heading name is rendered along with the rest of the heading, while the inline comment in the task is not rendered. ...
## Tasks %% fold %%
- [ ] Description (backlink)(edit)
- [ ] Wibble wobble (backlink)(edit)
... Does anyone know why there is a difference in whether these inline comments are rendered? Obsidian's help page on note formatting has a short section on comments but it does not specify much detail about where comments are expected. Hiding the comment in the rendered task makes sense, and I guess I am surprised it was not hidden in the rendered heading as well. Thoughts? Context: The comment in the heading comes from my usage of the community plugin Creases. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
Yes, I can reproduce this. I had noticed the problem before with Here is a copyable chunk: The Tasks
How Obsidian rendersWhich Obsidian renders - in Reading mode - as: Tasks blockWith this query:
How Tasks rendersTasks headings render as: |
Beta Was this translation helpful? Give feedback.
-
It is definitely a bug - Tasks should render the headings the same way as Obsidian does. Thanks very much for logging it. I'd been putting up with it, as I only rarely put any markup in headings. |
Beta Was this translation helpful? Give feedback.
-
I'll need to get someone to review the code, but here's my attempted fix: diff --git a/src/QueryRenderer.ts b/src/QueryRenderer.ts
index 3d76900..671c3ed 100644
--- a/src/QueryRenderer.ts
+++ b/src/QueryRenderer.ts
@@ -1,4 +1,4 @@
-import { App, MarkdownRenderChild, Plugin, TFile } from 'obsidian';
+import { App, Component, MarkdownRenderChild, MarkdownRenderer, Plugin, TFile } from 'obsidian';
import type { EventRef, MarkdownPostProcessorContext } from 'obsidian';
import type { IQuery } from './IQuery';
@@ -256,7 +256,7 @@ class QueryRenderChild extends MarkdownRenderChild {
}
}
- private static addGroupHeading(
+ private static async addGroupHeading(
content: HTMLDivElement,
group: GroupHeading,
) {
@@ -278,7 +278,7 @@ class QueryRenderChild extends MarkdownRenderChild {
cls: 'tasks-group-heading',
});
}
- header.appendText(group.name);
+ await MarkdownRenderer.renderMarkdown(group.name, header, '/', null as unknown as Component);
}
private addBacklinks( |
Beta Was this translation helpful? Give feedback.
-
Note to self: When testing this, test the backlinks thoroughly for all these tasks with markdown in... This won't have changed them, but worth testing while I have the samples to hand. |
Beta Was this translation helpful? Give feedback.
-
PR submitted: #909 |
Beta Was this translation helpful? Give feedback.
PR submitted: #909