@f-o-t/markdown 1.0.3 → 1.0.6
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/block-parser.d.ts +66 -0
- package/dist/block-parser.d.ts.map +1 -0
- package/dist/generator.d.ts +222 -0
- package/dist/generator.d.ts.map +1 -0
- package/dist/html-parser.d.ts +62 -0
- package/dist/html-parser.d.ts.map +1 -0
- package/dist/html-renderer.d.ts +47 -0
- package/dist/html-renderer.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3515 -0
- package/dist/index.js.map +18 -0
- package/dist/inline-parser.d.ts +13 -0
- package/dist/inline-parser.d.ts.map +1 -0
- package/dist/parser.d.ts +185 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/schemas.d.ts +936 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/stream.d.ts +71 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/types.d.ts +188 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +268 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +33 -33
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { InlineNode } from "./schemas";
|
|
2
|
+
/**
|
|
3
|
+
* Parses inline content and returns AST nodes.
|
|
4
|
+
*
|
|
5
|
+
* @param text - The inline content to parse
|
|
6
|
+
* @param references - Link reference definitions
|
|
7
|
+
* @returns Array of inline nodes
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseInline(text: string, references?: Map<string, {
|
|
10
|
+
url: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
}>): InlineNode[];
|
|
13
|
+
//# sourceMappingURL=inline-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-parser.d.ts","sourceRoot":"","sources":["../src/inline-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAo8B5C;;;;;;GAMG;AACH,wBAAgB,WAAW,CACxB,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,GAAG,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAa,GACpE,UAAU,EAAE,CAKd"}
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { type MarkdownDocument, type ParseOptions } from "./schemas";
|
|
2
|
+
import type { ParseResult } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Parses markdown content and returns a result object.
|
|
5
|
+
*
|
|
6
|
+
* @param content - The markdown string to parse
|
|
7
|
+
* @param options - Parsing options
|
|
8
|
+
* @returns A ParseResult containing either the parsed document or an error
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const result = parse("# Hello World");
|
|
13
|
+
* if (result.success) {
|
|
14
|
+
* console.log(result.data.root.children);
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function parse(content: string, options?: ParseOptions): ParseResult<MarkdownDocument>;
|
|
19
|
+
/**
|
|
20
|
+
* Parses markdown content and throws on error.
|
|
21
|
+
*
|
|
22
|
+
* @param content - The markdown string to parse
|
|
23
|
+
* @param options - Parsing options
|
|
24
|
+
* @returns The parsed markdown document
|
|
25
|
+
* @throws Error if parsing fails or options are invalid
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const doc = parseOrThrow("# Hello World");
|
|
30
|
+
* console.log(doc.root.children);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseOrThrow(content: string, options?: ParseOptions): MarkdownDocument;
|
|
34
|
+
/**
|
|
35
|
+
* Parses markdown from a buffer with automatic encoding detection.
|
|
36
|
+
*
|
|
37
|
+
* @param buffer - The buffer containing markdown data
|
|
38
|
+
* @param options - Parsing options
|
|
39
|
+
* @returns A ParseResult containing either the parsed document or an error
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const buffer = new Uint8Array([...]);
|
|
44
|
+
* const result = parseBuffer(buffer);
|
|
45
|
+
* if (result.success) {
|
|
46
|
+
* console.log(result.data.root.children);
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseBuffer(buffer: Uint8Array, options?: ParseOptions): ParseResult<MarkdownDocument>;
|
|
51
|
+
/**
|
|
52
|
+
* Parses markdown from a buffer with automatic encoding detection.
|
|
53
|
+
* Throws on error.
|
|
54
|
+
*
|
|
55
|
+
* @param buffer - The buffer containing markdown data
|
|
56
|
+
* @param options - Parsing options
|
|
57
|
+
* @returns The parsed markdown document
|
|
58
|
+
* @throws Error if parsing fails
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const buffer = new Uint8Array([...]);
|
|
63
|
+
* const doc = parseBufferOrThrow(buffer);
|
|
64
|
+
* console.log(doc.root.children);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseBufferOrThrow(buffer: Uint8Array, options?: ParseOptions): MarkdownDocument;
|
|
68
|
+
/**
|
|
69
|
+
* Parses markdown and returns just the AST root node.
|
|
70
|
+
*
|
|
71
|
+
* @param content - The markdown string to parse
|
|
72
|
+
* @param options - Parsing options
|
|
73
|
+
* @returns The root document node
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const root = parseToAst("# Hello");
|
|
78
|
+
* console.log(root.type); // "document"
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function parseToAst(content: string, options?: ParseOptions): MarkdownDocument["root"];
|
|
82
|
+
/**
|
|
83
|
+
* Checks if the given content is valid markdown (doesn't throw during parsing).
|
|
84
|
+
*
|
|
85
|
+
* @param content - The content to check
|
|
86
|
+
* @returns True if the content can be parsed as markdown
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* isValidMarkdown("# Hello"); // true
|
|
91
|
+
* isValidMarkdown("anything"); // true (markdown is very permissive)
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function isValidMarkdown(content: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Extracts all text content from a markdown document (strips formatting).
|
|
97
|
+
*
|
|
98
|
+
* @param content - The markdown string
|
|
99
|
+
* @returns Plain text content
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* extractText("**Hello** *world*"); // "Hello world"
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare function extractText(content: string): string;
|
|
107
|
+
/**
|
|
108
|
+
* Counts the number of words in a markdown document.
|
|
109
|
+
*
|
|
110
|
+
* @param content - The markdown string
|
|
111
|
+
* @returns Word count
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* countWords("Hello **world**!"); // 2
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function countWords(content: string): number;
|
|
119
|
+
/**
|
|
120
|
+
* Gets headings from a markdown document.
|
|
121
|
+
*
|
|
122
|
+
* @param content - The markdown string
|
|
123
|
+
* @returns Array of heading info
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* getHeadings("# Title\n## Section");
|
|
128
|
+
* // [{ level: 1, text: "Title" }, { level: 2, text: "Section" }]
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export declare function getHeadings(content: string): Array<{
|
|
132
|
+
level: number;
|
|
133
|
+
text: string;
|
|
134
|
+
}>;
|
|
135
|
+
/**
|
|
136
|
+
* Gets all links from a markdown document.
|
|
137
|
+
*
|
|
138
|
+
* @param content - The markdown string
|
|
139
|
+
* @returns Array of link info
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* getLinks("[Example](https://example.com)");
|
|
144
|
+
* // [{ text: "Example", url: "https://example.com" }]
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export declare function getLinks(content: string): Array<{
|
|
148
|
+
text: string;
|
|
149
|
+
url: string;
|
|
150
|
+
title?: string;
|
|
151
|
+
}>;
|
|
152
|
+
/**
|
|
153
|
+
* Gets all images from a markdown document.
|
|
154
|
+
*
|
|
155
|
+
* @param content - The markdown string
|
|
156
|
+
* @returns Array of image info
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* getImages("");
|
|
161
|
+
* // [{ alt: "Alt text", url: "image.png" }]
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
export declare function getImages(content: string): Array<{
|
|
165
|
+
alt: string;
|
|
166
|
+
url: string;
|
|
167
|
+
title?: string;
|
|
168
|
+
}>;
|
|
169
|
+
/**
|
|
170
|
+
* Gets all code blocks from a markdown document.
|
|
171
|
+
*
|
|
172
|
+
* @param content - The markdown string
|
|
173
|
+
* @returns Array of code block info
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* getCodeBlocks("```js\nconsole.log('hi');\n```");
|
|
178
|
+
* // [{ lang: "js", code: "console.log('hi');" }]
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
export declare function getCodeBlocks(content: string): Array<{
|
|
182
|
+
lang?: string;
|
|
183
|
+
code: string;
|
|
184
|
+
}>;
|
|
185
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AACA,OAAO,EAGJ,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAEnB,MAAM,WAAW,CAAC;AACnB,OAA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