feat(view,tests): query blocks stay code in text the agent did not write
This commit is contained in:
1 parent
43d1e1a4a3
commit
91699a382e
5 files changed
+66
-4
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { inertFences } from "$lib/panel/fences";
|
||||
|
||||
const runs = (language: string) => ["tasks", "dataview"].includes(language);
|
||||
|
||||
describe("inertFences", () => {
|
||||
it("turns a query block into code", () => {
|
||||
expect(inertFences("```tasks\nnot done\n```", runs)).toBe(
|
||||
"```text\nnot done\n```"
|
||||
);
|
||||
expect(inertFences("~~~Dataview\nlist\n~~~", runs)).toBe(
|
||||
"~~~text\nlist\n~~~"
|
||||
);
|
||||
});
|
||||
|
||||
it("reaches a block opened inside a list item or a quote", () => {
|
||||
expect(inertFences("+ ```tasks\n+ not done", runs)).toBe(
|
||||
"+ ```text\n+ not done"
|
||||
);
|
||||
expect(inertFences("> 1. ````tasks {x}", runs)).toBe("> 1. ````text {x}");
|
||||
});
|
||||
|
||||
it("leaves ordinary code and closing fences alone", () => {
|
||||
const text = "```python\nprint(1)\n```\ninline `tasks` stays";
|
||||
expect(inertFences(text, runs)).toBe(text);
|
||||
});
|
||||
});
|
||||
@@ -34,6 +34,12 @@ export const moment = () => undefined;
|
||||
export const requestUrl = () =>
|
||||
Promise.reject(new Error("no network in the stub"));
|
||||
export const setIcon = () => undefined;
|
||||
export const MarkdownPreviewRenderer = {
|
||||
codeBlockPostProcessors: { tasks: () => undefined } as Record<
|
||||
string,
|
||||
unknown
|
||||
>,
|
||||
};
|
||||
|
||||
function escapeHtml(value: string): string {
|
||||
return value
|
||||
|
||||
Reference in new issue
Block a user