@gendive/chatllm 0.17.13 → 0.17.15

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.
@@ -1412,6 +1412,7 @@ var useProject = (options) => {
1412
1412
  var generateId2 = () => {
1413
1413
  return Math.random().toString(36).substring(2, 11);
1414
1414
  };
1415
+ var stripInlineMarkdown = (text) => text.replace(/\*\*(.+?)\*\*/g, "$1").replace(/__(.+?)__/g, "$1").replace(/\*(.+?)\*/g, "$1").replace(/_(.+?)_/g, "$1").replace(/`(.+?)`/g, "$1").replace(/~~(.+?)~~/g, "$1");
1415
1416
  var parsePollFromContent = (content) => {
1416
1417
  const pollRegex = /<poll([^>]*)>([\s\S]*?)<\/poll>/gi;
1417
1418
  const polls = [];
@@ -1446,12 +1447,12 @@ var parsePollFromContent = (content) => {
1446
1447
  let optionMatch;
1447
1448
  while ((optionMatch = optionTagRegex.exec(innerContent)) !== null) {
1448
1449
  const optionAttrs = optionMatch[1];
1449
- const optionLabel = optionMatch[2].trim();
1450
+ const optionLabel = stripInlineMarkdown(optionMatch[2].trim());
1450
1451
  const descMatch = optionAttrs.match(/description=["']([^"']+)["']/i);
1451
1452
  options.push({
1452
1453
  id: generateId2(),
1453
1454
  label: optionLabel,
1454
- description: descMatch?.[1]
1455
+ description: descMatch?.[1] ? stripInlineMarkdown(descMatch[1]) : void 0
1455
1456
  });
1456
1457
  }
1457
1458
  if (options.length === 0) {
@@ -1461,8 +1462,8 @@ var parsePollFromContent = (content) => {
1461
1462
  const fullText = listMatch[1].trim();
1462
1463
  const colonIndex = fullText.indexOf(":");
1463
1464
  if (colonIndex > 0) {
1464
- const label = fullText.substring(0, colonIndex).trim();
1465
- const description = fullText.substring(colonIndex + 1).trim();
1465
+ const label = stripInlineMarkdown(fullText.substring(0, colonIndex).trim());
1466
+ const description = stripInlineMarkdown(fullText.substring(colonIndex + 1).trim());
1466
1467
  options.push({
1467
1468
  id: generateId2(),
1468
1469
  label,
@@ -1471,7 +1472,7 @@ var parsePollFromContent = (content) => {
1471
1472
  } else {
1472
1473
  options.push({
1473
1474
  id: generateId2(),
1474
- label: fullText
1475
+ label: stripInlineMarkdown(fullText)
1475
1476
  });
1476
1477
  }
1477
1478
  }
@@ -1482,14 +1483,14 @@ var parsePollFromContent = (content) => {
1482
1483
  while ((numMatch = numberedRegex.exec(innerContent)) !== null) {
1483
1484
  options.push({
1484
1485
  id: generateId2(),
1485
- label: numMatch[1].trim()
1486
+ label: stripInlineMarkdown(numMatch[1].trim())
1486
1487
  });
1487
1488
  }
1488
1489
  }
1489
1490
  if (questionText && options.length >= 2) {
1490
1491
  const pollQuestion = {
1491
1492
  id: generateId2(),
1492
- question: questionText,
1493
+ question: stripInlineMarkdown(questionText),
1493
1494
  options,
1494
1495
  multiSelect,
1495
1496
  allowOther,
@@ -7104,6 +7105,37 @@ var DeepResearchProgressUI = ({ progress }) => {
7104
7105
  // src/react/components/PollCard.tsx
7105
7106
  var import_react13 = require("react");
7106
7107
  var import_jsx_runtime9 = require("react/jsx-runtime");
7108
+ var renderInlineMarkdown = (text) => {
7109
+ const parts = [];
7110
+ let remaining = text;
7111
+ let key = 0;
7112
+ while (remaining.length > 0) {
7113
+ const match = remaining.match(
7114
+ /(\*\*(.+?)\*\*|__(.+?)__|`(.+?)`|~~(.+?)~~|\*(.+?)\*|_(.+?)_)/
7115
+ );
7116
+ if (!match || match.index === void 0) {
7117
+ parts.push(remaining);
7118
+ break;
7119
+ }
7120
+ if (match.index > 0) {
7121
+ parts.push(remaining.slice(0, match.index));
7122
+ }
7123
+ const fullMatch = match[0];
7124
+ if (match[2] || match[3]) {
7125
+ parts.push(/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: match[2] || match[3] }, key++));
7126
+ } else if (match[4]) {
7127
+ parts.push(
7128
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { style: { backgroundColor: "var(--chatllm-bg-tertiary, #f1f5f9)", padding: "1px 4px", borderRadius: "3px", fontSize: "0.9em" }, children: match[4] }, key++)
7129
+ );
7130
+ } else if (match[5]) {
7131
+ parts.push(/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("s", { children: match[5] }, key++));
7132
+ } else if (match[6] || match[7]) {
7133
+ parts.push(/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("em", { children: match[6] || match[7] }, key++));
7134
+ }
7135
+ remaining = remaining.slice(match.index + fullMatch.length);
7136
+ }
7137
+ return parts.length === 1 && typeof parts[0] === "string" ? parts[0] : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: parts });
7138
+ };
7107
7139
  var stripMarkdown = (text) => text.replace(/\*\*(.+?)\*\*/g, "$1").replace(/__(.+?)__/g, "$1").replace(/\*(.+?)\*/g, "$1").replace(/_(.+?)_/g, "$1").replace(/`(.+?)`/g, "$1").replace(/~~(.+?)~~/g, "$1");
7108
7140
  var PollCard = ({
7109
7141
  questions,
@@ -7262,7 +7294,7 @@ var PollCard = ({
7262
7294
  fontWeight: 600,
7263
7295
  color: "var(--chatllm-text, #1e293b)"
7264
7296
  },
7265
- children: stripMarkdown(currentQuestion.question)
7297
+ children: renderInlineMarkdown(currentQuestion.question)
7266
7298
  }
7267
7299
  ),
7268
7300
  currentQuestion.multiSelect && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -7330,7 +7362,7 @@ var PollCard = ({
7330
7362
  color: "var(--chatllm-text, #1e293b)",
7331
7363
  lineHeight: "1.4"
7332
7364
  },
7333
- children: stripMarkdown(option.label)
7365
+ children: renderInlineMarkdown(option.label)
7334
7366
  }
7335
7367
  ),
7336
7368
  option.description && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -7342,7 +7374,7 @@ var PollCard = ({
7342
7374
  marginTop: "2px",
7343
7375
  lineHeight: "1.3"
7344
7376
  },
7345
- children: stripMarkdown(option.description)
7377
+ children: renderInlineMarkdown(option.description)
7346
7378
  }
7347
7379
  )
7348
7380
  ] })