mrkdwn.js 4.0.6 → 6.6.2

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 (118) hide show
  1. package/README.md +85 -66
  2. package/dist/ast/ast.d.cts +1 -1
  3. package/dist/ast/ast.d.ts +1 -1
  4. package/dist/{ast-8XCbjRQT.d.cts → ast-CNfTgS0N.d.cts} +35 -35
  5. package/dist/{ast-8XCbjRQT.d.ts → ast-CNfTgS0N.d.ts} +35 -35
  6. package/dist/block/block.cjs +12 -4
  7. package/dist/block/block.d.cts +9 -5
  8. package/dist/block/block.d.ts +9 -5
  9. package/dist/block/block.js +8 -4
  10. package/dist/block/definitions.d.cts +2 -2
  11. package/dist/block/definitions.d.ts +2 -2
  12. package/dist/block/node.d.cts +4 -4
  13. package/dist/block/node.d.ts +4 -4
  14. package/dist/block/table.d.cts +1 -1
  15. package/dist/block/table.d.ts +1 -1
  16. package/dist/codec.cjs +1 -1
  17. package/dist/codec.d.cts +1631 -29
  18. package/dist/codec.d.ts +1631 -29
  19. package/dist/codec.js +2 -2
  20. package/dist/defaults/defaults.d.cts +1 -1
  21. package/dist/defaults/defaults.d.ts +1 -1
  22. package/dist/diagnostics/diagnostics.cjs +17 -7
  23. package/dist/diagnostics/diagnostics.d.cts +2 -2
  24. package/dist/diagnostics/diagnostics.d.ts +2 -2
  25. package/dist/diagnostics/diagnostics.js +17 -8
  26. package/dist/{diagnostics-BWK1iGy7.d.cts → diagnostics-CjfBoW4K.d.cts} +14 -10
  27. package/dist/{diagnostics-BWK1iGy7.d.ts → diagnostics-CjfBoW4K.d.ts} +14 -10
  28. package/dist/emit/emit.cjs +378 -42
  29. package/dist/emit/emit.js +381 -45
  30. package/dist/emit/front-matter.cjs +22 -5
  31. package/dist/emit/front-matter.js +22 -5
  32. package/dist/emit/html-table.cjs +104 -0
  33. package/dist/emit/html-table.d.cts +7 -0
  34. package/dist/emit/html-table.d.ts +7 -0
  35. package/dist/emit/html-table.js +102 -0
  36. package/dist/emit/inline.cjs +69 -26
  37. package/dist/emit/inline.d.cts +2 -12
  38. package/dist/emit/inline.d.ts +2 -12
  39. package/dist/emit/inline.js +68 -27
  40. package/dist/emit/table.cjs +18 -11
  41. package/dist/emit/table.d.cts +3 -2
  42. package/dist/emit/table.d.ts +3 -2
  43. package/dist/emit/table.js +18 -11
  44. package/dist/html/html-table.cjs +243 -0
  45. package/dist/html/html-table.d.cts +5 -0
  46. package/dist/html/html-table.d.ts +5 -0
  47. package/dist/html/html-table.js +242 -0
  48. package/dist/html/render.d.cts +1 -1
  49. package/dist/html/render.d.ts +1 -1
  50. package/dist/image/image.cjs +4 -4
  51. package/dist/image/image.d.cts +1 -1
  52. package/dist/image/image.d.ts +1 -1
  53. package/dist/image/image.js +4 -4
  54. package/dist/{image-C4KYmz_L.d.cts → image-B5L0HpAJ.d.cts} +1 -1
  55. package/dist/{image-DescdRgq.d.cts → image-BtmTG4_a.d.cts} +1 -1
  56. package/dist/{image-DescdRgq.d.ts → image-BtmTG4_a.d.ts} +1 -1
  57. package/dist/{image-Cm3hT5PS.d.ts → image-C390OIB3.d.ts} +1 -1
  58. package/dist/index.cjs +2 -2
  59. package/dist/index.d.cts +4 -4
  60. package/dist/index.d.ts +4 -4
  61. package/dist/index.js +3 -3
  62. package/dist/inline/delimiter.d.cts +2 -2
  63. package/dist/inline/delimiter.d.ts +2 -2
  64. package/dist/inline/inline.d.cts +1 -1
  65. package/dist/inline/inline.d.ts +1 -1
  66. package/dist/inline/link.d.cts +17 -1
  67. package/dist/inline/link.d.ts +17 -1
  68. package/dist/inline/node.d.cts +2 -2
  69. package/dist/inline/node.d.ts +2 -2
  70. package/dist/{inline-CXVQWQnW.d.cts → inline-CnO86zMw.d.cts} +2 -2
  71. package/dist/inline-DCIKQ83j.d.cts +14 -0
  72. package/dist/{inline-B_V7bs5j.d.ts → inline-DItZ-VVw.d.ts} +2 -2
  73. package/dist/inline-INoDAG37.d.ts +14 -0
  74. package/dist/lower/front-matter.cjs +73 -26
  75. package/dist/lower/front-matter.d.cts +2 -1
  76. package/dist/lower/front-matter.d.ts +2 -1
  77. package/dist/lower/front-matter.js +72 -25
  78. package/dist/lower/image.d.cts +1 -1
  79. package/dist/lower/image.d.ts +1 -1
  80. package/dist/lower/inline.cjs +87 -33
  81. package/dist/lower/inline.d.cts +9 -12
  82. package/dist/lower/inline.d.ts +9 -12
  83. package/dist/lower/inline.js +89 -34
  84. package/dist/lower/lower.cjs +143 -113
  85. package/dist/lower/lower.d.cts +8 -1
  86. package/dist/lower/lower.d.ts +8 -1
  87. package/dist/lower/lower.js +144 -115
  88. package/dist/lower/table.cjs +3 -2
  89. package/dist/lower/table.d.cts +1 -1
  90. package/dist/lower/table.d.ts +1 -1
  91. package/dist/lower/table.js +3 -2
  92. package/dist/options/options.d.cts +10 -10
  93. package/dist/options/options.d.ts +10 -10
  94. package/dist/read.cjs +45 -9
  95. package/dist/read.d.cts +3 -3
  96. package/dist/read.d.ts +3 -3
  97. package/dist/read.js +47 -11
  98. package/dist/scan/entity-table.cjs +2125 -2125
  99. package/dist/scan/entity-table.js +2125 -2125
  100. package/dist/shared/line-ending.cjs +7 -0
  101. package/dist/shared/line-ending.d.cts +5 -0
  102. package/dist/shared/line-ending.d.ts +5 -0
  103. package/dist/shared/line-ending.js +5 -0
  104. package/dist/shared/list-id.cjs +11 -3
  105. package/dist/shared/list-id.d.cts +7 -4
  106. package/dist/shared/list-id.d.ts +7 -4
  107. package/dist/shared/list-id.js +11 -4
  108. package/dist/shared/style-constants.cjs +0 -2
  109. package/dist/shared/style-constants.d.cts +1 -2
  110. package/dist/shared/style-constants.d.ts +1 -2
  111. package/dist/shared/style-constants.js +1 -2
  112. package/dist/write.cjs +33 -6
  113. package/dist/write.d.cts +2 -2
  114. package/dist/write.d.ts +2 -2
  115. package/dist/write.js +34 -7
  116. package/package.json +29 -30
  117. package/dist/link-Dv4kxVjk.d.cts +0 -18
  118. package/dist/link-Dv4kxVjk.d.ts +0 -18
