mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-10-18 19:10:45 +08:00
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:
@@ -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}"`);
|
||||
});
|
||||
Reference in New Issue
Block a user