markdown-to-adf 0.2.1

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 (56) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +21 -0
  3. package/README.md +328 -0
  4. package/SECURITY.md +3 -0
  5. package/dist/builders/index.d.ts +22 -0
  6. package/dist/builders/index.d.ts.map +1 -0
  7. package/dist/builders/index.js +22 -0
  8. package/dist/builders/index.js.map +1 -0
  9. package/dist/builders/marks.d.ts +43 -0
  10. package/dist/builders/marks.d.ts.map +1 -0
  11. package/dist/builders/marks.js +54 -0
  12. package/dist/builders/marks.js.map +1 -0
  13. package/dist/builders/nodes.d.ts +133 -0
  14. package/dist/builders/nodes.d.ts.map +1 -0
  15. package/dist/builders/nodes.js +234 -0
  16. package/dist/builders/nodes.js.map +1 -0
  17. package/dist/converter/block-parser.d.ts +38 -0
  18. package/dist/converter/block-parser.d.ts.map +1 -0
  19. package/dist/converter/block-parser.js +426 -0
  20. package/dist/converter/block-parser.js.map +1 -0
  21. package/dist/converter.d.ts +39 -0
  22. package/dist/converter.d.ts.map +1 -0
  23. package/dist/converter.js +81 -0
  24. package/dist/converter.js.map +1 -0
  25. package/dist/index.d.ts +29 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +30 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/markdown/parser.d.ts +11 -0
  30. package/dist/markdown/parser.d.ts.map +1 -0
  31. package/dist/markdown/parser.js +16 -0
  32. package/dist/markdown/parser.js.map +1 -0
  33. package/dist/presets/index.d.ts +23 -0
  34. package/dist/presets/index.d.ts.map +1 -0
  35. package/dist/presets/index.js +90 -0
  36. package/dist/presets/index.js.map +1 -0
  37. package/dist/types/adf.d.ts +252 -0
  38. package/dist/types/adf.d.ts.map +1 -0
  39. package/dist/types/adf.js +7 -0
  40. package/dist/types/adf.js.map +1 -0
  41. package/dist/types/index.d.ts +6 -0
  42. package/dist/types/index.d.ts.map +1 -0
  43. package/dist/types/index.js +5 -0
  44. package/dist/types/index.js.map +1 -0
  45. package/dist/types/options.d.ts +141 -0
  46. package/dist/types/options.d.ts.map +1 -0
  47. package/dist/types/options.js +5 -0
  48. package/dist/types/options.js.map +1 -0
  49. package/dist/utils/inline-parser.d.ts +16 -0
  50. package/dist/utils/inline-parser.d.ts.map +1 -0
  51. package/dist/utils/inline-parser.js +174 -0
  52. package/dist/utils/inline-parser.js.map +1 -0
  53. package/docs/compatibility.md +30 -0
  54. package/docs/presets.md +22 -0
  55. package/docs/warnings.md +20 -0
  56. package/package.json +68 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.2.1] - 2026-02-13
