@sillsdev/docu-notion 0.14.0-alpha.16 → 0.14.0-alpha.17

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.
@@ -554,7 +554,78 @@ test("internal link inside codeblock ignored", () => __awaiter(void 0, void 0, v
554
554
  }, targetPage);
555
555
  expect(results.trim()).toContain("this should not change [link](https://www.notion.so/native/metapages/mypage)");
556
556
  }));
557
- function getMarkdown(block, targetPage) {
557
+ test("multiple internal links in a paragraph", () => __awaiter(void 0, void 0, void 0, function* () {
558
+ const targetPageAId = "123";
559
+ const targetPageA = (0, pluginTestRun_1.makeSamplePageObject)({
560
+ slug: undefined,
561
+ name: "Hello World A",
562
+ id: targetPageAId,
563
+ });
564
+ const targetPageBId = "456";
565
+ const targetPageB = (0, pluginTestRun_1.makeSamplePageObject)({
566
+ slug: undefined,
567
+ name: "Hello World B",
568
+ id: targetPageBId,
569
+ });
570
+ const results = yield getMarkdown({
571
+ type: "paragraph",
572
+ paragraph: {
573
+ rich_text: [
574
+ {
575
+ type: "text",
576
+ text: {
577
+ content: "A",
578
+ link: { url: `/${targetPageAId}` },
579
+ },
580
+ annotations: {
581
+ bold: false,
582
+ italic: false,
583
+ strikethrough: false,
584
+ underline: false,
585
+ code: false,
586
+ color: "default",
587
+ },
588
+ plain_text: "A",
589
+ href: `/${targetPageAId}`,
590
+ },
591
+ {
592
+ type: "text",
593
+ text: { content: " ", link: null },
594
+ annotations: {
595
+ bold: false,
596
+ italic: false,
597
+ strikethrough: false,
598
+ underline: false,
599
+ code: false,
600
+ color: "default",
601
+ },
602
+ plain_text: " ",
603
+ href: null,
604
+ },
605
+ {
606
+ type: "text",
607
+ text: {
608
+ content: "B",
609
+ link: { url: `/${targetPageBId}` },
610
+ },
611
+ annotations: {
612
+ bold: false,
613
+ italic: false,
614
+ strikethrough: false,
615
+ underline: false,
616
+ code: false,
617
+ color: "default",
618
+ },
619
+ plain_text: "B",
620
+ href: `/${targetPageBId}`,
621
+ },
622
+ ],
623
+ color: "default",
624
+ },
625
+ }, targetPageA, targetPageB);
626
+ expect(results.trim()).toBe(`[A](/${targetPageAId}) [B](/${targetPageBId})`);
627
+ }));
628
+ function getMarkdown(block, targetPage, targetPage2) {
558
629
  return __awaiter(this, void 0, void 0, function* () {
559
630
  const config = {
560
631
  plugins: [
@@ -563,6 +634,6 @@ function getMarkdown(block, targetPage) {
563
634
  externalLinks_1.standardExternalLinkConversion,
564
635
  ],
565
636
  };
566
- return yield (0, pluginTestRun_1.oneBlockToMarkdown)(config, block, targetPage);
637
+ return yield (0, pluginTestRun_1.oneBlockToMarkdown)(config, block, targetPage, targetPage2);
567
638
  });
568
639
  }
@@ -7,4 +7,4 @@ export declare function makeSamplePageObject(options: {
7
7
  name?: string;
8
8
  id?: string;
9
9
  }): NotionPage;
10
- export declare function oneBlockToMarkdown(config: IDocuNotionConfig, block: Record<string, unknown>, targetPage?: NotionPage): Promise<string>;
10
+ export declare function oneBlockToMarkdown(config: IDocuNotionConfig, block: Record<string, unknown>, targetPage?: NotionPage, targetPage2?: NotionPage): Promise<string>;
@@ -226,7 +226,7 @@ function makeSamplePageObject(options) {
226
226
  return p;
227
227
  }
228
228
  exports.makeSamplePageObject = makeSamplePageObject;
229
- function oneBlockToMarkdown(config, block, targetPage) {
229
+ function oneBlockToMarkdown(config, block, targetPage, targetPage2) {
230
230
  return __awaiter(this, void 0, void 0, function* () {
231
231
  // just in case someone expects these other properties that aren't normally relevant,
232
232
  // we merge the given block properties into an actual, full block
@@ -258,7 +258,7 @@ function oneBlockToMarkdown(config, block, targetPage) {
258
258
  slug: "dummy2",
259
259
  name: "Dummy2",
260
260
  });
261
- return yield blocksToMarkdown(config, [fullBlock], targetPage ? [dummyPage1, targetPage, dummyPage2] : undefined);
261
+ return yield blocksToMarkdown(config, [fullBlock], targetPage ? [dummyPage1, targetPage, targetPage2 !== null && targetPage2 !== void 0 ? targetPage2 : dummyPage2] : undefined);
262
262
  });
263
263
  }
264
264
  exports.oneBlockToMarkdown = oneBlockToMarkdown;
package/dist/transform.js CHANGED
@@ -149,7 +149,7 @@ function doNotionToMarkdown(docunotionContext, blocks) {
149
149
  // Raw links come in without a leading slash, e.g. [link_to_page](4a6de8c0-b90b-444b-8a7b-d534d6ec71a4)
150
150
  // Inline links come in with a leading slash, e.g. [pointer to the introduction](/4a6de8c0b90b444b8a7bd534d6ec71a4)
151
151
  function doLinkFixes(context, markdown, config) {
152
- const linkRegExp = /\[.*\]\([^\)]*\)/g;
152
+ const linkRegExp = /\[.*?\]\([^\)]*?\)/g;
153
153
  (0, log_1.logDebug)("markdown before link fixes", markdown);
154
154
  let match;
155
155
  // since we're going to make changes to the markdown,
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  "volta": {
92
92
  "node": "18.16.0"
93
93
  },
94
- "version": "0.14.0-alpha.16"
94
+ "version": "0.14.0-alpha.17"
95
95
  }