mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +01:00
Merge branch 'develop' into feat/llm-tool-improvement
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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! I’m 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! I’m 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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user