Update editor, workspace, Git services, appearance, and project guides
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { documentLinks, documentLinkAt } from "../src/lib/editor/documentLinks.ts";
|
||||
|
||||
test("document links keep complete source ranges and decode Markdown destinations", () => {
|
||||
const source = '[Local](<notes/two words.md> "Title") and [Web](https://example.com/a_(b)) and [[Another note|Alias]]';
|
||||
const links = documentLinks(source);
|
||||
assert.deepEqual(links.map(link => [link.kind, link.target]), [["md", "notes/two words.md"], ["md", "https://example.com/a_(b)"], ["wiki", "Another note"]]);
|
||||
for (const link of links) {
|
||||
assert.equal(documentLinkAt(source, link.from + 2)?.target, link.target);
|
||||
assert.equal(documentLinkAt(source, link.to - 1)?.target, link.target);
|
||||
}
|
||||
});
|
||||
|
||||
test("literal code and images cannot become document links", () => {
|
||||
const source = ' `https://example.com`\n\n```md\n[Hidden](hidden.md)\n[[Hidden]]\n```\n\n[Open](open.md)';
|
||||
assert.deepEqual(documentLinks(source).map(link => link.target), ["open.md"]);
|
||||
});
|
||||
|
||||
test("bare and angle links omit prose punctuation and preserve balanced parentheses", () => {
|
||||
const source = 'Go to https://example.com/a_(b). Next (<https://example.org>). Mail <mailto:[email protected]>.';
|
||||
assert.deepEqual(documentLinks(source).map(link => link.target), ["https://example.com/a_(b)", "https://example.org", "mailto:[email protected]"]);
|
||||
});
|
||||
Reference in New Issue
Block a user