@jacobbubu/md-to-lark 1.4.10 → 1.4.11

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.
@@ -223,6 +223,36 @@ function mergeAdjacentTextRuns(inlines) {
223
223
  }
224
224
  return merged;
225
225
  }
226
+ function trimBoundaryNewlinesFromInlines(inlines) {
227
+ const trimmed = inlines.map((inline) => ({ ...inline }));
228
+ let start = 0;
229
+ let end = trimmed.length;
230
+ while (start < end) {
231
+ const inline = trimmed[start];
232
+ if (!inline || inline.kind !== 'text_run')
233
+ break;
234
+ const nextText = (inline.text ?? '').replace(/^(?:\r?\n)+/, '');
235
+ if (nextText.length === 0) {
236
+ start += 1;
237
+ continue;
238
+ }
239
+ inline.text = nextText;
240
+ break;
241
+ }
242
+ while (end > start) {
243
+ const inline = trimmed[end - 1];
244
+ if (!inline || inline.kind !== 'text_run')
245
+ break;
246
+ const nextText = (inline.text ?? '').replace(/(?:\r?\n)+$/, '');
247
+ if (nextText.length === 0) {
248
+ end -= 1;
249
+ continue;
250
+ }
251
+ inline.text = nextText;
252
+ break;
253
+ }
254
+ return mergeAdjacentTextRuns(trimmed.slice(start, end));
255
+ }
226
256
  function hasClassName(element, expected) {
227
257
  return getClassNames(element).includes(expected);
228
258
  }
@@ -674,17 +704,7 @@ function convertTable(ctx, table, parentId) {
674
704
  return [tableId];
675
705
  }
676
706
  function convertBlockquote(ctx, blockquote, parentId) {
677
- const quoteText = trimBoundaryNewlines(toString(blockquote));
678
- const inlines = quoteText.length
679
- ? [
680
- {
681
- id: nextInlineId(ctx),
682
- kind: 'text_run',
683
- marks: createDefaultMarks(),
684
- text: quoteText,
685
- },
686
- ]
687
- : [];
707
+ const inlines = trimBoundaryNewlinesFromInlines(parseInlineNodes(ctx, getChildren(blockquote)));
688
708
  return [createTextualBlock(ctx, 'quote', parentId, inlines)];
689
709
  }
690
710
  function trimBoundaryNewlines(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jacobbubu/md-to-lark",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "description": "Publish Markdown to Feishu docs with a stable pipeline.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",