11
+ - Fixed strict TypeScript narrowing in task list whitespace trimming.
12
+
13
+ ## [0.2.0] - 2026-02-13
14
+ - Added markdown-it parsing for spec-accurate Markdown support.
15
+ - Added warnings API and risky-node warnings for tables in comments.
16
+ - Added linting, formatting, and CI workflows.
17
+ - Split converter into focused modules for parsing and conversion.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 markdown-to-adf contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,328 @@
1
+ # markdown-to-adf
2
+
3
+ [![CI](https://github.com/califlower/markdown-to-adf/actions/workflows/ci.yml/badge.svg)](https://github.com/califlower/markdown-to-adf/actions/workflows/ci.yml)
4
+ [![npm version](https://img.shields.io/npm/v/markdown-to-adf.svg)](https://www.npmjs.com/package/markdown-to-adf)
5
+ [![license](https://img.shields.io/npm/l/markdown-to-adf.svg)](https://github.com/califlower/markdown-to-adf/blob/main/LICENSE)
6
+
7
+ Convert Markdown to Atlassian Document Format (ADF) with context-aware presets for Jira.
8
+
9
+ Built from production experience: this library handles the nuances of ADF support across different Jira contexts, preventing the "INVALID_INPUT" errors that plague manual ADF generation.
10
+
11
+ ## Installation
12
+
13
+ ### From npm
14
+
15
+ ```bash
16
+ npm install markdown-to-adf
17
+ ```
18
+
19
+ ### Install from Source
20
+
21
+ ```bash
22
+ # Clone the repository
23
+ git clone https://github.com/califlower/markdown-to-adf.git
24
+ cd markdown-to-adf
25
+
26
+ # Install dependencies
27
+ npm install
28
+
29
+ # Build the library
30
+ npm run build
31
+ ```
32
+
33
+ ### Use as a Git Dependency
34
+
35
+ You can also reference it directly in your `package.json`:
36
+
37
+ ```json
38
+ {
39
+ "dependencies": {
40
+ "markdown-to-adf": "git+https://github.com/califlower/markdown-to-adf.git#v0.2.0"
41
+ }
42
+ }
43
+ ```
44
+
45
+ Then run `npm install`.
46
+
47
+ ## Quick Start
48
+
49
+ ```typescript
50
+ import { markdownToAdf } from 'markdown-to-adf';
51
+
52
+ // Basic usage
53
+ const adf = markdownToAdf('## Hello\n- Item 1\n- Item 2');
54
+
55
+ // Context-specific presets
56
+ const adf = markdownToAdf(markdown, { preset: 'comment' }); // For issue comments
57
+ const adf = markdownToAdf(markdown, { preset: 'task' }); // For Task issues
58
+ const adf = markdownToAdf(markdown, { preset: 'story' }); // For Story/Epic issues
59
+ ```
60
+
61
+ ## Features
62
+
63
+ - **Type-safe**: Full TypeScript support with comprehensive types
64
+ - **Context-aware**: Presets optimized for different Jira contexts
65
+ - **AST-backed parsing**: Uses markdown-it for spec-accurate Markdown parsing
66
+ - **Well-tested**: Comprehensive test coverage
67
+ - **Modern**: ESM-only, built for current tooling
68
+
69
+ ## Docs
70
+
71
+ - Presets: `docs/presets.md`
72
+ - Compatibility: `docs/compatibility.md`
73
+ - Warnings: `docs/warnings.md`
74
+
75
+ ## Supported Markdown
76
+
77
+ | Feature | Syntax | Support |
78
+ | ------------- | -------------------- | ------------------- | --- | --- | --------------------------------- |
79
+ | Paragraphs | Plain text | Universal |
80
+ | Bold | `**text**` | Universal |
81
+ | Italic | `*text*` or `_text_` | Universal |
82
+ | Inline code | `` `code` `` | Universal |
83
+ | Strikethrough | `~~text~~` | Universal |
84
+ | Links | `[text](url)` | Universal |
85
+ | Headings | `## text` | Context-dependent\* |
86
+ | Bullet lists | `- item` | Universal |
87
+ | Ordered lists | `1. item` | Universal |
88
+ | Task lists | `- [ ] item` | Universal |
89
+ | Tables | ` | a | b | ` | Universal (risky in comments)\*\* |
90
+ | Code blocks | ` ```lang ` | Universal |
91
+ | Block quotes | `> text` | Universal |
92
+
93
+ \*See Heading Support section below.
94
+ \*\*Tables are valid in comments but can be inconsistent in some Jira views.
95
+
96
+ ## Critical: Heading Support
97
+
98
+ Headings are not universally supported in Jira's ADF implementation:
99
+
100
+ | Context | Headings | Preset |
101
+ | ----------------- | ------------- | --------- |
102
+ | Issue Comments | Not supported | `comment` |
103
+ | Task Issues | Not supported | `task` |
104
+ | Story/Epic Issues | Supported | `story` |
105
+
106
+ When headings aren't supported, they convert to bold paragraphs automatically.
107
+ With `strictMode: true`, incompatible headings throw instead of converting.
108
+
109
+ Tables are valid in comments, but can be flaky in some Jira surfaces. The `comment` preset enables
110
+ `warnOnRiskyNodes` by default to surface these cases.
111
+
112
+ ## API Reference
113
+
114
+ ### markdownToAdf(markdown, options?)
115
+
116
+ ```typescript
117
+ function markdownToAdf(markdown: string, options?: ConversionOptions): ADFDocument;
118
+ ```
119
+
120
+ #### ConversionOptions
121
+
122
+ ```typescript
123
+ interface ConversionOptions {
124
+ // Preset for specific Jira context
125
+ preset?: 'comment' | 'task' | 'story' | 'default';
126
+
127
+ // Use actual heading nodes (only for supported contexts)
128
+ useHeadings?: boolean;
129
+
130
+ // Maximum heading level (1-6)
131
+ maxHeadingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
132
+
133
+ // Default language for unlabeled code blocks
134
+ defaultCodeLanguage?: string;
135
+
136
+ // Throw on unsupported markdown
137
+ strictMode?: boolean;
138
+
139
+ // Warn on risky-but-valid nodes (e.g., tables in comments)
140
+ warnOnRiskyNodes?: boolean;
141
+
142
+ // Preserve single line breaks
143
+ preserveLineBreaks?: boolean;
144
+ }
145
+ ```
146
+
147
+ ### markdownToAdfWithWarnings(markdown, options?)
148
+
149
+ ```typescript
150
+ function markdownToAdfWithWarnings(
151
+ markdown: string,
152
+ options?: ConversionOptions,
153
+ ): { adf: ADFDocument; warnings: ConversionWarning[] };
154
+ ```
155
+
156
+ ### Warnings
157
+
158
+ Use the warnings API when you want visibility into lossy conversions or risky nodes:
159
+
160
+ ```typescript
161
+ import { markdownToAdfWithWarnings } from 'markdown-to-adf';
162
+
163
+ const { adf, warnings } = markdownToAdfWithWarnings(markdown, {
164
+ preset: 'comment',
165
+ });
166
+ ```
167
+
168
+ Warnings can include:
169
+
170
+ - `lossy_conversion` (e.g., headings converted to bold)
171
+ - `unsupported_feature` (e.g., horizontal rules)
172
+ - `risky_feature` (e.g., tables in comments)
173
+
174
+ The `comment` preset enables `warnOnRiskyNodes` by default.
175
+
176
+ ### Type Exports
177
+
178
+ All ADF types are exported:
179
+
180
+ ```typescript
181
+ import type {
182
+ ADFDocument,
183
+ ADFParagraph,
184
+ ADFHeading,
185
+ ADFBulletList,
186
+ ConversionOptions,
187
+ } from 'markdown-to-adf';
188
+ ```
189
+
190
+ ## Versioning
191
+
192
+ This project follows [Semantic Versioning](https://semver.org/). Breaking changes will be released in a major version.
193
+
194
+ ### Builder Functions
195
+
196
+ For manual ADF construction:
197
+
198
+ ```typescript
199
+ import { doc, paragraph, text, strong } from 'markdown-to-adf';
200
+
201
+ const adf = doc([paragraph([text('Hello '), text('world', [strong()])])]);
202
+ ```
203
+
204
+ ## Examples
205
+
206
+ ### Jira Comment
207
+
208
+ ```typescript
209
+ const markdown = `
210
+ Key findings:
211
+
212
+ **Issues:**
213
+ - Authentication fails on retry
214
+ - Response timeout after 30s
215
+
216
+ Check the server logs for details.
217
+ `;
218
+
219
+ const adf = markdownToAdf(markdown, { preset: 'comment' });
220
+ ```
221
+
222
+ ### Task Description
223
+
224
+ ```typescript
225
+ const markdown = `
226
+ ## Acceptance Criteria
227
+ - Feature implements retry logic
228
+ - Tests cover edge cases
229
+ - Documentation updated
230
+
231
+ ## Technical Notes
232
+ Requires API version 2.0 or higher.
233
+ `;
234
+
235
+ const adf = markdownToAdf(markdown, { preset: 'task' });
236
+ ```
237
+
238
+ ### Story Description
239
+
240
+ ```typescript
241
+ const markdown = `
242
+ # User Story
243
+ As a developer, I need retry logic for API calls.
244
+
245
+ ## Implementation
246
+ Add exponential backoff:
247
+
248
+ \`\`\`typescript
249
+ async function retryRequest(fn: () => Promise<T>, maxRetries = 3) {
250
+ // implementation
251
+ }
252
+ \`\`\`
253
+
254
+ ## Acceptance Criteria
255
+ - Retries up to 3 times
256
+ - Uses exponential backoff
257
+ `;
258
+
259
+ const adf = markdownToAdf(markdown, { preset: 'story' });
260
+ ```
261
+
262
+ ## Known Limitations
263
+
264
+ ### Heading Support
265
+
266
+ Headings only work in Story/Epic issue types. Use appropriate presets or set `useHeadings: false`.
267
+
268
+ ### List Item Content
269
+
270
+ List items can only contain paragraphs and nested lists. Other blocks inside list items are dropped with warnings.
271
+
272
+ ### Tables
273
+
274
+ Tables are supported, but can be inconsistent in some Jira comment views. Use the warnings API to audit usage.
275
+
276
+ ### Images
277
+
278
+ Image syntax (`![alt](url)`) is converted to linked text; ADF media nodes are not emitted.
279
+
280
+ ### HTML
281
+
282
+ Raw HTML in markdown is not supported.
283
+
284
+ ## Troubleshooting
285
+
286
+ ### "INVALID_INPUT" from Jira
287
+
288
+ Common causes:
289
+
290
+ 1. Using headings in unsupported contexts (use `comment` or `task` preset)
291
+ 2. Complex nesting that exceeds ADF schema limits
292
+ 3. Unsupported markdown features
293
+
294
+ Solution: Start with simple markdown and gradually add complexity.
295
+
296
+ ### Type Errors
297
+
298
+ Ensure TypeScript 5.3+ is installed:
299
+
300
+ ```bash
301
+ npm install -D typescript@^5.3.0
302
+ ```
303
+
304
+ ## Development
305
+
306
+ ```bash
307
+ bun install # Install dependencies
308
+ bun test # Run tests
309
+ bun test --watch # Watch mode
310
+ bun run typecheck # Type checking
311
+ bun run lint # Lint
312
+ bun run format # Format
313
+ bun run build # Build for distribution
314
+ ```
315
+
316
+ ## Why This Library Exists
317
+
318
+ Atlassian's ADF implementation has context-specific limitations that aren't well documented:
319
+
320
+ - Task issues don't support heading nodes
321
+ - Comments have a restricted schema
322
+ - No clear documentation of these constraints
323
+
324
+ This library encodes production learnings so you don't encounter these issues.
325
+
326
+ ## License
327
+
328
+ MIT
package/SECURITY.md ADDED
@@ -0,0 +1,3 @@
1
+ # Security Policy
2
+
3
+ If you discover a security issue, please email the maintainer directly rather than opening a public issue.
@@ -0,0 +1,22 @@
1
+ /**
2
+ * ADF node and mark builder functions.
3
+ *
4
+ * @remarks
5
+ * These are pure functions that create properly-typed ADF nodes.
6
+ * They can be used to manually construct ADF documents if needed.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { doc, paragraph, text, strong } from 'markdown-to-adf/builders';
11
+ *
12
+ * const adf = doc([
13
+ * paragraph([
14
+ * text('Hello '),
15
+ * text('world', [strong()]),
16
+ * ]),
17
+ * ]);
18
+ * ```
19
+ */
20
+ export { doc, paragraph, heading, bulletList, orderedList, listItem, taskList, taskItem, codeBlock, blockQuote, rule, text, hardBreak, table, tableRow, tableHeader, tableCell, } from './nodes.js';
21
+ export { strong, em, code, strike, underline, link } from './marks.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builders/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,GAAG,EACH,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,KAAK,EACL,QAAQ,EACR,WAAW,EACX,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * ADF node and mark builder functions.
3
+ *
4
+ * @remarks
5
+ * These are pure functions that create properly-typed ADF nodes.
6
+ * They can be used to manually construct ADF documents if needed.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { doc, paragraph, text, strong } from 'markdown-to-adf/builders';
11
+ *
12
+ * const adf = doc([
13
+ * paragraph([
14
+ * text('Hello '),
15
+ * text('world', [strong()]),
16
+ * ]),
17
+ * ]);
18
+ * ```
19
+ */
20
+ export { doc, paragraph, heading, bulletList, orderedList, listItem, taskList, taskItem, codeBlock, blockQuote, rule, text, hardBreak, table, tableRow, tableHeader, tableCell, } from './nodes.js';
21
+ export { strong, em, code, strike, underline, link } from './marks.js';
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/builders/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,GAAG,EACH,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,KAAK,EACL,QAAQ,EACR,WAAW,EACX,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Pure functions for building ADF marks (inline formatting).
3
+ */
4
+ import type { ADFStrongMark, ADFEmMark, ADFCodeMark, ADFStrikeMark, ADFUnderlineMark, ADFLinkMark } from '../types/adf.js';
5
+ /**
6
+ * Creates a bold (strong) mark.
7
+ *
8
+ * @returns A strong mark
9
+ */
10
+ export declare function strong(): ADFStrongMark;
11
+ /**
12
+ * Creates an italic (emphasis) mark.
13
+ *
14
+ * @returns An emphasis mark
15
+ */
16
+ export declare function em(): ADFEmMark;
17
+ /**
18
+ * Creates an inline code mark.
19
+ *
20
+ * @returns A code mark
21
+ */
22
+ export declare function code(): ADFCodeMark;
23
+ /**
24
+ * Creates a strikethrough mark.
25
+ *
26
+ * @returns A strike mark
27
+ */
28
+ export declare function strike(): ADFStrikeMark;
29
+ /**
30
+ * Creates an underline mark.
31
+ *
32
+ * @returns An underline mark
33
+ */
34
+ export declare function underline(): ADFUnderlineMark;
35
+ /**
36
+ * Creates a hyperlink mark.
37
+ *
38
+ * @param href - The URL to link to
39
+ * @param title - Optional link title
40
+ * @returns A link mark
41
+ */
42
+ export declare function link(href: string, title?: string): ADFLinkMark;
43
+ //# sourceMappingURL=marks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marks.d.ts","sourceRoot":"","sources":["../../src/builders/marks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAEzB;;;;GAIG;AACH,wBAAgB,MAAM,IAAI,aAAa,CAEtC;AAED;;;;GAIG;AACH,wBAAgB,EAAE,IAAI,SAAS,CAE9B;AAED;;;;GAIG;AACH,wBAAgB,IAAI,IAAI,WAAW,CAElC;AAED;;;;GAIG;AACH,wBAAgB,MAAM,IAAI,aAAa,CAEtC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,gBAAgB,CAE5C;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CAE9D"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Pure functions for building ADF marks (inline formatting).
3
+ */
4
+ /**
5
+ * Creates a bold (strong) mark.
6
+ *
7
+ * @returns A strong mark
8
+ */
9
+ export function strong() {
10
+ return { type: 'strong' };
11
+ }
12
+ /**
13
+ * Creates an italic (emphasis) mark.
14
+ *
15
+ * @returns An emphasis mark
16
+ */
17
+ export function em() {
18
+ return { type: 'em' };
19
+ }
20
+ /**
21
+ * Creates an inline code mark.
22
+ *
23
+ * @returns A code mark
24
+ */
25
+ export function code() {
26
+ return { type: 'code' };
27
+ }
28
+ /**
29
+ * Creates a strikethrough mark.
30
+ *
31
+ * @returns A strike mark
32
+ */
33
+ export function strike() {
34
+ return { type: 'strike' };
35
+ }
36
+ /**
37
+ * Creates an underline mark.
38
+ *
39
+ * @returns An underline mark
40
+ */
41
+ export function underline() {
42
+ return { type: 'underline' };
43
+ }
44
+ /**
45
+ * Creates a hyperlink mark.
46
+ *
47
+ * @param href - The URL to link to
48
+ * @param title - Optional link title
49
+ * @returns A link mark
50
+ */
51
+ export function link(href, title) {
52
+ return title ? { type: 'link', attrs: { href, title } } : { type: 'link', attrs: { href } };
53
+ }
54
+ //# sourceMappingURL=marks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marks.js","sourceRoot":"","sources":["../../src/builders/marks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH;;;;GAIG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,EAAE;IAChB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,IAAI;IAClB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,KAAc;IAC/C,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;AAC9F,CAAC"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Pure functions for building ADF nodes.
3
+ * Each function creates a properly-typed ADF node without side effects.
4
+ */
5
+ import type { ADFDocument, ADFParagraph, ADFHeading, ADFBulletList, ADFOrderedList, ADFTaskList, ADFTaskItem, ADFListItem, ADFCodeBlock, ADFBlockQuote, ADFRule, ADFText, ADFHardBreak, ADFBlockNode, ADFInlineNode, ADFMark, ADFTable, ADFTableRow, ADFTableHeader, ADFTableCell } from '../types/adf.js';
6
+ /**
7
+ * Creates an ADF document root node.
8
+ *
9
+ * @param content - Array of block nodes to include in the document
10
+ * @returns A complete ADF document
11
+ */
12
+ export declare function doc(content: readonly ADFBlockNode[]): ADFDocument;
13
+ /**
14
+ * Creates a paragraph node.
15
+ *
16
+ * @param content - Array of inline nodes (text, links, etc.)
17
+ * @returns A paragraph node
18
+ */
19
+ export declare function paragraph(content?: readonly ADFInlineNode[]): ADFParagraph;
20
+ /**
21
+ * Creates a heading node.
22
+ *
23
+ * @param level - Heading level (1-6)
24
+ * @param content - Array of inline nodes
25
+ * @returns A heading node
26
+ */
27
+ export declare function heading(level: 1 | 2 | 3 | 4 | 5 | 6, content: readonly ADFInlineNode[]): ADFHeading;
28
+ /**
29
+ * Creates a bullet list node.
30
+ *
31
+ * @param items - Array of list items
32
+ * @returns A bullet list node
33
+ */
34
+ export declare function bulletList(items: readonly ADFListItem[]): ADFBulletList;
35
+ /**
36
+ * Creates an ordered list node.
37
+ *
38
+ * @param items - Array of list items
39
+ * @returns An ordered list node
40
+ */
41
+ export declare function orderedList(items: readonly ADFListItem[]): ADFOrderedList;
42
+ /**
43
+ * Creates a list item node.
44
+ *
45
+ * @param content - Array of paragraphs or nested lists
46
+ * @returns A list item node
47
+ */
48
+ export declare function listItem(content: readonly (ADFParagraph | ADFBulletList | ADFOrderedList)[]): ADFListItem;
49
+ /**
50
+ * Creates a task list node (checkbox list).
51
+ *
52
+ * @param items - Array of task items
53
+ * @param localId - Optional local ID for the task list
54
+ * @returns A task list node
55
+ */
56
+ export declare function taskList(items: readonly ADFTaskItem[], localId?: string): ADFTaskList;
57
+ /**
58
+ * Creates a task item node (checkbox item).
59
+ *
60
+ * @param content - Array of inline nodes
61
+ * @param checked - Whether the task is checked
62
+ * @param localId - Optional local ID for the task item
63
+ * @returns A task item node
64
+ */
65
+ export declare function taskItem(content: readonly ADFInlineNode[], checked?: boolean, localId?: string): ADFTaskItem;
66
+ /**
67
+ * Creates a code block node.
68
+ *
69
+ * @param code - The code content as a string
70
+ * @param language - Optional language for syntax highlighting
71
+ * @returns A code block node
72
+ */
73
+ export declare function codeBlock(code: string, language?: string): ADFCodeBlock;
74
+ /**
75
+ * Creates a block quote node.
76
+ *
77
+ * @param content - Array of block nodes inside the quote
78
+ * @returns A block quote node
79
+ */
80
+ export declare function blockQuote(content: readonly ADFBlockNode[]): ADFBlockQuote;
81
+ /**
82
+ * Creates a horizontal rule (divider) node.
83
+ *
84
+ * @returns A rule node
85
+ */
86
+ export declare function rule(): ADFRule;
87
+ /**
88
+ * Creates a text node with optional formatting marks.
89
+ *
90
+ * @param text - The text content
91
+ * @param marks - Optional array of formatting marks (bold, italic, etc.)
92
+ * @returns A text node
93
+ */
94
+ export declare function text(text: string, marks?: readonly ADFMark[]): ADFText;
95
+ /**
96
+ * Creates a hard line break node.
97
+ *
98
+ * @returns A hard break node
99
+ */
100
+ export declare function hardBreak(): ADFHardBreak;
101
+ /**
102
+ * Creates a table node.
103
+ *
104
+ * @param rows - Array of table rows
105
+ * @param options - Optional table attributes
106
+ * @returns A table node
107
+ */
108
+ export declare function table(rows: readonly ADFTableRow[], options?: {
109
+ isNumberColumnEnabled?: boolean;
110
+ layout?: 'default' | 'wide' | 'full-width';
111
+ }): ADFTable;
112
+ /**
113
+ * Creates a table row node.
114
+ *
115
+ * @param cells - Array of table cells or headers
116
+ * @returns A table row node
117
+ */
118
+ export declare function tableRow(cells: readonly (ADFTableCell | ADFTableHeader)[]): ADFTableRow;
119
+ /**
120
+ * Creates a table header cell node.
121
+ *
122
+ * @param content - Array of paragraphs
123
+ * @returns A table header cell node
124
+ */
125
+ export declare function tableHeader(content: readonly ADFParagraph[]): ADFTableHeader;
126
+ /**
127
+ * Creates a table data cell node.
128
+ *
129
+ * @param content - Array of paragraphs
130
+ * @returns A table data cell node
131
+ */
132
+ export declare function tableCell(content: readonly ADFParagraph[]): ADFTableCell;
133
+ //# sourceMappingURL=nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/builders/nodes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,EACd,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,OAAO,EACP,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,OAAO,EACP,QAAQ,EACR,WAAW,EACX,cAAc,EACd,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,WAAW,CAMjE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,SAAS,aAAa,EAAO,GAAG,YAAY,CAE9E;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAC5B,OAAO,EAAE,SAAS,aAAa,EAAE,GAChC,UAAU,CAMZ;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,aAAa,CAKvE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,cAAc,CAKzE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,SAAS,CAAC,YAAY,GAAG,aAAa,GAAG,cAAc,CAAC,EAAE,GAClE,WAAW,CAKb;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAMrF;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,OAAO,GAAE,OAAe,EACxB,OAAO,CAAC,EAAE,MAAM,GACf,WAAW,CASb;AAUD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,YAAY,CAavE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,aAAa,CAK1E;AAED;;;;GAIG;AACH,wBAAgB,IAAI,IAAI,OAAO,CAE9B;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,YAAY,CAExC;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,SAAS,WAAW,EAAE,EAC5B,OAAO,CAAC,EAAE;IAAE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,YAAY,CAAA;CAAE,GACxF,QAAQ,CAcV;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,YAAY,GAAG,cAAc,CAAC,EAAE,GAAG,WAAW,CAKvF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,cAAc,CAM5E;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,YAAY,CAMxE"}