Merge branch 'develop' into feat/llm-tool-improvement

This commit is contained in:
perf3ct
2025-06-20 15:34:11 +00:00
4 changed files with 16 additions and 3 deletions

View File

@@ -77,7 +77,7 @@
]
},
"circular-deps": {
"command": "pnpx dpdm -T {projectRoot}/src/**/*.ts --tree=false --warning=false"
"command": "pnpx dpdm -T {projectRoot}/src/**/*.ts --tree=false --warning=false --skip-dynamic-imports=circular"
}
}
}

View File

@@ -1,6 +1,5 @@
import utils, { isShare } from "./utils.js";
import ValidationError from "./validation_error.js";
import { throwError } from "./ws.js";
type Headers = Record<string, string | null | undefined>;
@@ -277,6 +276,7 @@ async function reportError(method: string, url: string, statusCode: number, resp
} else {
const title = `${statusCode} ${method} ${url}`;
toastService.showErrorTitleAndMessage(title, messageStr);
const { throwError } = await import("./ws.js");
throwError(`${title} - ${message}`);
}
}

View File

@@ -281,4 +281,10 @@ $$`;
expect(markdownService.renderToHtml(input, "Title")).toStrictEqual(expected);
});
it("supports wikilink with root-relative path", () => {
const input = `oh no my banana I bought on [[journal/monday]] has gone off! Im taking it back to the [[other/shop]] for a refund`;
const expected = `<p>oh no my banana I bought on <a class="reference-link" href="journal/monday">journal/monday</a> has gone off! Im taking it back to the <a class="reference-link" href="other/shop">other/shop</a> for a refund</p>`;
expect(markdownService.renderToHtml(input, "Title")).toStrictEqual(expected);
});
});

View File

@@ -23,7 +23,9 @@ class CustomMarkdownRenderer extends Renderer {
}
override paragraph(data: Tokens.Paragraph): string {
return super.paragraph(data).trimEnd();
let text = super.paragraph(data).trimEnd();
text = processWikiLinks(text);
return text;
}
override code({ text, lang }: Tokens.Code): string {
@@ -212,6 +214,11 @@ function restoreFromMap(text: string, map: Map<string, string>): string {
return text.replace(new RegExp(pattern, 'g'), match => map.get(match) ?? match);
}
function processWikiLinks(paragraph: string) {
paragraph = paragraph.replaceAll(/\[\[([^\[\]]+)\]\]/g, `<a class="reference-link" href="$1">$1</a>`);
return paragraph;
}
const renderer = new CustomMarkdownRenderer({ async: false });
export default {