import { QueryDescriptor, ResourceView, SelectInput } from '.'; import { RenderContext } from './render-context'; import { URI } from '../model/uri'; /** * Markdown → HTML callback injected by the host. When omitted, markdown-bearing * cells fall back to escaped raw text (CLI / MCP behaviour). `sourceUri` * identifies the resource the markdown came from — used by adapters to * rewrite intra-note links and to guard against rendering cycles. */ export interface MarkdownRenderOptions { sourceUri?: URI; } export type MarkdownRenderer = (markdown: string, opts?: MarkdownRenderOptions) => string; /** * Builds the `href` value for a note link in query output. Returning `null` * tells `noteLink` to render the title as plain text (no anchor) — used by * the report renderer to drop links to notes that aren't part of the report. * * The hook receives the full `URI`, including any `fragment`, so callers can * route section-targeted query results (e.g. `[[note#section]]` results) to * section anchors when their output scheme supports them. */ export type ToHref = (uri: URI) => string | null; export declare function escapeHtml(text: string): string; /** * Renders a query result as an anchor (or plain text). The host's `toHref` * owns the full href shape — `noteLink` doesn't prefix, encode, or otherwise * massage the returned string. * * Returning `null` from `toHref` is the explicit "no link" signal: useful * when the target is out of the host's output scope (e.g. not included in a * report). A thrown error is still caught as a safety net and falls back to * plain text too, but `null` is the documented path. */ export declare function noteLink(title: string, uri: URI, toHref: ToHref): string; /** * Coarse description of the HTML a query renderer produced. Consumers of the * `onDidRender` hook on `markdownItFoamQuery` use this to decide how (or * whether) to wrap the result without having to inspect the HTML string. * * - `'table'` / `'list'` / `'count'`: shape of the successful render. * - `'empty'`: the renderer produced the empty-state placeholder because the * underlying result set was empty. * - `'unknown'`: emitted by `renderJsQuery`, where the user's script can call * `render(value)` arbitrarily many times with arbitrary inputs, so the * output is an opaque concatenation. */ export type QueryResultShape = 'table' | 'list' | 'count' | 'empty' | 'unknown'; /** What every query renderer in this module returns: the HTML plus the * shape that produced it. Errors are not represented here — they're a * fence-rule concern, surfaced via `FoamQueryRenderEvent.shape === 'error'`. */ export interface QueryRender { html: string; shape: QueryResultShape; } /** * Event fired by the `markdownItFoamQuery` plugin after a single foam-query * (or foam-query-js) fence has been rendered. Consumers receive the rendered * HTML plus a coarse shape tag so they can wrap, decorate, or strip the * output without inspecting it. * * Note on warnings: DQL prepends a `foam-query-warning` block to its result * HTML when validation issues come up. The block is included in `html` (we * don't split it out); `shape` describes the underlying result, not the * warnings. */ export interface FoamQueryRenderEvent { /** Which fence kind produced this. */ info: 'foam-query' | 'foam-query-js'; /** The HTML the renderer produced. */ html: string; /** * Result shape, with the added `'error'` case for when the fence rule's * try/catch caught an exception — those don't appear in a renderer's own * return value (since the renderer never finished). */ shape: QueryResultShape | 'error'; } export declare function renderList(results: ResourceView[], fields: SelectInput[], toHref: ToHref, renderMarkdown?: MarkdownRenderer, context?: RenderContext): QueryRender; export declare function renderTable(results: ResourceView[], fields: SelectInput[], toHref: ToHref, renderMarkdown?: MarkdownRenderer, context?: RenderContext): QueryRender; export declare function renderCount(results: ResourceView[]): QueryRender; /** * Renders query results as HTML based on the descriptor's format. */ export declare function renderResults(results: ResourceView[], descriptor: QueryDescriptor, toHref: ToHref, renderMarkdown?: MarkdownRenderer, context?: RenderContext): QueryRender; //# sourceMappingURL=html.d.ts.map