@@ -2,10 +2,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_defaults_defaults = require("../defaults/defaults.cjs");
3
3
  const require_diagnostics_diagnostics = require("../diagnostics/diagnostics.cjs");
4
4
  const require_block_block = require("../block/block.cjs");
5
- const require_shared_list_id = require("../shared/list-id.cjs");
5
+ const require_lower_image = require("./image.cjs");
6
6
  const require_shared_style_constants = require("../shared/style-constants.cjs");
7
+ const require_html_html_table = require("../html/html-table.cjs");
8
+ const require_shared_list_id = require("../shared/list-id.cjs");
7
9
  const require_lower_front_matter = require("./front-matter.cjs");
8
- const require_lower_image = require("./image.cjs");
9
10
  const require_lower_inline = require("./inline.cjs");
10
11
  const require_lower_table = require("./table.cjs");
11
12
  let document_schema_js = require("document-schema.js");
@@ -25,17 +26,21 @@ function decorateParagraph(paragraph, context) {
25
26
  };
26
27
  if (context.list !== void 0) result = {
27
28
  ...result,
28
- list: {
29
- numId: context.list.numId,
30
- level: context.list.level
31
- }
29
+ list: { ...context.list }
32
30
  };
33
31
  return result;
34
32
  }
33
+ function paragraphWithConstructs(runs, runConstructExtents) {
34
+ return {
35
+ runs,
36
+ ...runConstructExtents.length > 0 ? { constructs: [...runConstructExtents] } : {}
37
+ };
38
+ }
35
39
  function lowerHeading(node, context) {
40
+ const inline = require_lower_inline.lowerInlineNodes(node.children, inlineContext(context));
36
41
  return [decorateParagraph({
37
42
  kind: "paragraph",
38
- runs: require_lower_inline.lowerInlineNodes(node.children, inlineContext(context)),
43
+ ...paragraphWithConstructs(inline.runs, inline.runConstructExtents),
39
44
  styleId: require_shared_style_constants.headingStyleId(node.level),
40
45
  headingLevel: node.level
41
46
  }, context)];
@@ -46,9 +51,10 @@ function lowerParagraph(node, context) {
46
51
  let segment = [];
47
52
  const flushSegment = (force) => {
48
53
  if (segment.length === 0 && !force) return;
54
+ const inline = require_lower_inline.lowerInlineNodes(segment, inlineCtx);
49
55
  blocks.push(decorateParagraph({
50
56
  kind: "paragraph",
51
- runs: require_lower_inline.lowerInlineNodes(segment, inlineCtx)
57
+ ...paragraphWithConstructs(inline.runs, inline.runConstructExtents)
52
58
  }, context));
53
59
  segment = [];
54
60
  };
@@ -70,39 +76,74 @@ function lowerParagraph(node, context) {
70
76
  segment.push(child);
71
77
  continue;
72
78
  }
73
- if (child.title !== void 0) context.sink({
74
- code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.LINK_TITLE_DROPPED,
75
- severity: "info",
76
- message: `image title "${child.title}" has no ContentImageBlock equivalent and was dropped`
77
- });
78
79
  flushSegment(false);
79
80
  if (context.list !== void 0) context.sink({
80
81
  code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.LIST_ITEM_BLOCK_UNLISTED,
81
82
  severity: "info",
82
83
  message: "a resolved image block directly inside a list item has no ContentListMembership field of its own -- only ContentParagraph carries .list -- so its association with the enclosing list item is lost"
83
84
  });
84
- blocks.push({
85
+ const image = {
85
86
  kind: "image",
86
87
  format: resolved.format,
87
88
  base64: resolved.base64,
88
89
  widthPt: resolved.widthPt,
89
90
  heightPt: resolved.heightPt,
90
91
  ...child.alt.length > 0 ? { altText: child.alt } : {}
91
- });
92
+ };
93
+ if (child.title === void 0) {
94
+ blocks.push(image);
95
+ continue;
96
+ }
97
+ blocks.push({
98
+ kind: "constructStart",
99
+ descriptor: {
100
+ kind: "link",
101
+ target: {
102
+ kind: "external",
103
+ uri: child.destination
104
+ },
105
+ title: child.title
106
+ }
107
+ }, image, { kind: "constructEnd" });
92
108
  }
93
109
  flushSegment(blocks.length === 0);
94
110
  return blocks;
95
111
  }
