ts-markdown-builder 0.3.0 → 0.4.0

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.
@@ -13,7 +13,7 @@ function heading(text, options) {
13
13
  return `${'#'.repeat(level)} ${text}`;
14
14
  }
15
15
  function blockquote(content) {
16
- return (0, _utils.prefixLines)(content, '> ');
16
+ return (0, _utils.prefixLines)((0, _utils.joinBlocks)(content), '> ');
17
17
  }
18
18
  function codeBlock(content) {
19
19
  return `\`\`\`\n${content}\n\`\`\``;
@@ -1 +1 @@
1
- {"version":3,"file":"block.js","names":["horizontalRule","exports","heading","text","options","level","repeat","blockquote","content","prefixLines","codeBlock","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { prefixLines } from './utils';\n\n/**\n * Create a horizontal rule block.\n *\n * Markdown: `---`\n */\nexport const horizontalRule = '---';\n\ntype HeadingOptions = {\n level: number;\n};\n\n/**\n * Create a heading block.\n * Markdown: `# Heading`\n *\n * @param text - The text of the heading.\n * @param level - The level of the heading (defaults to 1).\n */\nexport function heading(text: string, options?: HeadingOptions): string {\n const level = options?.level ?? 1;\n return `${'#'.repeat(level)} ${text}`;\n}\n\n/**\n * Create a blockquote block.\n *\n * Markdown:\n * ```\n * > Content\n * > Content\n * ```\n *\n * @param text - The content of the blockquote.\n */\nexport function blockquote(content: string): string {\n return prefixLines(content, '> ');\n}\n\n/**\n * Create a code block.\n *\n * Markdown:\n * ````\n * ```\n * Content\n * ```\n * ````\n *\n * @param content - The content of the code block.\n */\nexport function codeBlock(content: string): string {\n return `\\`\\`\\`\\n${content}\\n\\`\\`\\``;\n}\n\n/**\n * Create an unordered list block.\n *\n * Markdown:\n * ```\n * - Item\n * - Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function list(items: readonly string[]): string {\n return items.map((item) => `- ${item}`).join('\\n');\n}\n\n/**\n * Create an ordered list block.\n *\n * Markdown:\n * ```\n * 1. Item\n * 2. Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function orderedList(items: readonly string[]): string {\n return items.map((item, index) => `${index + 1}. ${item}`).join('\\n');\n}\n"],"mappings":";;;;;;;;;AAOO,MAAMA,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,KAAK;AAa5B,SAASE,OAAOA,CAACC,IAAY,EAAEC,OAAwB,EAAU;EACtE,MAAMC,KAAK,GAAGD,OAAO,EAAEC,KAAK,IAAI,CAAC;EACjC,OAAO,GAAG,GAAG,CAACC,MAAM,CAACD,KAAK,CAAC,IAAIF,IAAI,EAAE;AACvC;AAaO,SAASI,UAAUA,CAACC,OAAe,EAAU;EAClD,OAAO,IAAAC,kBAAW,EAACD,OAAO,EAAE,IAAI,CAAC;AACnC;AAcO,SAASE,SAASA,CAACF,OAAe,EAAU;EACjD,OAAO,WAAWA,OAAO,UAAU;AACrC;AAaO,SAASG,IAAIA,CAACC,KAAwB,EAAU;EACrD,OAAOA,KAAK,CAACC,GAAG,CAAEC,IAAI,IAAK,KAAKA,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACpD;AAaO,SAASC,WAAWA,CAACJ,KAAwB,EAAU;EAC5D,OAAOA,KAAK,CAACC,GAAG,CAAC,CAACC,IAAI,EAAEG,KAAK,KAAK,GAAGA,KAAK,GAAG,CAAC,KAAKH,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACvE","ignoreList":[]}
1
+ {"version":3,"file":"block.js","names":["horizontalRule","exports","heading","text","options","level","repeat","blockquote","content","prefixLines","joinBlocks","codeBlock","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { joinBlocks, prefixLines } from './utils';\n\n/**\n * Create a horizontal rule block.\n *\n * Markdown: `---`\n */\nexport const horizontalRule = '---';\n\ntype HeadingOptions = {\n level: number;\n};\n\n/**\n * Create a heading block.\n * Markdown: `# Heading`\n *\n * @param text - The text of the heading.\n * @param level - The level of the heading (defaults to 1).\n */\nexport function heading(text: string, options?: HeadingOptions): string {\n const level = options?.level ?? 1;\n return `${'#'.repeat(level)} ${text}`;\n}\n\n/**\n * Create a blockquote block.\n *\n * Markdown:\n * ```\n * > Content\n * > Content\n * ```\n *\n * @param text - The content of the blockquote.\n */\nexport function blockquote(content: string | readonly string[]): string {\n return prefixLines(joinBlocks(content), '> ');\n}\n\n/**\n * Create a code block.\n *\n * Markdown:\n * ````\n * ```\n * Content\n * ```\n * ````\n *\n * @param content - The content of the code block.\n */\nexport function codeBlock(content: string): string {\n return `\\`\\`\\`\\n${content}\\n\\`\\`\\``;\n}\n\n/**\n * Create an unordered list block.\n *\n * Markdown:\n * ```\n * - Item\n * - Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function list(items: readonly string[]): string {\n return items.map((item) => `- ${item}`).join('\\n');\n}\n\n/**\n * Create an ordered list block.\n *\n * Markdown:\n * ```\n * 1. Item\n * 2. Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function orderedList(items: readonly string[]): string {\n return items.map((item, index) => `${index + 1}. ${item}`).join('\\n');\n}\n"],"mappings":";;;;;;;;;AAOO,MAAMA,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,KAAK;AAa5B,SAASE,OAAOA,CAACC,IAAY,EAAEC,OAAwB,EAAU;EACtE,MAAMC,KAAK,GAAGD,OAAO,EAAEC,KAAK,IAAI,CAAC;EACjC,OAAO,GAAG,GAAG,CAACC,MAAM,CAACD,KAAK,CAAC,IAAIF,IAAI,EAAE;AACvC;AAaO,SAASI,UAAUA,CAACC,OAAmC,EAAU;EACtE,OAAO,IAAAC,kBAAW,EAAC,IAAAC,iBAAU,EAACF,OAAO,CAAC,EAAE,IAAI,CAAC;AAC/C;AAcO,SAASG,SAASA,CAACH,OAAe,EAAU;EACjD,OAAO,WAAWA,OAAO,UAAU;AACrC;AAaO,SAASI,IAAIA,CAACC,KAAwB,EAAU;EACrD,OAAOA,KAAK,CAACC,GAAG,CAAEC,IAAI,IAAK,KAAKA,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACpD;AAaO,SAASC,WAAWA,CAACJ,KAAwB,EAAU;EAC5D,OAAOA,KAAK,CAACC,GAAG,CAAC,CAACC,IAAI,EAAEG,KAAK,KAAK,GAAGA,KAAK,GAAG,CAAC,KAAKH,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACvE","ignoreList":[]}
@@ -54,6 +54,12 @@ Object.defineProperty(exports, "italic", {
54
54
  return _inline.italic;
55
55
  }
56
56
  });
