import type { VFile } from 'vfile'; import type { VFileMessage } from 'vfile-message'; import type { Position } from 'unist'; import type { Node, Parent } from 'myst-spec'; import type { RuleId } from './ruleids.js'; import type { AdmonitionKind, GenericNode, GenericParent } from './types.js'; export type MessageInfo = { node?: Node | Position; note?: string; source?: string; url?: string; fatal?: boolean; ruleId?: RuleId | string; /** This key can be combined with the ruleId to suppress a warning */ key?: string; }; export declare function fileError(file: VFile, message: string | Error, opts?: MessageInfo): VFileMessage; export declare function fileWarn(file: VFile, message: string | Error, opts?: MessageInfo): VFileMessage; export declare function fileInfo(file: VFile, message: string | Error, opts?: MessageInfo): VFileMessage; /** * Create random 10-digit alphanumeric string */ export declare function createId(): string; /** * https://github.com/syntax-tree/mdast#association * @param label A label field can be present. * label is a string value: it works just like title on a link or a * lang on code: character escapes and character references are parsed. * @returns { identifier, label, html_id } */ export declare function normalizeLabel(label: string | undefined): { identifier: string; label: string; html_id: string; } | undefined; export declare function createHtmlId(identifier?: string): string | undefined; /** * Transfer all target-related attributes from one node to another * * During mdast transformation, these attributes (including: label, * identifier, html_id, indexEntries) are often moved. For example * `mystTarget` information propagates to the next node, `image` * attributes may propagate to parent `container` node, etc. * * This shared function helps insure attributes are not lost along the way. */ export declare function transferTargetAttrs(sourceNode: GenericNode, destNode: GenericNode, vfile?: VFile): void; /** * Eliminate all parent nodes in `tree` of type `removeType`; children of eliminated nodes are moved up to it's parent * * Nodes of `removeType` will remain if: * - they are the root of `tree` * - their children are undefined */ export declare function liftChildren(tree: GenericParent | GenericNode, removeType: string): void; export declare function setTextAsChild(node: Partial, text: string): void; /** * Renders a textual representation of one or more nodes * by concatenating all children that have a text representation. * @param content The node or nodes to provide as input. * @returns A string. An empty string is returned in case no * textual representation could be extracted. */ export declare function toText(content?: Node[] | Node | null): string; export declare function copyNode(node: T): T; export declare function mergeTextNodes(node: GenericNode): GenericNode; export declare function admonitionKindToTitle(kind: AdmonitionKind | string): string; export declare function writeTexLabelledComment(title: string, commands: string[], commentLength: number): string; export declare function getMetadataTags(node: GenericNode): string[]; /** * Change from a slug such as `folder.subfolder.index` to a URL (`folder/subfolder`). * * @param slug * @returns url */ export declare function slugToUrl(slug: T): T; //# sourceMappingURL=utils.d.ts.map