Link AsciiDoc cross references to their source

`xref:other.adoc[]` linked to `other.html`, which doesn't exist in the
repository, so following it showed a missing file instead.
This commit is contained in:
Rūdolfs Ošiņš
2026-10-08 10:29:43 +02:00
parent 38279298d1
commit 021c9f8a59
2 changed files with 24 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
import { expect, test, vi } from "vitest";
import { renderAsciidoc } from "@app/lib/asciidoc";
vi.mock("@app/lib/invoke", () => ({ invoke: vi.fn() }));
const source = {
rid: "rad:z3fpY7nttPPa6MBnAv2DccHzQJnqe",
sha: "a".repeat(40),
path: "docs/index.adoc",
};
test.each([
["xref:spec.adoc[Spec]", "spec.adoc"],
["xref:spec.adoc#_details[Spec]", "spec.adoc#_details"],
["<<spec.adoc#,Spec>>", "spec.adoc"],
["<<_details,Details>>", "#_details"],
])("links %j to %j", async (content, href) => {
const html = await renderAsciidoc(content, source);
expect(html).toContain(`href="${href}"`);
});