chattercatcher 0.2.1 → 0.2.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.
- package/dist/cli.js +17 -21
- package/dist/cli.js.map +1 -1
- package/dist/index.js +16 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4318,8 +4318,8 @@ function findMarkdownLinkEnd(text, start) {
|
|
|
4318
4318
|
}
|
|
4319
4319
|
return -1;
|
|
4320
4320
|
}
|
|
4321
|
-
function
|
|
4322
|
-
|
|
4321
|
+
function stripInlineMarkdown(text) {
|
|
4322
|
+
let output = "";
|
|
4323
4323
|
let index = 0;
|
|
4324
4324
|
while (index < text.length) {
|
|
4325
4325
|
const linkStart = text.indexOf("[", index);
|
|
@@ -4328,12 +4328,10 @@ function parseInline(text) {
|
|
|
4328
4328
|
const candidates = [linkStart, boldStarStart, boldUnderscoreStart].filter((value) => value >= 0);
|
|
4329
4329
|
const next = candidates.length ? Math.min(...candidates) : -1;
|
|
4330
4330
|
if (next < 0) {
|
|
4331
|
-
|
|
4331
|
+
output += text.slice(index);
|
|
4332
4332
|
break;
|
|
4333
4333
|
}
|
|
4334
|
-
|
|
4335
|
-
elements.push({ tag: "text", text: text.slice(index, next) });
|
|
4336
|
-
}
|
|
4334
|
+
output += text.slice(index, next);
|
|
4337
4335
|
if (next === linkStart) {
|
|
4338
4336
|
const labelEnd = text.indexOf("](", next);
|
|
4339
4337
|
if (labelEnd > next) {
|
|
@@ -4341,27 +4339,29 @@ function parseInline(text) {
|
|
|
4341
4339
|
const hrefEnd = findMarkdownLinkEnd(text, hrefStart);
|
|
4342
4340
|
const href = hrefEnd >= 0 ? text.slice(hrefStart, hrefEnd) : "";
|
|
4343
4341
|
if (hrefEnd >= 0 && /^https?:\/\/\S+$/.test(href)) {
|
|
4344
|
-
|
|
4342
|
+
output += `${text.slice(next + 1, labelEnd)} ${href}`;
|
|
4345
4343
|
index = hrefEnd + 1;
|
|
4346
4344
|
continue;
|
|
4347
4345
|
}
|
|
4348
4346
|
}
|
|
4349
|
-
|
|
4347
|
+
output += text[next];
|
|
4350
4348
|
index = next + 1;
|
|
4351
4349
|
continue;
|
|
4352
4350
|
}
|
|
4353
4351
|
const marker = next === boldStarStart ? "**" : "__";
|
|
4354
4352
|
const close = text.indexOf(marker, next + marker.length);
|
|
4355
4353
|
if (close > next + marker.length) {
|
|
4356
|
-
|
|
4354
|
+
output += text.slice(next + marker.length, close);
|
|
4357
4355
|
index = close + marker.length;
|
|
4358
4356
|
continue;
|
|
4359
4357
|
}
|
|
4360
|
-
|
|
4358
|
+
output += marker;
|
|
4361
4359
|
index = next + marker.length;
|
|
4362
4360
|
}
|
|
4363
|
-
|
|
4364
|
-
|
|
4361
|
+
return output;
|
|
4362
|
+
}
|
|
4363
|
+
function parseInline(text) {
|
|
4364
|
+
return [{ tag: "text", text: stripInlineMarkdown(text) || " " }];
|
|
4365
4365
|
}
|
|
4366
4366
|
function pushParagraph(content, lines) {
|
|
4367
4367
|
if (lines.length === 0) return;
|
|
@@ -4402,7 +4402,7 @@ ${code.join("\n")}
|
|
|
4402
4402
|
const heading = line.match(/^#{1,6}\s+(.+)$/);
|
|
4403
4403
|
if (heading) {
|
|
4404
4404
|
pushParagraph(content, paragraph);
|
|
4405
|
-
content.push([{ tag: "text", text: heading[1]
|
|
4405
|
+
content.push([{ tag: "text", text: stripInlineMarkdown(heading[1]) || " " }]);
|
|
4406
4406
|
continue;
|
|
4407
4407
|
}
|
|
4408
4408
|
const unordered = line.match(/^[-*]\s+(.+)$/);
|
|
@@ -4430,17 +4430,13 @@ function buildFeishuPostContent(markdown, options) {
|
|
|
4430
4430
|
const content = parseMarkdownBlocks(markdown);
|
|
4431
4431
|
const mentions = options?.mentions ?? [];
|
|
4432
4432
|
if (mentions.length) {
|
|
4433
|
-
const mentionElements = mentions.map((mention) => ({
|
|
4434
|
-
tag: "at",
|
|
4435
|
-
user_id: mention.openId,
|
|
4436
|
-
user_name: mention.name
|
|
4437
|
-
}));
|
|
4438
4433
|
const firstLine = content[0] ?? [];
|
|
4439
4434
|
const firstText = firstLine[0];
|
|
4435
|
+
const prefix = mentions.map((mention) => `@${mention.name}`).join(" ");
|
|
4440
4436
|
if (firstText?.tag === "text") {
|
|
4441
|
-
content[0] = [
|
|
4437
|
+
content[0] = [{ tag: "text", text: `${prefix} ${firstText.text}` }, ...firstLine.slice(1)];
|
|
4442
4438
|
} else {
|
|
4443
|
-
content[0] = [
|
|
4439
|
+
content[0] = [{ tag: "text", text: `${prefix} ` }, ...firstLine];
|
|
4444
4440
|
}
|
|
4445
4441
|
}
|
|
4446
4442
|
return {
|