@promptbook/markdown-utils 0.105.0-31 → 0.105.0-32

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/esm/index.es.js CHANGED
@@ -23,7 +23,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.105.0-31';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.105.0-32';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -72,7 +72,7 @@ function capitalize(word) {
72
72
  */
73
73
  function extractAllBlocksFromMarkdown(markdown) {
74
74
  const codeBlocks = [];
75
- const lines = markdown.split('\n');
75
+ const lines = markdown.split(/\r?\n/);
76
76
  // Note: [0] Ensure that the last block notated by gt > will be closed
77
77
  lines.push('');
78
78
  let currentCodeBlock = null;
@@ -1495,7 +1495,7 @@ function isValidEmail(email) {
1495
1495
  if (typeof email !== 'string') {
1496
1496
  return false;
1497
1497
  }
1498
- if (email.split('\n').length > 1) {
1498
+ if (email.split(/\r?\n/).length > 1) {
1499
1499
  return false;
1500
1500
  }
1501
1501
  return /^.+@.+\..+$/.test(email);
@@ -1511,7 +1511,7 @@ function isValidFilePath(filename) {
1511
1511
  if (typeof filename !== 'string') {
1512
1512
  return false;
1513
1513
  }
1514
- if (filename.split('\n').length > 1) {
1514
+ if (filename.split(/\r?\n/).length > 1) {
1515
1515
  return false;
1516
1516
  }
1517
1517
  // Normalize slashes early so heuristics can detect path-like inputs
@@ -4883,7 +4883,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
4883
4883
 
4884
4884
  The source:
4885
4885
  ${block(knowledgeSource.knowledgeSourceContent
4886
- .split('\n')
4886
+ .split(/\r?\n/)
4887
4887
  .map((line) => `> ${line}`)
4888
4888
  .join('\n'))}
4889
4889
 
@@ -4899,7 +4899,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
4899
4899
 
4900
4900
  The source:
4901
4901
  > ${block(knowledgeSource.knowledgeSourceContent
4902
- .split('\n')
4902
+ .split(/\r?\n/)
4903
4903
  .map((line) => `> ${line}`)
4904
4904
  .join('\n'))}
4905
4905
 
@@ -5600,7 +5600,7 @@ const TextFormatParser = {
5600
5600
  subvalueName: 'LINE',
5601
5601
  async mapValues(options) {
5602
5602
  const { value, mapCallback, onProgress } = options;
5603
- const lines = value.split('\n');
5603
+ const lines = value.split(/\r?\n/);
5604
5604
  const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
5605
5605
  // TODO: [🧠] Maybe option to skip empty line
5606
5606
  /* not await */ mapCallback({
@@ -5805,7 +5805,7 @@ function templateParameters(template, parameters) {
5805
5805
  parameterValue = parameterValue.replace(/[{}]/g, '\\$&');
5806
5806
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
5807
5807
  parameterValue = parameterValue
5808
- .split('\n')
5808
+ .split(/\r?\n/)
5809
5809
  .map((line, index) => (index === 0 ? line : `${precol}${line}`))
5810
5810
  .join('\n');
5811
5811
  }
@@ -5874,7 +5874,7 @@ function countLines(text) {
5874
5874
  }
5875
5875
  text = text.replace('\r\n', '\n');
5876
5876
  text = text.replace('\r', '\n');
5877
- const lines = text.split('\n');
5877
+ const lines = text.split(/\r?\n/);
5878
5878
  return lines.reduce((count, line) => count + Math.max(Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 1), 0);
5879
5879
  }
5880
5880
  /**
@@ -6349,13 +6349,13 @@ async function executeAttempts(options) {
6349
6349
  return `
6350
6350
  Attempt ${failure.attemptIndex + 1}:
6351
6351
  Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
6352
- ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
6352
+ ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split(/\r?\n/).map((line) => `> ${line}`).join('\n'))}
6353
6353
 
6354
6354
  Result:
6355
6355
  ${block(failure.result === null
6356
6356
  ? 'null'
6357
6357
  : spaceTrim$2(failure.result)
6358
- .split('\n')
6358
+ .split(/\r?\n/)
6359
6359
  .map((line) => `> ${line}`)
6360
6360
  .join('\n'))}
6361
6361
  `;
@@ -6370,7 +6370,7 @@ async function executeAttempts(options) {
6370
6370
 
6371
6371
  The Prompt:
6372
6372
  ${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
6373
- .split('\n')
6373
+ .split(/\r?\n/)
6374
6374
  .map((line) => `> ${line}`)
6375
6375
  .join('\n'))}
6376
6376
 
@@ -7041,7 +7041,7 @@ async function executePipeline(options) {
7041
7041
  ${block(pipelineIdentification)}
7042
7042
 
7043
7043
  ${block(JSON.stringify(newOngoingResult, null, 4)
7044
- .split('\n')
7044
+ .split(/\r?\n/)
7045
7045
  .map((line) => `> ${line}`)
7046
7046
  .join('\n'))}
7047
7047
  `));
@@ -7621,7 +7621,7 @@ function escapeMarkdownBlock(value) {
7621
7621
  * @public exported from `@promptbook/markdown-utils`
7622
7622
  */
7623
7623
  function extractAllListItemsFromMarkdown(markdown) {
7624
- const lines = markdown.split('\n');
7624
+ const lines = markdown.split(/\r?\n/);
7625
7625
  const listItems = [];
7626
7626
  let isInCodeBlock = false;
7627
7627
  for (const line of lines) {
@@ -7644,7 +7644,7 @@ function extractAllListItemsFromMarkdown(markdown) {
7644
7644
  */
7645
7645
  function parseMarkdownSection(value) {
7646
7646
  var _a, _b;
7647
- const lines = value.split('\n');
7647
+ const lines = value.split(/\r?\n/);
7648
7648
  if (!lines[0].startsWith('#')) {
7649
7649
  throw new ParseError('Markdown section must start with heading');
7650
7650
  }
@@ -7669,7 +7669,7 @@ function parseMarkdownSection(value) {
7669
7669
  * @public exported from `@promptbook/markdown-utils`
7670
7670
  */
7671
7671
  function splitMarkdownIntoSections(markdown) {
7672
- const lines = markdown.split('\n');
7672
+ const lines = markdown.split(/\r?\n/);
7673
7673
  const sections = [];
7674
7674
  // TODO: [🧽] DRY
7675
7675
  let currentType = 'MARKDOWN';