4a9ca29887
The repository's docs/api/ (the portal, its surface pages and the generated mod and server references) is built into the docs section: /docs/api is its README and /docs/api/<page> each page, in two nav groups, "Build on Horizon" and "API reference". The pages are read from the checkout or from main on GitHub, like the README, so the site never holds a copy. Links between portal pages become the site's (and the build's link check covers them); other relative links go to the file on GitHub. The renderer gains tables: the "Ways in" table, the references and the other tables on the site (apis, performance) showed as raw pipes. A link whose label is a code span no longer throws. Caddy and the dev server route /docs/api/<page> and redirect /docs/api/ to /docs/api; Railway rebuilds when docs/api/ changes. /docs/mods links the Mod API, its reference and its ways in; the summary page is now "APIs at a glance". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
1.2 KiB
JavaScript
26 lines
1.2 KiB
JavaScript
// node --test src/: the Markdown the docs pages and release notes are rendered from.
|
|
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { markdown } from "./markdown.js";
|
|
|
|
test("a table renders with its header, cells and inline Markdown", () => {
|
|
const html = markdown("| Way in | Status |\n| --- | :-: |\n| Rust | `cargo horizon-mod` |\n| Lua | planned \\| soon |\n\nAfter.");
|
|
assert.equal(
|
|
html,
|
|
'<div class="table-wrap"><table class="md-table"><thead><tr><th>Way in</th><th>Status</th></tr></thead>' +
|
|
"<tbody><tr><td>Rust</td><td><code>cargo horizon-mod</code></td></tr><tr><td>Lua</td><td>planned | soon</td></tr></tbody></table></div>\n<p>After.</p>",
|
|
);
|
|
});
|
|
|
|
test("a bar inside a code span stays in its cell", () => {
|
|
assert.match(markdown("| a | b |\n|---|---|\n| `x | y` | z |"), /<td><code>x \| y<\/code><\/td><td>z<\/td>/);
|
|
});
|
|
|
|
test("rows without a rule line are a paragraph", () => {
|
|
assert.equal(markdown("| a | b |\n| c | d |"), "<p>| a | b | | c | d |</p>");
|
|
});
|
|
|
|
test("a link whose label is code keeps it", () => {
|
|
assert.equal(markdown("See [`AGENTS.md`](/docs/agents).", { site: true }), '<p>See <a href="/docs/agents"><code>AGENTS.md</code></a>.</p>');
|
|
});
|