Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions scripts/parsers/directives/reference-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
// node.label is non-empty. Directives that need a computed display label mutate
// node.label in their expand hook; render() then omits `label` from output.params.

import { createRequire } from 'module';
import type { DirectiveDef, DirectiveRenderOutput } from '../directive-registry.js';
import { DirectiveParseError } from '../directives.js';
import type { DirectiveNode, ExpandDirectivesContext } from '../directives.js';
import apiLibsJson from './api-libs.json';

// Load api-libs.json at module init time
const _require = createRequire(import.meta.url);
const API_LIBS: Record<string, string> = _require('./api-libs.json');
// api-libs.json is inlined at bundle time (static JSON import) so no sidecar
// file is needed next to the built parsers.bundle.mjs.
const API_LIBS: Record<string, string> = apiLibsJson as Record<string, string>;

// ─── :tutorial-ref[slug]{label?} ─────────────────────────────────────────────
//
Expand Down
6 changes: 2 additions & 4 deletions scripts/parsers/directives/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
// Side-effect: call registerUiDirectives() once at startup.
// In tests: resetRegistry(); registerUiDirectives()

import { createRequire } from 'node:module';
import { registerDirective, getRegistry } from '../directive-registry.js';
import { DirectiveParseError } from '../directives.js';
import type { DirectiveNode } from '../directives.js';
import iconAllowlistJson from './icon-allowlist.json';

const _require = createRequire(import.meta.url);
// eslint-disable-next-line @typescript-eslint/no-var-requires
const iconAllowlist: string[] = _require('./icon-allowlist.json') as string[];
const iconAllowlist: string[] = iconAllowlistJson as string[];

// ─── Key token constants ──────────────────────────────────────────────────────

Expand Down
6 changes: 6 additions & 0 deletions test/unit/option-tail-leak.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
const REPO_ROOT = join(__dirname, '..', '..');
const SHORTCODES = join(REPO_ROOT, 'hugo', 'layouts', 'shortcodes');
const MARKUP = join(REPO_ROOT, 'hugo', 'layouts', '_default', '_markup');
const PARTIALS = join(REPO_ROOT, 'hugo', 'layouts', 'partials');

function hugoBinary(): string {
return process.env.HUGO || 'hugo';
Expand All @@ -51,6 +52,7 @@ function renderThroughPipeline(stepBody: string): string {
const dir = mkdtempSync(join(tmpdir(), 'opt-tail-leak-'));
mkdirSync(join(dir, 'layouts', 'shortcodes'), { recursive: true });
mkdirSync(join(dir, 'layouts', '_default', '_markup'), { recursive: true });
mkdirSync(join(dir, 'layouts', 'partials'), { recursive: true });
mkdirSync(join(dir, 'content'), { recursive: true });

for (const sc of ['os-options.html', 'os-panel.html', 'option-tabs.html', 'tab.html']) {
Expand All @@ -67,6 +69,10 @@ function renderThroughPipeline(stepBody: string): string {
const p = join(MARKUP, h);
if (existsSync(p)) copyFileSync(p, join(dir, 'layouts', '_default', '_markup', h));
}
// render-blockquote.html delegates GitHub-style alerts (`> [!TIP]`) to the
// tut-alert partial (#2595/#71a8d70bc), so it must be present or the Hugo
// build fails resolving `partial "tut-alert.html"`.
copyFileSync(join(PARTIALS, 'tut-alert.html'), join(dir, 'layouts', 'partials', 'tut-alert.html'));

writeFileSync(join(dir, 'hugo.toml'),
'baseURL = "http://example.org/"\n' +
Expand Down
Loading