/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import { type SluggerOptions } from './slugger'; /** * The syntax to use for heading IDs. * - `classic` => `{#id}` (invalid MDX, but commonly supported) * - `mdx-comment` => `{/* #id * /}` (valid MDX) */ export type HeadingIdSyntax = 'classic' | 'mdx-comment'; /** * Parses custom ID from a heading. The ID can contain any characters except * `{#` and `}`. * * @param heading e.g. `## Some heading {#some-heading}` where the last * character must be `}` for the ID to be recognized * @param syntax which heading ID syntax to recognize */ export declare function parseMarkdownHeadingId(heading: string, syntax?: HeadingIdSyntax): { /** * The heading content sans the ID part, right-trimmed. e.g. `## Some heading` */ text: string; /** The heading ID. e.g. `some-heading` */ id: string | undefined; }; /** * For our classic syntax, MDX v2+ now requires escaping { to compile: \{#id}. * See https://mdxjs.com/docs/troubleshooting-mdx/#could-not-parse-expression-with-acorn-error */ export declare function escapeMarkdownHeadingIds(content: string): string; export type WriteHeadingIDOptions = SluggerOptions & { /** The target syntax to use for heading IDs. */ syntax?: HeadingIdSyntax; /** Migrate the existing heading IDs to the target syntax */ migrate?: boolean; /** Overwrite existing heading IDs by re-generating them from the text. */ overwrite?: boolean; }; /** * Takes Markdown content, returns new content with heading IDs written. * Respects existing IDs (unless `overwrite=true`) and never generates colliding * IDs (through the slugger). */ export declare function writeMarkdownHeadingId(content: string, options?: WriteHeadingIDOptions): string; //# sourceMappingURL=markdownHeadingIdUtils.d.ts.map