112
+ function splitInfoString(infoString) {
113
+ const firstWhitespace = infoString.search(/\s/);
114
+ if (firstWhitespace === -1) return infoString.startsWith("{") ? {
115
+ language: void 0,
116
+ remainder: infoString
117
+ } : {
118
+ language: infoString,
119
+ remainder: void 0
120
+ };
121
+ const firstWord = infoString.slice(0, firstWhitespace);
122
+ const remainder = infoString.slice(firstWhitespace).trim();
123
+ if (firstWord.startsWith("{")) return {
124
+ language: void 0,
125
+ remainder: infoString.trim()
126
+ };
127
+ return {
128
+ language: firstWord,
129
+ remainder: remainder.length > 0 ? remainder : void 0
130
+ };
131
+ }
96
132
  function lowerCodeBlock(node, context) {
97
- if (node.fenced && node.infoString !== void 0 && node.infoString.length > 0) context.sink({
98
- code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.CODE_BLOCK_INFO_STRING_DROPPED,
99
- severity: "info",
100
- message: `fenced code block's own info string "${node.infoString}" has no ContentParagraph equivalent and was dropped`
101
- });
133
+ const info = node.fenced && node.infoString !== void 0 && node.infoString.length > 0 ? splitInfoString(node.infoString) : {
134
+ language: void 0,
135
+ remainder: void 0
136
+ };
102
137
  return [decorateParagraph({
103
138
  kind: "paragraph",
104
139
  runs: [require_lower_inline.lowerCodeBlockRun(node.literal.replace(/\n$/, ""))],
105
- styleId: require_shared_style_constants.CODE_BLOCK_STYLE_ID
140
+ styleId: require_shared_style_constants.CODE_BLOCK_STYLE_ID,
141
+ preformatted: true,
142
+ ...info.language !== void 0 ? { codeLanguage: info.language } : {},
143
+ ...info.remainder !== void 0 ? { source: {
144
+ format: "markdown",
145
+ xml: info.remainder
146
+ } } : {}
106
147
  }, context)];
107
148
  }
