emdp 1.0.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.
Files changed (199) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -0
  3. package/dist/cjs/cli.js +36 -0
  4. package/dist/cjs/gfm.js +26 -0
  5. package/dist/cjs/index.js +26 -0
  6. package/dist/cjs/parser/block-parser.js +644 -0
  7. package/dist/cjs/parser/blocks/blockquote.js +28 -0
  8. package/dist/cjs/parser/blocks/code-block-fenced.js +58 -0
  9. package/dist/cjs/parser/blocks/code-block-indented.js +47 -0
  10. package/dist/cjs/parser/blocks/heading-atx.js +29 -0
  11. package/dist/cjs/parser/blocks/heading-setext.js +24 -0
  12. package/dist/cjs/parser/blocks/html-block.js +83 -0
  13. package/dist/cjs/parser/blocks/link-reference.js +109 -0
  14. package/dist/cjs/parser/blocks/list.js +155 -0
  15. package/dist/cjs/parser/blocks/paragraph.js +20 -0
  16. package/dist/cjs/parser/blocks/table.js +163 -0
  17. package/dist/cjs/parser/blocks/task-list.js +66 -0
  18. package/dist/cjs/parser/blocks/thematic-break.js +17 -0
  19. package/dist/cjs/parser/entities.js +2133 -0
  20. package/dist/cjs/parser/gfm/block-parser.js +773 -0
  21. package/dist/cjs/parser/gfm/index.js +125 -0
  22. package/dist/cjs/parser/gfm/inline-parser.js +813 -0
  23. package/dist/cjs/parser/gfm/renderer.js +513 -0
  24. package/dist/cjs/parser/index.js +104 -0
  25. package/dist/cjs/parser/inline-parser.js +564 -0
  26. package/dist/cjs/parser/inlines/autolink-extended.js +364 -0
  27. package/dist/cjs/parser/inlines/autolink.js +44 -0
  28. package/dist/cjs/parser/inlines/code-span.js +48 -0
  29. package/dist/cjs/parser/inlines/emphasis.js +64 -0
  30. package/dist/cjs/parser/inlines/entity.js +25 -0
  31. package/dist/cjs/parser/inlines/escape.js +25 -0
  32. package/dist/cjs/parser/inlines/footnote.js +41 -0
  33. package/dist/cjs/parser/inlines/hard-break.js +45 -0
  34. package/dist/cjs/parser/inlines/image.js +9 -0
  35. package/dist/cjs/parser/inlines/link.js +166 -0
  36. package/dist/cjs/parser/inlines/soft-break.js +18 -0
  37. package/dist/cjs/parser/inlines/strikethrough.js +48 -0
  38. package/dist/cjs/parser/inlines/text.js +20 -0
  39. package/dist/cjs/parser/renderer.js +345 -0
  40. package/dist/cjs/parser/types.js +5 -0
  41. package/dist/cjs/parser/utils.js +277 -0
  42. package/dist/cli.d.ts +6 -0
  43. package/dist/cli.js +36 -0
  44. package/dist/esm/cli.js +34 -0
  45. package/dist/esm/gfm.js +5 -0
  46. package/dist/esm/index.js +5 -0
  47. package/dist/esm/package.json +3 -0
  48. package/dist/esm/parser/block-parser.js +640 -0
  49. package/dist/esm/parser/blocks/blockquote.js +22 -0
  50. package/dist/esm/parser/blocks/code-block-fenced.js +52 -0
  51. package/dist/esm/parser/blocks/code-block-indented.js +42 -0
  52. package/dist/esm/parser/blocks/heading-atx.js +24 -0
  53. package/dist/esm/parser/blocks/heading-setext.js +19 -0
  54. package/dist/esm/parser/blocks/html-block.js +77 -0
  55. package/dist/esm/parser/blocks/link-reference.js +105 -0
  56. package/dist/esm/parser/blocks/list.js +145 -0
  57. package/dist/esm/parser/blocks/paragraph.js +15 -0
  58. package/dist/esm/parser/blocks/table.js +152 -0
  59. package/dist/esm/parser/blocks/task-list.js +61 -0
  60. package/dist/esm/parser/blocks/thematic-break.js +13 -0
  61. package/dist/esm/parser/entities.js +2130 -0
  62. package/dist/esm/parser/gfm/block-parser.js +769 -0
  63. package/dist/esm/parser/gfm/index.js +115 -0
  64. package/dist/esm/parser/gfm/inline-parser.js +809 -0
  65. package/dist/esm/parser/gfm/renderer.js +509 -0
  66. package/dist/esm/parser/index.js +80 -0
  67. package/dist/esm/parser/inline-parser.js +560 -0
  68. package/dist/esm/parser/inlines/autolink-extended.js +357 -0
  69. package/dist/esm/parser/inlines/autolink.js +40 -0
  70. package/dist/esm/parser/inlines/code-span.js +44 -0
  71. package/dist/esm/parser/inlines/emphasis.js +59 -0
  72. package/dist/esm/parser/inlines/entity.js +21 -0
  73. package/dist/esm/parser/inlines/escape.js +21 -0
  74. package/dist/esm/parser/inlines/footnote.js +38 -0
  75. package/dist/esm/parser/inlines/hard-break.js +41 -0
  76. package/dist/esm/parser/inlines/image.js +4 -0
  77. package/dist/esm/parser/inlines/link.js +156 -0
  78. package/dist/esm/parser/inlines/soft-break.js +14 -0
  79. package/dist/esm/parser/inlines/strikethrough.js +42 -0
  80. package/dist/esm/parser/inlines/text.js +16 -0
  81. package/dist/esm/parser/renderer.js +341 -0
  82. package/dist/esm/parser/types.js +4 -0
  83. package/dist/esm/parser/utils.js +254 -0
  84. package/dist/gfm.d.ts +6 -0
  85. package/dist/gfm.js +26 -0
  86. package/dist/index.d.ts +5 -0
  87. package/dist/index.js +26 -0
  88. package/dist/parser/block-parser.d.ts +25 -0
  89. package/dist/parser/block-parser.js +644 -0
  90. package/dist/parser/blocks/blockquote.d.ts +8 -0
  91. package/dist/parser/blocks/blockquote.js +28 -0
  92. package/dist/parser/blocks/code-block-fenced.d.ts +14 -0
  93. package/dist/parser/blocks/code-block-fenced.js +58 -0
  94. package/dist/parser/blocks/code-block-indented.d.ts +7 -0
  95. package/dist/parser/blocks/code-block-indented.js +47 -0
  96. package/dist/parser/blocks/heading-atx.d.ts +10 -0
  97. package/dist/parser/blocks/heading-atx.js +29 -0
  98. package/dist/parser/blocks/heading-setext.d.ts +8 -0
  99. package/dist/parser/blocks/heading-setext.js +24 -0
  100. package/dist/parser/blocks/html-block.d.ts +9 -0
  101. package/dist/parser/blocks/html-block.js +83 -0
  102. package/dist/parser/blocks/link-reference.d.ts +11 -0
  103. package/dist/parser/blocks/link-reference.js +109 -0
  104. package/dist/parser/blocks/list.d.ts +25 -0
  105. package/dist/parser/blocks/list.js +155 -0
  106. package/dist/parser/blocks/paragraph.d.ts +7 -0
  107. package/dist/parser/blocks/paragraph.js +20 -0
  108. package/dist/parser/blocks/table.d.ts +13 -0
  109. package/dist/parser/blocks/table.js +163 -0
  110. package/dist/parser/blocks/task-list.d.ts +10 -0
  111. package/dist/parser/blocks/task-list.js +66 -0
  112. package/dist/parser/blocks/thematic-break.d.ts +6 -0
  113. package/dist/parser/blocks/thematic-break.js +17 -0
  114. package/dist/parser/entities.d.ts +4 -0
  115. package/dist/parser/entities.js +2133 -0
  116. package/dist/parser/gfm/block-parser.d.ts +32 -0
  117. package/dist/parser/gfm/block-parser.js +773 -0
  118. package/dist/parser/gfm/index.d.ts +31 -0
  119. package/dist/parser/gfm/index.js +125 -0
  120. package/dist/parser/gfm/inline-parser.d.ts +25 -0
  121. package/dist/parser/gfm/inline-parser.js +813 -0
  122. package/dist/parser/gfm/renderer.d.ts +43 -0
  123. package/dist/parser/gfm/renderer.js +513 -0
  124. package/dist/parser/index.d.ts +33 -0
  125. package/dist/parser/index.js +104 -0
  126. package/dist/parser/inline-parser.d.ts +16 -0
  127. package/dist/parser/inline-parser.js +564 -0
  128. package/dist/parser/inlines/autolink-extended.d.ts +24 -0
  129. package/dist/parser/inlines/autolink-extended.js +364 -0
  130. package/dist/parser/inlines/autolink.d.ts +9 -0
  131. package/dist/parser/inlines/autolink.js +44 -0
  132. package/dist/parser/inlines/code-span.d.ts +9 -0
  133. package/dist/parser/inlines/code-span.js +48 -0
  134. package/dist/parser/inlines/emphasis.d.ts +14 -0
  135. package/dist/parser/inlines/emphasis.js +64 -0
  136. package/dist/parser/inlines/entity.d.ts +8 -0
  137. package/dist/parser/inlines/entity.js +25 -0
  138. package/dist/parser/inlines/escape.d.ts +8 -0
  139. package/dist/parser/inlines/escape.js +25 -0
  140. package/dist/parser/inlines/footnote.d.ts +9 -0
  141. package/dist/parser/inlines/footnote.js +41 -0
  142. package/dist/parser/inlines/hard-break.d.ts +9 -0
  143. package/dist/parser/inlines/hard-break.js +45 -0
  144. package/dist/parser/inlines/image.d.ts +4 -0
  145. package/dist/parser/inlines/image.js +9 -0
  146. package/dist/parser/inlines/link.d.ts +33 -0
  147. package/dist/parser/inlines/link.js +166 -0
  148. package/dist/parser/inlines/soft-break.d.ts +9 -0
  149. package/dist/parser/inlines/soft-break.js +18 -0
  150. package/dist/parser/inlines/strikethrough.d.ts +16 -0
  151. package/dist/parser/inlines/strikethrough.js +48 -0
  152. package/dist/parser/inlines/text.d.ts +6 -0
  153. package/dist/parser/inlines/text.js +20 -0
  154. package/dist/parser/renderer.d.ts +33 -0
  155. package/dist/parser/renderer.js +345 -0
  156. package/dist/parser/types.d.ts +152 -0
  157. package/dist/parser/types.js +5 -0
  158. package/dist/parser/utils.d.ts +32 -0
  159. package/dist/parser/utils.js +277 -0
  160. package/dist/types/cli.d.ts +6 -0
  161. package/dist/types/gfm.d.ts +6 -0
  162. package/dist/types/index.d.ts +5 -0
  163. package/dist/types/parser/block-parser.d.ts +25 -0
  164. package/dist/types/parser/blocks/blockquote.d.ts +8 -0
  165. package/dist/types/parser/blocks/code-block-fenced.d.ts +14 -0
  166. package/dist/types/parser/blocks/code-block-indented.d.ts +7 -0
  167. package/dist/types/parser/blocks/heading-atx.d.ts +10 -0
  168. package/dist/types/parser/blocks/heading-setext.d.ts +8 -0
  169. package/dist/types/parser/blocks/html-block.d.ts +9 -0
  170. package/dist/types/parser/blocks/link-reference.d.ts +11 -0
  171. package/dist/types/parser/blocks/list.d.ts +25 -0
  172. package/dist/types/parser/blocks/paragraph.d.ts +7 -0
  173. package/dist/types/parser/blocks/table.d.ts +13 -0
  174. package/dist/types/parser/blocks/task-list.d.ts +10 -0
  175. package/dist/types/parser/blocks/thematic-break.d.ts +6 -0
  176. package/dist/types/parser/entities.d.ts +4 -0
  177. package/dist/types/parser/gfm/block-parser.d.ts +32 -0
  178. package/dist/types/parser/gfm/index.d.ts +31 -0
  179. package/dist/types/parser/gfm/inline-parser.d.ts +25 -0
  180. package/dist/types/parser/gfm/renderer.d.ts +43 -0
  181. package/dist/types/parser/index.d.ts +33 -0
  182. package/dist/types/parser/inline-parser.d.ts +16 -0
  183. package/dist/types/parser/inlines/autolink-extended.d.ts +24 -0
  184. package/dist/types/parser/inlines/autolink.d.ts +9 -0
  185. package/dist/types/parser/inlines/code-span.d.ts +9 -0
  186. package/dist/types/parser/inlines/emphasis.d.ts +14 -0
  187. package/dist/types/parser/inlines/entity.d.ts +8 -0
  188. package/dist/types/parser/inlines/escape.d.ts +8 -0
  189. package/dist/types/parser/inlines/footnote.d.ts +9 -0
  190. package/dist/types/parser/inlines/hard-break.d.ts +9 -0
  191. package/dist/types/parser/inlines/image.d.ts +4 -0
  192. package/dist/types/parser/inlines/link.d.ts +33 -0
  193. package/dist/types/parser/inlines/soft-break.d.ts +9 -0
  194. package/dist/types/parser/inlines/strikethrough.d.ts +16 -0
  195. package/dist/types/parser/inlines/text.d.ts +6 -0
  196. package/dist/types/parser/renderer.d.ts +33 -0
  197. package/dist/types/parser/types.d.ts +152 -0
  198. package/dist/types/parser/utils.d.ts +32 -0
  199. package/package.json +54 -0
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Parser for GFM extended autolinks that recognize bare URLs and emails.
3
+ */
4
+ import type { LinkNode } from '../types.js';
5
+ export declare function parseWwwAutolink(text: string, pos: number, charBefore: string | undefined): {
6
+ node: LinkNode;
7
+ length: number;
8
+ } | null;
9
+ export declare function parseUrlAutolink(text: string, pos: number, charBefore: string | undefined): {
10
+ node: LinkNode;
11
+ length: number;
12
+ } | null;
13
+ export declare function parseEmailAutolink(text: string, pos: number, charBefore: string | undefined): {
14
+ node: LinkNode;
15
+ length: number;
16
+ } | null;
17
+ export declare function parseProtocolAutolink(text: string, pos: number, charBefore: string | undefined): {
18
+ node: LinkNode;
19
+ length: number;
20
+ } | null;
21
+ export declare function parseExtendedAutolink(text: string, pos: number, charBefore: string | undefined): {
22
+ node: LinkNode;
23
+ length: number;
24
+ } | null;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parser for autolinks enclosed in angle brackets.
3
+ */
4
+ import type { LinkNode } from '../types.js';
5
+ export declare function parseAutolink(text: string, pos: number): {
6
+ node: LinkNode;
7
+ length: number;
8
+ } | null;
9
+ export declare function isAutolinkStart(text: string, pos: number): boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parser for inline code spans delimited by backticks.
3
+ */
4
+ import type { CodeSpanNode } from '../types.js';
5
+ export declare function parseCodeSpan(text: string, pos: number): {
6
+ node: CodeSpanNode;
7
+ length: number;
8
+ } | null;
9
+ export declare function isCodeSpanStart(text: string, pos: number): boolean;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Parser for emphasis and strong emphasis using * and _ delimiters.
3
+ */
4
+ export interface DelimiterRun {
5
+ char: '*' | '_';
6
+ length: number;
7
+ canOpen: boolean;
8
+ canClose: boolean;
9
+ position: number;
10
+ origLength: number;
11
+ }
12
+ export declare function parseDelimiterRun(text: string, pos: number): DelimiterRun | null;
13
+ export declare function isEmphasisDelimiter(text: string, pos: number): boolean;
14
+ export declare function canDelimitersMatch(opener: DelimiterRun, closer: DelimiterRun): boolean;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Parser for HTML character entities in inline content.
3
+ */
4
+ export declare function parseEntity(text: string, pos: number): {
5
+ char: string;
6
+ length: number;
7
+ } | null;
8
+ export declare function isEntityStart(text: string, pos: number): boolean;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Parser for backslash escape sequences and escaped hard breaks.
3
+ */
4
+ export declare function parseEscape(text: string, pos: number): {
5
+ char: string;
6
+ length: number;
7
+ } | null;
8
+ export declare function isEscapedChar(text: string, pos: number): boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parser for GFM footnote labels.
3
+ */
4
+ export interface FootnoteLabelMatch {
5
+ label: string;
6
+ normalized: string;
7
+ length: number;
8
+ }
9
+ export declare function parseFootnoteLabel(text: string, pos: number): FootnoteLabelMatch | null;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parser for hard line breaks created by backslash-newline or trailing spaces.
3
+ */
4
+ import type { HardbreakNode } from '../types.js';
5
+ export declare function parseHardBreak(text: string, pos: number): {
6
+ node: HardbreakNode;
7
+ length: number;
8
+ } | null;
9
+ export declare function isHardBreakStart(text: string, pos: number): boolean;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Image parsing helpers that reuse link logic and create image nodes.
3
+ */
4
+ export { createImageNode, isImageStart } from './link.js';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Parser for inline links and images, including destinations, titles, and reference labels.
3
+ */
4
+ import type { LinkNode, ImageNode } from '../types.js';
5
+ export interface LinkMatch {
6
+ type: 'link' | 'image';
7
+ destination: string;
8
+ title: string;
9
+ textStart: number;
10
+ textEnd: number;
11
+ fullEnd: number;
12
+ }
13
+ export declare function parseLinkDestination(text: string): {
14
+ destination: string;
15
+ length: number;
16
+ } | null;
17
+ export declare function parseLinkTitle(text: string): {
18
+ title: string;
19
+ length: number;
20
+ } | null;
21
+ export declare function parseInlineLink(text: string, pos: number): {
22
+ destination: string;
23
+ title: string;
24
+ length: number;
25
+ } | null;
26
+ export declare function parseLinkLabel(text: string, pos: number): {
27
+ label: string;
28
+ length: number;
29
+ } | null;
30
+ export declare function createLinkNode(destination: string, title: string): LinkNode;
31
+ export declare function createImageNode(destination: string, title: string, alt: string): ImageNode;
32
+ export declare function isLinkStart(text: string, pos: number): boolean;
33
+ export declare function isImageStart(text: string, pos: number): boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parser for soft line breaks created by single newlines.
3
+ */
4
+ import type { SoftbreakNode } from '../types.js';
5
+ export declare function parseSoftBreak(text: string, pos: number): {
6
+ node: SoftbreakNode;
7
+ length: number;
8
+ } | null;
9
+ export declare function isSoftBreak(text: string, pos: number): boolean;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Parser for GFM strikethrough using ~ delimiters.
3
+ */
4
+ import type { StrikethroughNode, InlineNode } from '../types.js';
5
+ export interface StrikethroughDelimiter {
6
+ char: '~';
7
+ length: number;
8
+ canOpen: boolean;
9
+ canClose: boolean;
10
+ position: number;
11
+ origLength: number;
12
+ }
13
+ export declare function parseStrikethroughDelimiter(text: string, pos: number): StrikethroughDelimiter | null;
14
+ export declare function isStrikethroughDelimiter(text: string, pos: number): boolean;
15
+ export declare function createStrikethroughNode(children?: InlineNode[]): StrikethroughNode;
16
+ export declare function canStrikethroughDelimitersMatch(opener: StrikethroughDelimiter, closer: StrikethroughDelimiter): boolean;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Text node factories for literal inline content.
3
+ */
4
+ import type { TextNode } from '../types.js';
5
+ export declare function createTextNode(literal: string, noDelim?: boolean): TextNode;
6
+ export declare function mergeTextNodes(nodes: TextNode[]): TextNode;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * HTML renderer that converts a Markdown AST into HTML with configurable list, URL safety,
3
+ * and soft-break handling.
4
+ */
5
+ import type { DocumentNode, RenderOptions } from './types.js';
6
+ export declare class HtmlRenderer {
7
+ private options;
8
+ constructor(options?: RenderOptions);
9
+ render(document: DocumentNode): string;
10
+ private renderBlocks;
11
+ private renderBlock;
12
+ private renderParagraph;
13
+ private renderHeading;
14
+ private renderThematicBreak;
15
+ private renderCodeBlock;
16
+ private renderBlockquote;
17
+ private renderList;
18
+ private renderListItem;
19
+ private renderHtmlBlock;
20
+ private renderInlines;
21
+ private renderInline;
22
+ private renderText;
23
+ private renderSoftbreak;
24
+ private renderHardbreak;
25
+ private renderCodeSpan;
26
+ private renderEmphasis;
27
+ private renderStrong;
28
+ private renderLink;
29
+ private renderImage;
30
+ private renderHtmlInline;
31
+ private renderInlinesSmart;
32
+ private applyDashesAndEllipses;
33
+ }
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Type definitions for the Markdown AST nodes and parser/render options.
3
+ */
4
+ export type BlockType = 'document' | 'paragraph' | 'heading' | 'thematic_break' | 'code_block' | 'blockquote' | 'list' | 'list_item' | 'html_block' | 'link_reference_definition' | 'table';
5
+ export type InlineType = 'text' | 'softbreak' | 'hardbreak' | 'code_span' | 'emphasis' | 'strong' | 'strikethrough' | 'footnote_ref' | 'link' | 'image' | 'html_inline';
6
+ export interface Position {
7
+ line: number;
8
+ column: number;
9
+ offset: number;
10
+ }
11
+ export interface SourceLocation {
12
+ start: Position;
13
+ end: Position;
14
+ }
15
+ export interface BaseNode {
16
+ type: string;
17
+ sourcepos?: SourceLocation;
18
+ }
19
+ export interface DocumentNode extends BaseNode {
20
+ type: 'document';
21
+ children: BlockNode[];
22
+ footnoteDefinitions?: Map<string, FootnoteDefinition>;
23
+ }
24
+ export interface ParagraphNode extends BaseNode {
25
+ type: 'paragraph';
26
+ children: InlineNode[];
27
+ }
28
+ export interface HeadingNode extends BaseNode {
29
+ type: 'heading';
30
+ level: 1 | 2 | 3 | 4 | 5 | 6;
31
+ children: InlineNode[];
32
+ }
33
+ export interface ThematicBreakNode extends BaseNode {
34
+ type: 'thematic_break';
35
+ }
36
+ export interface CodeBlockNode extends BaseNode {
37
+ type: 'code_block';
38
+ info: string;
39
+ literal: string;
40
+ fenced: boolean;
41
+ }
42
+ export interface BlockquoteNode extends BaseNode {
43
+ type: 'blockquote';
44
+ children: BlockNode[];
45
+ }
46
+ export interface ListNode extends BaseNode {
47
+ type: 'list';
48
+ listType: 'bullet' | 'ordered';
49
+ start: number;
50
+ tight: boolean;
51
+ delimiter: '.' | ')' | null;
52
+ bulletChar: '-' | '+' | '*' | null;
53
+ children: ListItemNode[];
54
+ }
55
+ export interface ListItemNode extends BaseNode {
56
+ type: 'list_item';
57
+ children: BlockNode[];
58
+ checked?: boolean | null;
59
+ }
60
+ export interface HtmlBlockNode extends BaseNode {
61
+ type: 'html_block';
62
+ literal: string;
63
+ }
64
+ export type TableAlignment = 'left' | 'center' | 'right' | null;
65
+ export interface TableCellNode extends BaseNode {
66
+ type: 'table_cell';
67
+ children: InlineNode[];
68
+ align: TableAlignment;
69
+ isHeader: boolean;
70
+ }
71
+ export interface TableRowNode extends BaseNode {
72
+ type: 'table_row';
73
+ children: TableCellNode[];
74
+ isHeader: boolean;
75
+ }
76
+ export interface TableNode extends BaseNode {
77
+ type: 'table';
78
+ alignments: TableAlignment[];
79
+ children: TableRowNode[];
80
+ }
81
+ export interface LinkReferenceDefinition {
82
+ destination: string;
83
+ title: string;
84
+ }
85
+ export type BlockNode = ParagraphNode | HeadingNode | ThematicBreakNode | CodeBlockNode | BlockquoteNode | ListNode | ListItemNode | HtmlBlockNode | TableNode;
86
+ export interface TextNode extends BaseNode {
87
+ type: 'text';
88
+ literal: string;
89
+ noDelim?: boolean;
90
+ noSmart?: boolean;
91
+ }
92
+ export interface SoftbreakNode extends BaseNode {
93
+ type: 'softbreak';
94
+ }
95
+ export interface HardbreakNode extends BaseNode {
96
+ type: 'hardbreak';
97
+ }
98
+ export interface CodeSpanNode extends BaseNode {
99
+ type: 'code_span';
100
+ literal: string;
101
+ }
102
+ export interface EmphasisNode extends BaseNode {
103
+ type: 'emphasis';
104
+ children: InlineNode[];
105
+ }
106
+ export interface StrongNode extends BaseNode {
107
+ type: 'strong';
108
+ children: InlineNode[];
109
+ }
110
+ export interface StrikethroughNode extends BaseNode {
111
+ type: 'strikethrough';
112
+ children: InlineNode[];
113
+ }
114
+ export interface FootnoteRefNode extends BaseNode {
115
+ type: 'footnote_ref';
116
+ label: string;
117
+ key: string;
118
+ }
119
+ export interface LinkNode extends BaseNode {
120
+ type: 'link';
121
+ destination: string;
122
+ title: string;
123
+ children: InlineNode[];
124
+ }
125
+ export interface ImageNode extends BaseNode {
126
+ type: 'image';
127
+ destination: string;
128
+ title: string;
129
+ alt: string;
130
+ }
131
+ export interface HtmlInlineNode extends BaseNode {
132
+ type: 'html_inline';
133
+ literal: string;
134
+ }
135
+ export type InlineNode = TextNode | SoftbreakNode | HardbreakNode | CodeSpanNode | EmphasisNode | StrongNode | StrikethroughNode | FootnoteRefNode | LinkNode | ImageNode | HtmlInlineNode;
136
+ export interface FootnoteDefinition {
137
+ label: string;
138
+ blocks: BlockNode[];
139
+ }
140
+ export interface ParseOptions {
141
+ sourcepos?: boolean;
142
+ extensions?: string[];
143
+ }
144
+ export interface RenderOptions {
145
+ softbreak?: string;
146
+ safe?: boolean;
147
+ tablePreferStyleAttributes?: boolean;
148
+ fullInfoString?: boolean;
149
+ smart?: boolean;
150
+ tagfilter?: boolean;
151
+ extensions?: string[];
152
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Shared text-processing utilities for the parser, including entity decoding, escaping,
3
+ * whitespace handling, and URI normalization.
4
+ */
5
+ export declare function decodeHtmlEntities(str: string): string;
6
+ export declare function escapeXml(str: string): string;
7
+ export declare function escapeHtml(str: string, preserveEntities?: boolean): string;
8
+ export declare const ASCII_PUNCTUATION_REGEX: RegExp;
9
+ export declare const ASCII_PUNCTUATION_CHARS = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
10
+ export declare function isAsciiPunctuation(char: string): boolean;
11
+ export declare function isWhitespace(char: string): boolean;
12
+ export declare function isUnicodeWhitespace(char: string): boolean;
13
+ export declare function isUnicodePunctuation(char: string): boolean;
14
+ export declare function normalizeLineEndings(str: string): string;
15
+ export declare function expandTabs(line: string, tabStop?: number): string;
16
+ export declare function expandTabsPartial(line: string, startColumn: number, tabStop?: number): string;
17
+ export declare function trimLeadingSpaces(line: string, max?: number): {
18
+ trimmed: string;
19
+ count: number;
20
+ };
21
+ export declare function countLeadingSpaces(line: string): number;
22
+ export declare function countLeadingChars(line: string): {
23
+ spaces: number;
24
+ chars: number;
25
+ };
26
+ export declare function removeIndent(line: string, indent: number): string;
27
+ export declare function extractContentAfterMarker(line: string, startColumn: number, charIndex: number): string;
28
+ export declare function normalizeUri(uri: string): string;
29
+ export declare function unescapeString(str: string): string;
30
+ export declare function normalizeLabel(label: string): string;
31
+ export declare function isTagFilterTag(tagName: string): boolean;
32
+ export declare function applyTagFilter(html: string): string;
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "emdp",
3
+ "version": "1.0.0",
4
+ "description": "A CommonMark-compliant Markdown parser with optional GFM support",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/types/index.d.ts",
11
+ "import": "./dist/esm/index.js",
12
+ "require": "./dist/cjs/index.js"
13
+ },
14
+ "./gfm": {
15
+ "types": "./dist/types/gfm.d.ts",
16
+ "import": "./dist/esm/gfm.js",
17
+ "require": "./dist/cjs/gfm.js"
18
+ }
19
+ },
20
+ "bin": {
21
+ "mdparse": "dist/cjs/cli.js"
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "scripts": {
27
+ "build": "npm run build:types && npm run build:cjs && npm run build:esm",
28
+ "build:cjs": "tsc -p tsconfig.cjs.json",
29
+ "build:esm": "tsc -p tsconfig.esm.json && node scripts/write-esm-package.cjs",
30
+ "build:types": "tsc -p tsconfig.types.json",
31
+ "test": "node --test dist/cjs/**/*.test.js",
32
+ "prepublishOnly": "npm run build"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/SerenaFontaine/emdp.git"
37
+ },
38
+ "keywords": [
39
+ "markdown",
40
+ "commonmark",
41
+ "gfm",
42
+ "github-flavored-markdown",
43
+ "parser"
44
+ ],
45
+ "author": "Serena Fontaine",
46
+ "license": "MIT",
47
+ "bugs": {
48
+ "url": "https://github.com/SerenaFontaine/emdp/issues"
49
+ },
50
+ "devDependencies": {
51
+ "@types/node": "^25.0.9",
52
+ "typescript": "^5.3.0"
53
+ }
54
+ }