57
+ Object.defineProperty(exports, "joinBlocks", {
58
+ enumerable: true,
59
+ get: function () {
60
+ return _utils.joinBlocks;
61
+ }
62
+ });
57
63
  Object.defineProperty(exports, "lineBreak", {
58
64
  enumerable: true,
59
65
  get: function () {
@@ -88,4 +94,5 @@ var _block = require("./block.js");
88
94
  var _inline = require("./inline.js");
89
95
  var _table = require("./table.js");
90
96
  var _html = require("./html.js");
97
+ var _utils = require("./utils.js");
91
98
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';\nexport { code, italic, bold, link, image } from './inline';\nexport { table } from './table';\nexport { lineBreak, disclosure } from './html';\n\nexport type { TableOptions } from './table';\nexport type { DisclosureOptions } from './html';\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';\nexport { code, italic, bold, link, image } from './inline';\nexport { table } from './table';\nexport { lineBreak, disclosure } from './html';\nexport { joinBlocks } from './utils';\n\nexport type { TableOptions } from './table';\nexport type { DisclosureOptions } from './html';\n"],"mappings":"","ignoreList":[]}
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
 
3
+ exports.joinBlocks = joinBlocks;
3
4
  exports.prefixLines = prefixLines;
5
+ function joinBlocks(blocks) {
6
+ blocks = typeof blocks === 'string' ? [blocks] : blocks;
7
+ return blocks.map(trimBlock).filter(Boolean).join('\n\n');
8
+ }
9
+ function trimBlock(block) {
10
+ return block.replace(/^\n+|\n+$/g, '');
11
+ }
4
12
  function prefixLines(text, prefix) {
5
13
  const lines = text.split('\n');
6
14
  return lines.map(line => `${prefix}${line}`).join('\n');
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["prefixLines","text","prefix","lines","split","map","line","join"],"sources":["../../src/utils.ts"],"sourcesContent":["export function prefixLines(text: string, prefix: string): string {\n const lines = text.split('\\n');\n return lines.map((line) => `${prefix}${line}`).join('\\n');\n}\n"],"mappings":";;;AAAO,SAASA,WAAWA,CAACC,IAAY,EAAEC,MAAc,EAAU;EAChE,MAAMC,KAAK,GAAGF,IAAI,CAACG,KAAK,CAAC,IAAI,CAAC;EAC9B,OAAOD,KAAK,CAACE,GAAG,CAAEC,IAAI,IAAK,GAAGJ,MAAM,GAAGI,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AAC3D","ignoreList":[]}
1
+ {"version":3,"file":"utils.js","names":["joinBlocks","blocks","map","trimBlock","filter","Boolean","join","block","replace","prefixLines","text","prefix","lines","split","line"],"sources":["../../src/utils.ts"],"sourcesContent":["/**\n * Join blocks of text into a single markdown document (string).\n *\n * @param blocks - The blocks of text to join.\n * @returns Markdown document string.\n */\nexport function joinBlocks(blocks: string | readonly string[]): string {\n blocks = typeof blocks === 'string' ? [blocks] : blocks;\n\n return blocks.map(trimBlock).filter(Boolean).join('\\n\\n');\n}\n\nfunction trimBlock(block: string): string {\n return block.replace(/^\\n+|\\n+$/g, '');\n}\n\nexport function prefixLines(text: string, prefix: string): string {\n const lines = text.split('\\n');\n return lines.map((line) => `${prefix}${line}`).join('\\n');\n}\n"],"mappings":";;;;AAMO,SAASA,UAAUA,CAACC,MAAkC,EAAU;EACrEA,MAAM,GAAG,OAAOA,MAAM,KAAK,QAAQ,GAAG,CAACA,MAAM,CAAC,GAAGA,MAAM;EAEvD,OAAOA,MAAM,CAACC,GAAG,CAACC,SAAS,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;AAC3D;AAEA,SAASH,SAASA,CAACI,KAAa,EAAU;EACxC,OAAOA,KAAK,CAACC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACxC;AAEO,SAASC,WAAWA,CAACC,IAAY,EAAEC,MAAc,EAAU;EAChE,MAAMC,KAAK,GAAGF,IAAI,CAACG,KAAK,CAAC,IAAI,CAAC;EAC9B,OAAOD,KAAK,CAACV,GAAG,CAAEY,IAAI,IAAK,GAAGH,MAAM,GAAGG,IAAI,EAAE,CAAC,CAACR,IAAI,CAAC,IAAI,CAAC;AAC3D","ignoreList":[]}
@@ -1,11 +1,11 @@
1
- import { prefixLines } from "./utils.mjs";
1
+ import { joinBlocks, prefixLines } from "./utils.mjs";
2
2
  export const horizontalRule = '---';
3
3
  export function heading(text, options) {
4
4
  const level = options?.level ?? 1;
5
5
  return `${'#'.repeat(level)} ${text}`;
6
6
  }
7
7
  export function blockquote(content) {
8
- return prefixLines(content, '> ');
8
+ return prefixLines(joinBlocks(content), '> ');
9
9
  }
10
10
  export function codeBlock(content) {
11
11
  return `\`\`\`\n${content}\n\`\`\``;
@@ -1 +1 @@
1
- {"version":3,"file":"block.mjs","names":["prefixLines","horizontalRule","heading","text","options","level","repeat","blockquote","content","codeBlock","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { prefixLines } from './utils';\n\n/**\n * Create a horizontal rule block.\n *\n * Markdown: `---`\n */\nexport const horizontalRule = '---';\n\ntype HeadingOptions = {\n level: number;\n};\n\n/**\n * Create a heading block.\n * Markdown: `# Heading`\n *\n * @param text - The text of the heading.\n * @param level - The level of the heading (defaults to 1).\n */\nexport function heading(text: string, options?: HeadingOptions): string {\n const level = options?.level ?? 1;\n return `${'#'.repeat(level)} ${text}`;\n}\n\n/**\n * Create a blockquote block.\n *\n * Markdown:\n * ```\n * > Content\n * > Content\n * ```\n *\n * @param text - The content of the blockquote.\n */\nexport function blockquote(content: string): string {\n return prefixLines(content, '> ');\n}\n\n/**\n * Create a code block.\n *\n * Markdown:\n * ````\n * ```\n * Content\n * ```\n * ````\n *\n * @param content - The content of the code block.\n */\nexport function codeBlock(content: string): string {\n return `\\`\\`\\`\\n${content}\\n\\`\\`\\``;\n}\n\n/**\n * Create an unordered list block.\n *\n * Markdown:\n * ```\n * - Item\n * - Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function list(items: readonly string[]): string {\n return items.map((item) => `- ${item}`).join('\\n');\n}\n\n/**\n * Create an ordered list block.\n *\n * Markdown:\n * ```\n * 1. Item\n * 2. Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function orderedList(items: readonly string[]): string {\n return items.map((item, index) => `${index + 1}. ${item}`).join('\\n');\n}\n"],"mappings":"SAASA,WAAW;AAOpB,OAAO,MAAMC,cAAc,GAAG,KAAK;AAanC,OAAO,SAASC,OAAOA,CAACC,IAAY,EAAEC,OAAwB,EAAU;EACtE,MAAMC,KAAK,GAAGD,OAAO,EAAEC,KAAK,IAAI,CAAC;EACjC,OAAO,GAAG,GAAG,CAACC,MAAM,CAACD,KAAK,CAAC,IAAIF,IAAI,EAAE;AACvC;AAaA,OAAO,SAASI,UAAUA,CAACC,OAAe,EAAU;EAClD,OAAOR,WAAW,CAACQ,OAAO,EAAE,IAAI,CAAC;AACnC;AAcA,OAAO,SAASC,SAASA,CAACD,OAAe,EAAU;EACjD,OAAO,WAAWA,OAAO,UAAU;AACrC;AAaA,OAAO,SAASE,IAAIA,CAACC,KAAwB,EAAU;EACrD,OAAOA,KAAK,CAACC,GAAG,CAAEC,IAAI,IAAK,KAAKA,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACpD;AAaA,OAAO,SAASC,WAAWA,CAACJ,KAAwB,EAAU;EAC5D,OAAOA,KAAK,CAACC,GAAG,CAAC,CAACC,IAAI,EAAEG,KAAK,KAAK,GAAGA,KAAK,GAAG,CAAC,KAAKH,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACvE","ignoreList":[]}
1
+ {"version":3,"file":"block.mjs","names":["joinBlocks","prefixLines","horizontalRule","heading","text","options","level","repeat","blockquote","content","codeBlock","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { joinBlocks, prefixLines } from './utils';\n\n/**\n * Create a horizontal rule block.\n *\n * Markdown: `---`\n */\nexport const horizontalRule = '---';\n\ntype HeadingOptions = {\n level: number;\n};\n\n/**\n * Create a heading block.\n * Markdown: `# Heading`\n *\n * @param text - The text of the heading.\n * @param level - The level of the heading (defaults to 1).\n */\nexport function heading(text: string, options?: HeadingOptions): string {\n const level = options?.level ?? 1;\n return `${'#'.repeat(level)} ${text}`;\n}\n\n/**\n * Create a blockquote block.\n *\n * Markdown:\n * ```\n * > Content\n * > Content\n * ```\n *\n * @param text - The content of the blockquote.\n */\nexport function blockquote(content: string | readonly string[]): string {\n return prefixLines(joinBlocks(content), '> ');\n}\n\n/**\n * Create a code block.\n *\n * Markdown:\n * ````\n * ```\n * Content\n * ```\n * ````\n *\n * @param content - The content of the code block.\n */\nexport function codeBlock(content: string): string {\n return `\\`\\`\\`\\n${content}\\n\\`\\`\\``;\n}\n\n/**\n * Create an unordered list block.\n *\n * Markdown:\n * ```\n * - Item\n * - Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function list(items: readonly string[]): string {\n return items.map((item) => `- ${item}`).join('\\n');\n}\n\n/**\n * Create an ordered list block.\n *\n * Markdown:\n * ```\n * 1. Item\n * 2. Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function orderedList(items: readonly string[]): string {\n return items.map((item, index) => `${index + 1}. ${item}`).join('\\n');\n}\n"],"mappings":"SAASA,UAAU,EAAEC,WAAW;AAOhC,OAAO,MAAMC,cAAc,GAAG,KAAK;AAanC,OAAO,SAASC,OAAOA,CAACC,IAAY,EAAEC,OAAwB,EAAU;EACtE,MAAMC,KAAK,GAAGD,OAAO,EAAEC,KAAK,IAAI,CAAC;EACjC,OAAO,GAAG,GAAG,CAACC,MAAM,CAACD,KAAK,CAAC,IAAIF,IAAI,EAAE;AACvC;AAaA,OAAO,SAASI,UAAUA,CAACC,OAAmC,EAAU;EACtE,OAAOR,WAAW,CAACD,UAAU,CAACS,OAAO,CAAC,EAAE,IAAI,CAAC;AAC/C;AAcA,OAAO,SAASC,SAASA,CAACD,OAAe,EAAU;EACjD,OAAO,WAAWA,OAAO,UAAU;AACrC;AAaA,OAAO,SAASE,IAAIA,CAACC,KAAwB,EAAU;EACrD,OAAOA,KAAK,CAACC,GAAG,CAAEC,IAAI,IAAK,KAAKA,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACpD;AAaA,OAAO,SAASC,WAAWA,CAACJ,KAAwB,EAAU;EAC5D,OAAOA,KAAK,CAACC,GAAG,CAAC,CAACC,IAAI,EAAEG,KAAK,KAAK,GAAGA,KAAK,GAAG,CAAC,KAAKH,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACvE","ignoreList":[]}
@@ -2,4 +2,5 @@ export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } fro
2
2
  export { code, italic, bold, link, image } from "./inline.mjs";
3
3
  export { table } from "./table.mjs";
4
4
  export { lineBreak, disclosure } from "./html.mjs";
5
+ export { joinBlocks } from "./utils.mjs";
5
6
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["horizontalRule","heading","blockquote","orderedList","list","codeBlock","code","italic","bold","link","image","table","lineBreak","disclosure"],"sources":["../../src/index.ts"],"sourcesContent":["export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';\nexport { code, italic, bold, link, image } from './inline';\nexport { table } from './table';\nexport { lineBreak, disclosure } from './html';\n\nexport type { TableOptions } from './table';\nexport type { DisclosureOptions } from './html';\n"],"mappings":"SAASA,cAAc,EAAEC,OAAO,EAAEC,UAAU,EAAEC,WAAW,EAAEC,IAAI,EAAEC,SAAS;AAAA,SACjEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK;AAAA,SAC/BC,KAAK;AAAA,SACLC,SAAS,EAAEC,UAAU","ignoreList":[]}
1
+ {"version":3,"file":"index.mjs","names":["horizontalRule","heading","blockquote","orderedList","list","codeBlock","code","italic","bold","link","image","table","lineBreak","disclosure","joinBlocks"],"sources":["../../src/index.ts"],"sourcesContent":["export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';\nexport { code, italic, bold, link, image } from './inline';\nexport { table } from './table';\nexport { lineBreak, disclosure } from './html';\nexport { joinBlocks } from './utils';\n\nexport type { TableOptions } from './table';\nexport type { DisclosureOptions } from './html';\n"],"mappings":"SAASA,cAAc,EAAEC,OAAO,EAAEC,UAAU,EAAEC,WAAW,EAAEC,IAAI,EAAEC,SAAS;AAAA,SACjEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK;AAAA,SAC/BC,KAAK;AAAA,SACLC,SAAS,EAAEC,UAAU;AAAA,SACrBC,UAAU","ignoreList":[]}
@@ -1,3 +1,10 @@
1
+ export function joinBlocks(blocks) {
2
+ blocks = typeof blocks === 'string' ? [blocks] : blocks;
3
+ return blocks.map(trimBlock).filter(Boolean).join('\n\n');
4
+ }
5
+ function trimBlock(block) {
6
+ return block.replace(/^\n+|\n+$/g, '');
7
+ }
1
8
  export function prefixLines(text, prefix) {
2
9
  const lines = text.split('\n');
3
10
  return lines.map(line => `${prefix}${line}`).join('\n');
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":["prefixLines","text","prefix","lines","split","map","line","join"],"sources":["../../src/utils.ts"],"sourcesContent":["export function prefixLines(text: string, prefix: string): string {\n const lines = text.split('\\n');\n return lines.map((line) => `${prefix}${line}`).join('\\n');\n}\n"],"mappings":"AAAA,OAAO,SAASA,WAAWA,CAACC,IAAY,EAAEC,MAAc,EAAU;EAChE,MAAMC,KAAK,GAAGF,IAAI,CAACG,KAAK,CAAC,IAAI,CAAC;EAC9B,OAAOD,KAAK,CAACE,GAAG,CAAEC,IAAI,IAAK,GAAGJ,MAAM,GAAGI,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AAC3D","ignoreList":[]}
1
+ {"version":3,"file":"utils.mjs","names":["joinBlocks","blocks","map","trimBlock","filter","Boolean","join","block","replace","prefixLines","text","prefix","lines","split","line"],"sources":["../../src/utils.ts"],"sourcesContent":["/**\n * Join blocks of text into a single markdown document (string).\n *\n * @param blocks - The blocks of text to join.\n * @returns Markdown document string.\n */\nexport function joinBlocks(blocks: string | readonly string[]): string {\n blocks = typeof blocks === 'string' ? [blocks] : blocks;\n\n return blocks.map(trimBlock).filter(Boolean).join('\\n\\n');\n}\n\nfunction trimBlock(block: string): string {\n return block.replace(/^\\n+|\\n+$/g, '');\n}\n\nexport function prefixLines(text: string, prefix: string): string {\n const lines = text.split('\\n');\n return lines.map((line) => `${prefix}${line}`).join('\\n');\n}\n"],"mappings":"AAMA,OAAO,SAASA,UAAUA,CAACC,MAAkC,EAAU;EACrEA,MAAM,GAAG,OAAOA,MAAM,KAAK,QAAQ,GAAG,CAACA,MAAM,CAAC,GAAGA,MAAM;EAEvD,OAAOA,MAAM,CAACC,GAAG,CAACC,SAAS,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;AAC3D;AAEA,SAASH,SAASA,CAACI,KAAa,EAAU;EACxC,OAAOA,KAAK,CAACC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACxC;AAEA,OAAO,SAASC,WAAWA,CAACC,IAAY,EAAEC,MAAc,EAAU;EAChE,MAAMC,KAAK,GAAGF,IAAI,CAACG,KAAK,CAAC,IAAI,CAAC;EAC9B,OAAOD,KAAK,CAACV,GAAG,CAAEY,IAAI,IAAK,GAAGH,MAAM,GAAGG,IAAI,EAAE,CAAC,CAACR,IAAI,CAAC,IAAI,CAAC;AAC3D","ignoreList":[]}
@@ -26,7 +26,7 @@ export declare function heading(text: string, options?: HeadingOptions): string;
26
26
  *
27
27
  * @param text - The content of the blockquote.
28
28
  */
29
- export declare function blockquote(content: string): string;
29
+ export declare function blockquote(content: string | readonly string[]): string;
30
30
  /**
31
31
  * Create a code block.
32
32
  *
@@ -2,5 +2,6 @@ export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } fro
2
2
  export { code, italic, bold, link, image } from './inline';
3
3
  export { table } from './table';
4
4
  export { lineBreak, disclosure } from './html';
5
+ export { joinBlocks } from './utils';
5
6
  export type { TableOptions } from './table';
6
7
  export type { DisclosureOptions } from './html';
@@ -1 +1,8 @@
1
+ /**
2
+ * Join blocks of text into a single markdown document (string).
3
+ *
4
+ * @param blocks - The blocks of text to join.
5
+ * @returns Markdown document string.
6
+ */
7
+ export declare function joinBlocks(blocks: string | readonly string[]): string;
1
8
  export declare function prefixLines(text: string, prefix: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-markdown-builder",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Elegant markdown builder with minimal bundle size.",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "module": "dist/esm/index.mjs",
@@ -53,11 +53,11 @@
53
53
  "@babel/preset-env": "^7.25.4",
54
54
  "@babel/preset-typescript": "^7.24.7",
55
55
  "@callstack/eslint-config": "^15.0.0",
56
- "@release-it/conventional-changelog": "^8.0.1",
57
- "@size-limit/preset-small-lib": "^11.1.4",
56
+ "@release-it/conventional-changelog": "^9.0.0",
57
+ "@size-limit/preset-small-lib": "^11.1.6",
58
58
  "@types/jest": "^29.5.12",
59
59
  "babel-plugin-add-import-extension": "^1.6.0",
60
- "del-cli": "^5.1.0",
60
+ "del-cli": "^6.0.0",
61
61
  "eslint": "^8.57.0",
62
62
  "eslint-config-prettier": "^8.10.0",
63
63
  "eslint-plugin-flowtype": "^8.0.3",
@@ -65,7 +65,7 @@
65
65
  "eslint-plugin-prettier": "^4.2.1",
66
66
  "jest": "^29.7.0",
67
67
  "prettier": "^2.8.8",
68
- "release-it": "^17.6.0",
68
+ "release-it": "^17.10.0",
69
69
  "typescript": "^5.5.4"
70
70
  },
71
71
  "packageManager": "yarn@4.4.1",
@@ -101,11 +101,36 @@
101
101
  "publish": true
102
102
  },
103
103
  "github": {
104
- "release": true
104
+ "release": true,
105
+ "releaseName": "v${version} (${date:yyyy-MM-dd})"
105
106
  },
106
107
  "plugins": {
107
108
  "@release-it/conventional-changelog": {
108
- "preset": "angular"
109
+ "preset": {
110
+ "name": "conventionalcommits",
111
+ "types": [
112
+ {
113
+ "type": "feat",
114
+ "section": "✨ Features"
115
+ },
116
+ {
117
+ "type": "perf",
118
+ "section": "💨 Performance Improvements"
119
+ },
120
+ {
121
+ "type": "fix",
122
+ "section": "🐛 Bug Fixes"
123
+ },
124
+ {
125
+ "type": "chore(deps)",
126
+ "section": "🛠️ Dependency Upgrades"
127
+ },
128
+ {
129
+ "type": "docs",
130
+ "section": "📚 Documentation"
131
+ }
132
+ ]
133
+ }
109
134
  }
110
135
  }
111
136
  },