@readme/markdown 15.9.4 → 15.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/mdast-util/heading-id/index.d.ts +3 -0
- package/dist/lib/mdxish.d.ts +2 -0
- package/dist/lib/mdxishHeadingIds.d.ts +4 -0
- package/dist/lib/micromark/heading-id/index.d.ts +1 -0
- package/dist/lib/micromark/heading-id/syntax.d.ts +10 -0
- package/dist/lib/micromark/mdxish-extensions.d.ts +13 -7
- package/dist/main.js +437 -194
- package/dist/main.node.js +437 -194
- package/dist/main.node.js.map +1 -1
- package/dist/processor/compile/heading.d.ts +5 -0
- package/dist/processor/transform/mdxish/heading-ids.d.ts +14 -0
- package/dist/processor/transform/mdxish/heading-slugs.d.ts +2 -1
- package/dist/processor/utils.d.ts +9 -1
- package/dist/render-fixture.node.js +444 -194
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Heading, Parents } from 'mdast';
|
|
2
|
+
import type { Info, State } from 'mdast-util-to-markdown';
|
|
3
|
+
/** Writes an explicit heading id back as ` {#id}`. A setext heading, written for a line break, can't carry one. */
|
|
4
|
+
declare const heading: (node: Heading, parent: Parents | undefined, state: State, info: Info) => string;
|
|
5
|
+
export default heading;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Root } from 'mdast';
|
|
2
|
+
import type { Plugin } from 'unified';
|
|
3
|
+
declare module 'vfile' {
|
|
4
|
+
interface DataMap {
|
|
5
|
+
/** Heading ids set by `{#id}`, which the slug pass must not hand to another heading. */
|
|
6
|
+
explicitHeadingIds?: Set<string>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Records every heading id set by `{#id}`, so the slug pass never gives one to another heading.
|
|
11
|
+
* Warns when two headings share an id, since links can only reach the first.
|
|
12
|
+
*/
|
|
13
|
+
declare const headingIdsTransformer: Plugin<[], Root>;
|
|
14
|
+
export default headingIdsTransformer;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Root } from 'hast';
|
|
2
|
+
import type { VFile } from 'vfile';
|
|
2
3
|
/**
|
|
3
4
|
* Rehype plugin that constructs ids for headings
|
|
4
5
|
* Id's are used to construct slug anchor links & Table of Contents during rendering
|
|
5
6
|
* Use the text / nodes that make up the heading to generate the id
|
|
6
7
|
*/
|
|
7
|
-
declare const generateSlugForHeadings: () => (tree: Root) => Root;
|
|
8
|
+
declare const generateSlugForHeadings: () => (tree: Root, file: VFile) => Root;
|
|
8
9
|
export default generateSlugForHeadings;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Root as HastRoot } from 'hast';
|
|
2
|
-
import type { Node, Root as MdastRoot, Root } from 'mdast';
|
|
2
|
+
import type { Heading, Node, Root as MdastRoot, Root, Text } from 'mdast';
|
|
3
3
|
import type { MdxJsxFlowElement, MdxJsxTextElement, MdxjsEsm } from 'mdast-util-mdx';
|
|
4
4
|
import type { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
|
|
5
5
|
import type { Point, Position } from 'unist';
|
|
@@ -59,6 +59,14 @@ export declare const getHProps: <T>(node: Node) => T;
|
|
|
59
59
|
* @returns {Array} array of hProperty keys
|
|
60
60
|
*/
|
|
61
61
|
export declare const getHPropKeys: <T>(node: Node) => string[];
|
|
62
|
+
/** Turn a non-renderable evaluation result into a text node. */
|
|
63
|
+
export declare const createTextNode: (result: unknown, position: Position | undefined) => Text;
|
|
64
|
+
/**
|
|
65
|
+
* The id a heading's trailing `{#id}` set, when it is one the `{#id}` syntax can spell.
|
|
66
|
+
*
|
|
67
|
+
* Ids may use letters, numbers, `-`, `_`, `.` and `:`; anything else, like `x y`, is dropped.
|
|
68
|
+
*/
|
|
69
|
+
export declare const explicitHeadingId: (node: Heading) => string | undefined;
|
|
62
70
|
/**
|
|
63
71
|
* Gets the attributes of an MDX element and returns them as an object of hProperties.
|
|
64
72
|
*
|