108
149
  function lowerThematicBreak(context) {
@@ -112,7 +153,16 @@ function lowerThematicBreak(context) {
112
153
  styleId: require_shared_style_constants.HORIZONTAL_RULE_STYLE_ID
113
154
  }, context)];
114
155
  }
115
- function lowerHtmlBlock(node, context) {
156
+ function lowerHtmlBlock(node, context, contentWidthPt) {
157
+ const table = context.gfmTables ? require_html_html_table.parseHtmlTable(node.literal, contentWidthPt) : void 0;
158
+ if (table !== void 0) {
159
+ if (context.list !== void 0) context.sink({
160
+ code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.LIST_ITEM_BLOCK_UNLISTED,
161
+ severity: "info",
162
+ message: "an HTML-table block directly inside a list item has no ContentListMembership field of its own -- only ContentParagraph carries .list -- so its association with the enclosing list item is lost"
163
+ });
164
+ return [table];
165
+ }
116
166
  if (context.rawHtmlMode === "drop") {
117
167
  context.sink({
118
168
  code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.RAW_HTML_DROPPED,
@@ -124,71 +174,76 @@ function lowerHtmlBlock(node, context) {
124
174
  context.sink({
125
175
  code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.RAW_HTML_PRESERVED_AS_TEXT,
126
176
  severity: "info",
127
- message: "block-level raw HTML was preserved as literal text (styleId \"HTMLPreformatted\"); it will not be rendered as HTML by any consumer of the resulting ContentDocument"
177
+ message: "block-level raw HTML was preserved as literal text (styleId \"HTMLPreformatted\"); it will not be rendered as HTML by any consumer of the resulting ContentDocument, and its verbatim original rides the paragraph's own markdown residue for this package's writer to re-emit as-is"
128
178
  });
129
179
  const literal = node.literal.replace(/\n+$/, "");
130
180
  return [decorateParagraph({
131
181
  kind: "paragraph",
132
182
  runs: literal.length === 0 ? [] : [{ text: literal }],
133
- styleId: require_shared_style_constants.HTML_PREFORMATTED_STYLE_ID
183
+ styleId: require_shared_style_constants.HTML_PREFORMATTED_STYLE_ID,
184
+ source: {
185
+ format: "markdown",
186
+ xml: node.literal
187
+ }
134
188
  }, context)];
135
189
  }
136
190
  function lowerMathBlock(node, context) {
137
- context.sink({
138
- code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.MATH_BLOCK_PRESERVED_AS_TEXT,
191
+ if (context.list !== void 0) context.sink({
192
+ code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.LIST_ITEM_BLOCK_UNLISTED,
139
193
  severity: "info",
140
- message: "block math ($$...$$) was preserved as literal raw LaTeX text (styleId \"MathBlock\"); it is not parsed as LaTeX or converted to MathML by this package"
194
+ message: "a display-math block directly inside a list item has no ContentListMembership field of its own -- only ContentParagraph carries .list -- so its association with the enclosing list item is lost"
141
195
  });
142
- const literal = node.literal.replace(/\n$/, "");
143
- return [decorateParagraph({
144
- kind: "paragraph",
145
- runs: literal.length === 0 ? [] : [{ text: literal }],
146
- styleId: require_shared_style_constants.MATH_BLOCK_STYLE_ID
147
- }, context)];
196
+ return [{
197
+ kind: "embeddedObject",
198
+ objectKind: "formula",
199
+ document: {
200
+ kind: "formula",
201
+ metadata: {},
202
+ formula: {
203
+ mathml: [],
204
+ presentation: { latex: node.literal.replace(/\n$/, "") }
205
+ }
206
+ },
207
+ frame: {
208
+ xPt: 0,
209
+ yPt: 0,
210
+ widthPt: 0,
211
+ heightPt: 0
212
+ }
213
+ }];
148
214
  }
149
215
  function lowerBlockquote(node, context, contentWidthPt) {
150
- if (context.quoteDepth >= 1) context.sink({
151
- code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.BLOCKQUOTE_NESTED_DEPTH,
152
- severity: "info",
153
- message: `blockquote nesting beyond level 1 is represented only as a larger indentLeftPt (${String((context.quoteDepth + 1) * 36)}pt); recovering the exact nesting depth back out is an approximation, not an exact inverse`
154
- });
155
216
  const nested = {
156
217
  ...context,
157
218
  quoteDepth: context.quoteDepth + 1
158
219
  };
159
220
  const blocks = node.children.flatMap((child) => lowerBlock(child, nested, contentWidthPt));
160
- if (blocks.length === 0) return [decorateParagraph({
161
- kind: "paragraph",
162
- runs: []
163
- }, nested)];
164
- return blocks;
165
- }
166
- function applyTaskCheckbox(blocks, checked) {
167
- const first = blocks[0];
168
- if (first?.kind !== "paragraph") return false;
169
- const checkboxRun = { text: `${checked ? "☒" : "☐"} ` };
170
- blocks[0] = {
171
- ...first,
172
- runs: [checkboxRun, ...first.runs]
173
- };
174
- return true;
221
+ return [
222
+ {
223
+ kind: "constructStart",
224
+ descriptor: { kind: "division" }
225
+ },
226
+ ...blocks.length === 0 ? [decorateParagraph({
227
+ kind: "paragraph",
228
+ runs: []
229
+ }, nested)] : blocks,
230
+ { kind: "constructEnd" }
231
+ ];
175
232
  }
176
233
  function lowerListItem(item, numId, level, context, contentWidthPt) {
177
- if (item.children.filter((child) => child.type !== "list").length > 1) context.sink({
178
- code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.LIST_ITEM_MULTI_BLOCK_FLATTENED,
179
- severity: "info",
180
- message: "a list item directly containing more than one block loses its own item boundary once lowered -- ContentListMembership carries only numId/level, with no field distinguishing \"one item, several blocks\" from \"several items sharing this numId/level\""
181
- });
234
+ const membership = {
235
+ numId,
236
+ level,
237
+ ...item.checked !== void 0 ? { checked: item.checked } : {},
238
+ itemId: require_shared_list_id.mintListItemId(context.numIdState)
239
+ };
182
240
  const itemContext = {
183
241
  ...context,
184
- list: {
185
- numId,
186
- level
187
- }
242
+ list: membership
188
243
  };
189
244
  const blocks = [];
190
- let checkboxApplied = item.checked === void 0;
191
245
  let ownLevelBlockCount = 0;
246
+ let firstOwnBlock;
192
247
  for (const child of item.children) {
193
248
  if (child.type === "list") {
194
249
  blocks.push(...lowerList(child, numId, level + 1, context, contentWidthPt));
@@ -196,17 +251,13 @@ function lowerListItem(item, numId, level, context, contentWidthPt) {
196
251
  }
197
252
  const childBlocks = lowerBlock(child, itemContext, contentWidthPt);
198
253
  ownLevelBlockCount += childBlocks.length;
199
- if (!checkboxApplied) checkboxApplied = applyTaskCheckbox(childBlocks, item.checked === true);
254
+ firstOwnBlock ??= childBlocks[0];
200
255
  blocks.push(...childBlocks);
201
256
  }
202
- if (ownLevelBlockCount === 0) {
203
- const placeholder = [decorateParagraph({
204
- kind: "paragraph",
205
- runs: []
206
- }, itemContext)];
207
- if (!checkboxApplied) applyTaskCheckbox(placeholder, item.checked === true);
208
- blocks.unshift(...placeholder);
209
- }
257
+ if (ownLevelBlockCount === 0 || firstOwnBlock?.kind === "constructStart") blocks.unshift(decorateParagraph({
258
+ kind: "paragraph",
259
+ runs: []
260
+ }, itemContext));
210
261
  return blocks;
211
262
  }
212
263
  function lowerList(node, ancestorNumId, level, context, contentWidthPt) {
@@ -217,7 +268,8 @@ function lowerList(node, ancestorNumId, level, context, contentWidthPt) {
217
268
  type: node.markerType,
218
269
  start: node.start,
219
270
  task,
220
- loose: !node.tight
271
+ loose: !node.tight,
272
+ ownerItemId: context.list?.itemId
221
273
  });
222
274
  } else {
223
275
  numId = ancestorNumId;
@@ -230,46 +282,13 @@ function lowerList(node, ancestorNumId, level, context, contentWidthPt) {
230
282
  }
231
283
  return node.children.flatMap((item) => lowerListItem(item, numId, level, context, contentWidthPt));
232
284
  }
233
- function flattenFootnoteBodyHeadings(node, context) {
234
- switch (node.type) {
235
- case "heading":
236
- context.sink({
237
- code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.FOOTNOTE_BODY_HEADING_FLATTENED,
238
- severity: "info",
239
- message: `a level-${String(node.level)} heading inside a footnote definition's body is carried as literal ATX text: a construct boundary marker's extent may not contain a block that opens or closes a heading scope, so the heading cannot stay a heading inside the anchor construct the definition lowers to`
240
- });
241
- return {
242
- type: "paragraph",
243
- children: [{
244
- type: "text",
245
- value: `${"#".repeat(node.level)} `
246
- }, ...node.children]
247
- };
248
- case "blockquote": return {
249
- type: "blockquote",
250
- children: node.children.map((child) => flattenFootnoteBodyHeadings(child, context))
251
- };
252
- case "list": return {
253
- ...node,
254
- children: node.children.map((item) => flattenFootnoteBodyHeadingsInItem(item, context))
255
- };
256
- case "listItem": return flattenFootnoteBodyHeadingsInItem(node, context);
257
- default: return node;
258
- }
259
- }
260
- function flattenFootnoteBodyHeadingsInItem(item, context) {
261
- return {
262
- ...item,
263
- children: item.children.map((child) => flattenFootnoteBodyHeadings(child, context))
264
- };
265
- }
266
285
  function lowerFootnoteDefinition(node, context, contentWidthPt) {
267
286
  const descriptor = {
268
287
  kind: "anchor",
269
288
  anchorType: "footnote",
270
289
  name: node.label
271
290
  };
272
- const body = node.children.flatMap((child) => lowerBlock(flattenFootnoteBodyHeadings(child, context), context, contentWidthPt));
291
+ const body = node.children.flatMap((child) => lowerBlock(child, context, contentWidthPt));
273
292
  return [
274
293
  {
275
294
  kind: "constructStart",
@@ -287,7 +306,7 @@ function lowerBlock(node, context, contentWidthPt) {
287
306
  case "list": return lowerList(node, void 0, 0, context, contentWidthPt);
288
307
  case "codeBlock": return lowerCodeBlock(node, context);
289
308
  case "thematicBreak": return lowerThematicBreak(context);
290
- case "htmlBlock": return lowerHtmlBlock(node, context);
309
+ case "htmlBlock": return lowerHtmlBlock(node, context, contentWidthPt);
291
310
  case "mathBlock": return lowerMathBlock(node, context);
292
311
  case "footnoteDefinition": return lowerFootnoteDefinition(node, context, contentWidthPt);
293
312
  case "table":
@@ -319,7 +338,8 @@ function lowerParsedMarkdown(parsed, options = {}, metadata = {}) {
319
338
  rawHtmlMode: options.rawHtml ?? "preserve",
320
339
  numIdState: require_shared_list_id.createNumIdMintState(),
321
340
  quoteDepth: 0,
322
- list: void 0
341
+ list: void 0,
342
+ gfmTables: options.gfmTables ?? true
323
343
  };
324
344
  return {
325
345
  kind: "wordprocessing",
@@ -331,15 +351,16 @@ function lowerParsedMarkdown(parsed, options = {}, metadata = {}) {
331
351
  }]
332
352
  };
333
353
  }
334
- function lowerMarkdown(source, options = {}) {
354
+ function lowerMarkdownDetailed(source, options = {}) {
335
355
  if (options.maxInputBytes !== void 0) {
336
356
  const actualBytes = new TextEncoder().encode(source).length;
337
357
  if (actualBytes > options.maxInputBytes) throw new require_diagnostics_diagnostics.MarkdownInputTooLargeError(options.maxInputBytes, actualBytes);
338
358
  }
339
359
  const sink = options.sink ?? require_diagnostics_diagnostics.NOOP_MARKDOWN_DIAGNOSTIC_SINK;
340
- const { metadata, rest } = options.frontMatter ?? false ? require_lower_front_matter.extractFrontMatter(source, sink) : {
360
+ const extracted = options.frontMatter ?? false ? require_lower_front_matter.extractFrontMatter(source, sink) : {
341
361
  metadata: {},
342
- rest: source
362
+ rest: source,
363
+ source: void 0
343
364
  };
344
365
  const parseOptions = {
345
366
  gfmTables: options.gfmTables,
@@ -350,8 +371,17 @@ function lowerMarkdown(source, options = {}) {
350
371
  maxNesting: options.maxBlockNesting,
351
372
  sink
352
373
  };
353
- return lowerParsedMarkdown(require_block_block.parseMarkdown(rest, parseOptions), options, metadata);
374
+ const parsed = require_block_block.parseMarkdown(extracted.rest, parseOptions);
375
+ return {
376
+ document: lowerParsedMarkdown(parsed, options, extracted.metadata),
377
+ references: parsed.references,
378
+ frontMatterSource: extracted.source
379
+ };
380
+ }
381
+ function lowerMarkdown(source, options = {}) {
382
+ return lowerMarkdownDetailed(source, options).document;
354
383
  }
355
384
  //#endregion
356
385
  exports.lowerMarkdown = lowerMarkdown;
386
+ exports.lowerMarkdownDetailed = lowerMarkdownDetailed;
357
387
  exports.lowerParsedMarkdown = lowerParsedMarkdown;
@@ -1,8 +1,15 @@
1
+ import { LinkReferenceMap } from "../inline/link.cjs";
1
2
  import { ParsedMarkdown } from "../block/block.cjs";
2
3
  import { ReadMarkdownOptions } from "../options/options.cjs";
3
4
  import { ContentDocument, LayoutMetadata } from "document-schema.js";
4
5
  //#region src/lower/lower.d.ts
5
6
  declare function lowerParsedMarkdown(parsed: ParsedMarkdown, options?: ReadMarkdownOptions, metadata?: LayoutMetadata): ContentDocument;
7
+ interface LoweredMarkdownDetail {
8
+ readonly document: ContentDocument;
9
+ readonly references: LinkReferenceMap;
10
+ readonly frontMatterSource: string | undefined;
11
+ }
12
+ declare function lowerMarkdownDetailed(source: string, options?: ReadMarkdownOptions): LoweredMarkdownDetail;
6
13
  declare function lowerMarkdown(source: string, options?: ReadMarkdownOptions): ContentDocument;
7
14
  //#endregion
8
- export { lowerMarkdown, lowerParsedMarkdown };
15
+ export { LoweredMarkdownDetail, lowerMarkdown, lowerMarkdownDetailed, lowerParsedMarkdown };
@@ -1,8 +1,15 @@
1
+ import { LinkReferenceMap } from "../inline/link.js";
1
2
  import { ParsedMarkdown } from "../block/block.js";
2
3
  import { ReadMarkdownOptions } from "../options/options.js";
3
4
  import { ContentDocument, LayoutMetadata } from "document-schema.js";
4
5
  //#region src/lower/lower.d.ts
5
6
  declare function lowerParsedMarkdown(parsed: ParsedMarkdown, options?: ReadMarkdownOptions, metadata?: LayoutMetadata): ContentDocument;
7
+ interface LoweredMarkdownDetail {
8
+ readonly document: ContentDocument;
9
+ readonly references: LinkReferenceMap;
10
+ readonly frontMatterSource: string | undefined;
11
+ }
12
+ declare function lowerMarkdownDetailed(source: string, options?: ReadMarkdownOptions): LoweredMarkdownDetail;
6
13
  declare function lowerMarkdown(source: string, options?: ReadMarkdownOptions): ContentDocument;
7
14
  //#endregion
8
- export { lowerMarkdown, lowerParsedMarkdown };
15
+ export { LoweredMarkdownDetail, lowerMarkdown, lowerMarkdownDetailed, lowerParsedMarkdown };