ts-markdown-builder 0.2.2 → 0.3.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.
package/README.md CHANGED
@@ -11,9 +11,10 @@ Elegant markdown builder with minimal bundle size.
11
11
  ## Goal
12
12
 
13
13
  TypeScript markdown generation library:
14
+
14
15
  - easy to read and write API
15
16
  - build CommonMark & GFM compliant markdown
16
- - minimal bundle size + tree-shakable
17
+ - minimal bundle size + tree-shakable
17
18
 
18
19
  ## Installation
19
20
 
@@ -26,7 +27,7 @@ npm install ts-markdown-builder
26
27
  ```js
27
28
  import * as md from 'ts-markdown-builder';
28
29
 
29
- const output = md.joinBlocks([
30
+ const output = [
30
31
  md.heading('Welcome to TS Markdown Builder'),
31
32
  "It's an easy to use modern markdown generator.",
32
33
  'It supports:',
@@ -37,7 +38,7 @@ const output = md.joinBlocks([
37
38
  'blockquotes',
38
39
  'and more!',
39
40
  ]),
40
- ]);
41
+ ].join('\n\n');
41
42
  ```
42
43
 
43
44
  ```markdown
@@ -47,7 +48,7 @@ It's an easy to use modern markdown generator.
47
48
 
48
49
  It supports:
49
50
 
50
- - **bold** and *italic*
51
+ - **bold** and _italic_
51
52
  - \`code\` spans and code blocks
52
53
  - unordered and ordered lists
53
54
  - blockquotes
@@ -8,7 +8,8 @@ exports.list = list;
8
8
  exports.orderedList = orderedList;
9
9
  var _utils = require("./utils.js");
10
10
  const horizontalRule = exports.horizontalRule = '---';
11
- function heading(text, level = 1) {
11
+ function heading(text, options) {
12
+ const level = options?.level ?? 1;
12
13
  return `${'#'.repeat(level)} ${text}`;
13
14
  }
14
15
  function blockquote(content) {
@@ -1 +1 @@
1
- {"version":3,"file":"block.js","names":["horizontalRule","exports","heading","text","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\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, level: number = 1): string {\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;AAS5B,SAASE,OAAOA,CAACC,IAAY,EAAEC,KAAa,GAAG,CAAC,EAAU;EAC/D,OAAO,GAAG,GAAG,CAACC,MAAM,CAACD,KAAK,CAAC,IAAID,IAAI,EAAE;AACvC;AAaO,SAASG,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","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":[]}
@@ -7,7 +7,10 @@ function disclosure(title, content, options) {
7
7
  const headerHack = title.startsWith('#') ? '\n\n' : '';
8
8
  return `<details${options?.open ? ' open' : ''}>
9
9
  <summary>${headerHack}${title}${headerHack}</summary>
10
- \n${content}\n
10
+ ${escapeMarkdownInHtml(content)}
11
11
  </details>`;
12
12
  }
13
+ function escapeMarkdownInHtml(markdown) {
14
+ return `\n${markdown}\n`;
15
+ }
13
16
  //# sourceMappingURL=html.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"html.js","names":["lineBreak","exports","disclosure","title","content","options","headerHack","startsWith","open"],"sources":["../../src/html.ts"],"sourcesContent":["/**\n * Create a line break.\n *\n * Markdown/Html:: `<br/>`\n */\nexport const lineBreak = '<br/>';\n\n/**\n * Options for the `disclosure` block.\n */\nexport type DisclosureOptions = {\n /**\n * Whether the disclosure block should be open by default.\n */\n open?: boolean;\n};\n\n/**\n * Create a disclosure block.\n *\n * Markdown/Html:\n * ```\n * <details>\n * <summary>Title</summary>\n * Content\n * </details>\n * ```\n *\n * @param title - The title of the disclosure.\n * @param content - The content of the disclosure.\n * @param options - The options for the disclosure.\n */\nexport function disclosure(title: string, content: string, options?: DisclosureOptions): string {\n // Add extra with lines to render header properly. New line should not be added for regular text\n // as it messes up the formatting.\n const headerHack = title.startsWith('#') ? '\\n\\n' : '';\n\n // The extra new lines in <summary> and <details> are required for proper rendering in GitHub.\n // See https://gist.github.com/scmx/eca72d44afee0113ceb0349dd54a84a2\n return `<details${options?.open ? ' open' : ''}>\n<summary>${headerHack}${title}${headerHack}</summary>\n\\n${content}\\n \n</details>`;\n}\n"],"mappings":";;;;AAKO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,OAAO;AA2BzB,SAASE,UAAUA,CAACC,KAAa,EAAEC,OAAe,EAAEC,OAA2B,EAAU;EAG9F,MAAMC,UAAU,GAAGH,KAAK,CAACI,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,EAAE;EAItD,OAAO,WAAWF,OAAO,EAAEG,IAAI,GAAG,OAAO,GAAG,EAAE;AAChD,WAAWF,UAAU,GAAGH,KAAK,GAAGG,UAAU;AAC1C,IAAIF,OAAO;AACX,WAAW;AACX","ignoreList":[]}
1
+ {"version":3,"file":"html.js","names":["lineBreak","exports","disclosure","title","content","options","headerHack","startsWith","open","escapeMarkdownInHtml","markdown"],"sources":["../../src/html.ts"],"sourcesContent":["/**\n * Create a line break.\n *\n * Markdown (as HTML): `<br/>`\n */\nexport const lineBreak = '<br/>';\n\n/**\n * Options for the `disclosure` block.\n */\nexport type DisclosureOptions = {\n /**\n * Whether the disclosure block should be open by default (defaults to false).\n */\n open?: boolean;\n};\n\n/**\n * Create a disclosure block.\n *\n * Markdown (as HTML):\n * ```\n * <details>\n * <summary>Title</summary>\n * Content\n * </details>\n * ```\n *\n * @param title - The title of the disclosure (text only or markdown heading: `# heading`).\n * @param content - The content of the disclosure (can include markdown).\n * @param options - The options for the disclosure.\n */\nexport function disclosure(title: string, content: string, options?: DisclosureOptions): string {\n // Add extra with lines to render header properly. New line should not be added for regular text\n // as it messes up the formatting.\n const headerHack = title.startsWith('#') ? '\\n\\n' : '';\n\n return `<details${options?.open ? ' open' : ''}>\n<summary>${headerHack}${title}${headerHack}</summary>\n${escapeMarkdownInHtml(content)}\n</details>`;\n}\n\n// Blank lines are required for rendering a markdown section inside html tag.\n// See https://gist.github.com/scmx/eca72d44afee0113ceb0349dd54a84a2\nfunction escapeMarkdownInHtml(markdown: string): string {\n return `\\n${markdown}\\n`;\n}\n"],"mappings":";;;;AAKO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,OAAO;AA2BzB,SAASE,UAAUA,CAACC,KAAa,EAAEC,OAAe,EAAEC,OAA2B,EAAU;EAG9F,MAAMC,UAAU,GAAGH,KAAK,CAACI,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,EAAE;EAEtD,OAAO,WAAWF,OAAO,EAAEG,IAAI,GAAG,OAAO,GAAG,EAAE;AAChD,WAAWF,UAAU,GAAGH,KAAK,GAAGG,UAAU;AAC1C,EAAEG,oBAAoB,CAACL,OAAO,CAAC;AAC/B,WAAW;AACX;AAIA,SAASK,oBAAoBA,CAACC,QAAgB,EAAU;EACtD,OAAO,KAAKA,QAAQ,IAAI;AAC1B","ignoreList":[]}
@@ -54,18 +54,6 @@ 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 _join.joinBlocks;
61
- }
62
- });
63
- Object.defineProperty(exports, "joinLines", {
64
- enumerable: true,
65
- get: function () {
66
- return _join.joinLines;
67
- }
68
- });
69
57
  Object.defineProperty(exports, "lineBreak", {
70
58
  enumerable: true,
71
59
  get: function () {
@@ -96,7 +84,6 @@ Object.defineProperty(exports, "table", {
96
84
  return _table.table;
97
85
  }
98
86
  });
99
- var _join = require("./join.js");
100
87
  var _block = require("./block.js");
101
88
  var _inline = require("./inline.js");
102
89
  var _table = require("./table.js");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export { joinBlocks, joinLines } from './join';\nexport { 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';\n\nexport type { TableOptions } from './table';\nexport type { DisclosureOptions } from './html';\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"inline.js","names":["italic","text","bold","code","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["/**\n * Create an italic text.\n *\n * Markdown: `*text*`\n *\n * @param text - The text to be italicized.\n */\nexport function italic(text: string): string {\n return `*${text}*`;\n}\n\n/**\n * Create a bold text.\n *\n * Markdown: `**text**`\n *\n * @param text - The text to be bolded.\n */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/**\n * Create a code text.\n *\n * Markdown: `\\`text\\``\n *\n * @param text - The text to be marked as code.\n */\nexport function code(text: string): string {\n return `\\`${text}\\``;\n}\n\n/**\n * Create a link or autolink span.\n *\n * Markdown:\n * - `[text](url)` link when `text` is provided\n * - `<url>` autolink when `text` is not provided\n *\n * @param url - The URL to be linked.\n * @param text - The title for the link (optional).\n */\nexport function link(url: string, text?: string): string {\n return text ? `[${text}](${url})` : `<${url}>`;\n}\n\n/**\n * Create an image text.\n *\n * Markdown: `![text](url)`\n *\n * @param url - The URL of the image.\n * @param text - The description for the image (optional).\n */\nexport function image(url: string, text?: string): string {\n return `![${text ?? ''}](${url})`;\n}\n"],"mappings":";;;;;;;AAOO,SAASA,MAAMA,CAACC,IAAY,EAAU;EAC3C,OAAO,IAAIA,IAAI,GAAG;AACpB;AASO,SAASC,IAAIA,CAACD,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AASO,SAASE,IAAIA,CAACF,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AAYO,SAASG,IAAIA,CAACC,GAAW,EAAEJ,IAAa,EAAU;EACvD,OAAOA,IAAI,GAAG,IAAIA,IAAI,KAAKI,GAAG,GAAG,GAAG,IAAIA,GAAG,GAAG;AAChD;AAUO,SAASC,KAAKA,CAACD,GAAW,EAAEJ,IAAa,EAAU;EACxD,OAAO,KAAKA,IAAI,IAAI,EAAE,KAAKI,GAAG,GAAG;AACnC","ignoreList":[]}
1
+ {"version":3,"file":"inline.js","names":["italic","text","bold","code","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["/**\n * Create an italic text.\n *\n * Markdown: `*text*`\n *\n * @param text - The text to be italicized.\n */\nexport function italic(text: string): string {\n return `*${text}*`;\n}\n\n/**\n * Create a bold text.\n *\n * Markdown: `**text**`\n *\n * @param text - The text to be bolded.\n */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/**\n * Create a code text.\n *\n * Markdown: `code`\n *\n * @param text - The text to be marked as code.\n */\nexport function code(text: string): string {\n return `\\`${text}\\``;\n}\n\n/**\n * Create a link or autolink span.\n *\n * Markdown:\n * - `[text](url)` link when `text` is provided\n * - `<url>` autolink when `text` is not provided\n *\n * @param url - The URL to be linked.\n * @param text - The title for the link (optional).\n */\nexport function link(url: string, text?: string): string {\n return text ? `[${text}](${url})` : `<${url}>`;\n}\n\n/**\n * Create an image text.\n *\n * Markdown: `![text](url)`\n *\n * @param url - The URL of the image.\n * @param text - The description for the image (optional).\n */\nexport function image(url: string, text?: string): string {\n return `![${text ?? ''}](${url})`;\n}\n"],"mappings":";;;;;;;AAOO,SAASA,MAAMA,CAACC,IAAY,EAAU;EAC3C,OAAO,IAAIA,IAAI,GAAG;AACpB;AASO,SAASC,IAAIA,CAACD,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AASO,SAASE,IAAIA,CAACF,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AAYO,SAASG,IAAIA,CAACC,GAAW,EAAEJ,IAAa,EAAU;EACvD,OAAOA,IAAI,GAAG,IAAIA,IAAI,KAAKI,GAAG,GAAG,GAAG,IAAIA,GAAG,GAAG;AAChD;AAUO,SAASC,KAAKA,CAACD,GAAW,EAAEJ,IAAa,EAAU;EACxD,OAAO,KAAKA,IAAI,IAAI,EAAE,KAAKI,GAAG,GAAG;AACnC","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  import { prefixLines } from "./utils.mjs";
2
2
  export const horizontalRule = '---';
3
- export function heading(text, level = 1) {
3
+ export function heading(text, options) {
4
+ const level = options?.level ?? 1;
4
5
  return `${'#'.repeat(level)} ${text}`;
5
6
  }
6
7
  export function blockquote(content) {
@@ -1 +1 @@
1
- {"version":3,"file":"block.mjs","names":["prefixLines","horizontalRule","heading","text","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\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, level: number = 1): string {\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;AASnC,OAAO,SAASC,OAAOA,CAACC,IAAY,EAAEC,KAAa,GAAG,CAAC,EAAU;EAC/D,OAAO,GAAG,GAAG,CAACC,MAAM,CAACD,KAAK,CAAC,IAAID,IAAI,EAAE;AACvC;AAaA,OAAO,SAASG,UAAUA,CAACC,OAAe,EAAU;EAClD,OAAOP,WAAW,CAACO,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":["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":[]}
package/dist/esm/html.mjs CHANGED
@@ -3,7 +3,10 @@ export function disclosure(title, content, options) {
3
3
  const headerHack = title.startsWith('#') ? '\n\n' : '';
4
4
  return `<details${options?.open ? ' open' : ''}>
5
5
  <summary>${headerHack}${title}${headerHack}</summary>
6
- \n${content}\n
6
+ ${escapeMarkdownInHtml(content)}
7
7
  </details>`;
8
8
  }
9
+ function escapeMarkdownInHtml(markdown) {
10
+ return `\n${markdown}\n`;
11
+ }
9
12
  //# sourceMappingURL=html.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"html.mjs","names":["lineBreak","disclosure","title","content","options","headerHack","startsWith","open"],"sources":["../../src/html.ts"],"sourcesContent":["/**\n * Create a line break.\n *\n * Markdown/Html:: `<br/>`\n */\nexport const lineBreak = '<br/>';\n\n/**\n * Options for the `disclosure` block.\n */\nexport type DisclosureOptions = {\n /**\n * Whether the disclosure block should be open by default.\n */\n open?: boolean;\n};\n\n/**\n * Create a disclosure block.\n *\n * Markdown/Html:\n * ```\n * <details>\n * <summary>Title</summary>\n * Content\n * </details>\n * ```\n *\n * @param title - The title of the disclosure.\n * @param content - The content of the disclosure.\n * @param options - The options for the disclosure.\n */\nexport function disclosure(title: string, content: string, options?: DisclosureOptions): string {\n // Add extra with lines to render header properly. New line should not be added for regular text\n // as it messes up the formatting.\n const headerHack = title.startsWith('#') ? '\\n\\n' : '';\n\n // The extra new lines in <summary> and <details> are required for proper rendering in GitHub.\n // See https://gist.github.com/scmx/eca72d44afee0113ceb0349dd54a84a2\n return `<details${options?.open ? ' open' : ''}>\n<summary>${headerHack}${title}${headerHack}</summary>\n\\n${content}\\n \n</details>`;\n}\n"],"mappings":"AAKA,OAAO,MAAMA,SAAS,GAAG,OAAO;AA2BhC,OAAO,SAASC,UAAUA,CAACC,KAAa,EAAEC,OAAe,EAAEC,OAA2B,EAAU;EAG9F,MAAMC,UAAU,GAAGH,KAAK,CAACI,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,EAAE;EAItD,OAAO,WAAWF,OAAO,EAAEG,IAAI,GAAG,OAAO,GAAG,EAAE;AAChD,WAAWF,UAAU,GAAGH,KAAK,GAAGG,UAAU;AAC1C,IAAIF,OAAO;AACX,WAAW;AACX","ignoreList":[]}
1
+ {"version":3,"file":"html.mjs","names":["lineBreak","disclosure","title","content","options","headerHack","startsWith","open","escapeMarkdownInHtml","markdown"],"sources":["../../src/html.ts"],"sourcesContent":["/**\n * Create a line break.\n *\n * Markdown (as HTML): `<br/>`\n */\nexport const lineBreak = '<br/>';\n\n/**\n * Options for the `disclosure` block.\n */\nexport type DisclosureOptions = {\n /**\n * Whether the disclosure block should be open by default (defaults to false).\n */\n open?: boolean;\n};\n\n/**\n * Create a disclosure block.\n *\n * Markdown (as HTML):\n * ```\n * <details>\n * <summary>Title</summary>\n * Content\n * </details>\n * ```\n *\n * @param title - The title of the disclosure (text only or markdown heading: `# heading`).\n * @param content - The content of the disclosure (can include markdown).\n * @param options - The options for the disclosure.\n */\nexport function disclosure(title: string, content: string, options?: DisclosureOptions): string {\n // Add extra with lines to render header properly. New line should not be added for regular text\n // as it messes up the formatting.\n const headerHack = title.startsWith('#') ? '\\n\\n' : '';\n\n return `<details${options?.open ? ' open' : ''}>\n<summary>${headerHack}${title}${headerHack}</summary>\n${escapeMarkdownInHtml(content)}\n</details>`;\n}\n\n// Blank lines are required for rendering a markdown section inside html tag.\n// See https://gist.github.com/scmx/eca72d44afee0113ceb0349dd54a84a2\nfunction escapeMarkdownInHtml(markdown: string): string {\n return `\\n${markdown}\\n`;\n}\n"],"mappings":"AAKA,OAAO,MAAMA,SAAS,GAAG,OAAO;AA2BhC,OAAO,SAASC,UAAUA,CAACC,KAAa,EAAEC,OAAe,EAAEC,OAA2B,EAAU;EAG9F,MAAMC,UAAU,GAAGH,KAAK,CAACI,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,EAAE;EAEtD,OAAO,WAAWF,OAAO,EAAEG,IAAI,GAAG,OAAO,GAAG,EAAE;AAChD,WAAWF,UAAU,GAAGH,KAAK,GAAGG,UAAU;AAC1C,EAAEG,oBAAoB,CAACL,OAAO,CAAC;AAC/B,WAAW;AACX;AAIA,SAASK,oBAAoBA,CAACC,QAAgB,EAAU;EACtD,OAAO,KAAKA,QAAQ,IAAI;AAC1B","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- export { joinBlocks, joinLines } from "./join.mjs";
2
1
  export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from "./block.mjs";
3
2
  export { code, italic, bold, link, image } from "./inline.mjs";
4
3
  export { table } from "./table.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["joinBlocks","joinLines","horizontalRule","heading","blockquote","orderedList","list","codeBlock","code","italic","bold","link","image","table","lineBreak","disclosure"],"sources":["../../src/index.ts"],"sourcesContent":["export { joinBlocks, joinLines } from './join';\nexport { 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,UAAU,EAAEC,SAAS;AAAA,SACrBC,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"],"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 +1 @@
1
- {"version":3,"file":"inline.mjs","names":["italic","text","bold","code","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["/**\n * Create an italic text.\n *\n * Markdown: `*text*`\n *\n * @param text - The text to be italicized.\n */\nexport function italic(text: string): string {\n return `*${text}*`;\n}\n\n/**\n * Create a bold text.\n *\n * Markdown: `**text**`\n *\n * @param text - The text to be bolded.\n */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/**\n * Create a code text.\n *\n * Markdown: `\\`text\\``\n *\n * @param text - The text to be marked as code.\n */\nexport function code(text: string): string {\n return `\\`${text}\\``;\n}\n\n/**\n * Create a link or autolink span.\n *\n * Markdown:\n * - `[text](url)` link when `text` is provided\n * - `<url>` autolink when `text` is not provided\n *\n * @param url - The URL to be linked.\n * @param text - The title for the link (optional).\n */\nexport function link(url: string, text?: string): string {\n return text ? `[${text}](${url})` : `<${url}>`;\n}\n\n/**\n * Create an image text.\n *\n * Markdown: `![text](url)`\n *\n * @param url - The URL of the image.\n * @param text - The description for the image (optional).\n */\nexport function image(url: string, text?: string): string {\n return `![${text ?? ''}](${url})`;\n}\n"],"mappings":"AAOA,OAAO,SAASA,MAAMA,CAACC,IAAY,EAAU;EAC3C,OAAO,IAAIA,IAAI,GAAG;AACpB;AASA,OAAO,SAASC,IAAIA,CAACD,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AASA,OAAO,SAASE,IAAIA,CAACF,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AAYA,OAAO,SAASG,IAAIA,CAACC,GAAW,EAAEJ,IAAa,EAAU;EACvD,OAAOA,IAAI,GAAG,IAAIA,IAAI,KAAKI,GAAG,GAAG,GAAG,IAAIA,GAAG,GAAG;AAChD;AAUA,OAAO,SAASC,KAAKA,CAACD,GAAW,EAAEJ,IAAa,EAAU;EACxD,OAAO,KAAKA,IAAI,IAAI,EAAE,KAAKI,GAAG,GAAG;AACnC","ignoreList":[]}
1
+ {"version":3,"file":"inline.mjs","names":["italic","text","bold","code","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["/**\n * Create an italic text.\n *\n * Markdown: `*text*`\n *\n * @param text - The text to be italicized.\n */\nexport function italic(text: string): string {\n return `*${text}*`;\n}\n\n/**\n * Create a bold text.\n *\n * Markdown: `**text**`\n *\n * @param text - The text to be bolded.\n */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/**\n * Create a code text.\n *\n * Markdown: `code`\n *\n * @param text - The text to be marked as code.\n */\nexport function code(text: string): string {\n return `\\`${text}\\``;\n}\n\n/**\n * Create a link or autolink span.\n *\n * Markdown:\n * - `[text](url)` link when `text` is provided\n * - `<url>` autolink when `text` is not provided\n *\n * @param url - The URL to be linked.\n * @param text - The title for the link (optional).\n */\nexport function link(url: string, text?: string): string {\n return text ? `[${text}](${url})` : `<${url}>`;\n}\n\n/**\n * Create an image text.\n *\n * Markdown: `![text](url)`\n *\n * @param url - The URL of the image.\n * @param text - The description for the image (optional).\n */\nexport function image(url: string, text?: string): string {\n return `![${text ?? ''}](${url})`;\n}\n"],"mappings":"AAOA,OAAO,SAASA,MAAMA,CAACC,IAAY,EAAU;EAC3C,OAAO,IAAIA,IAAI,GAAG;AACpB;AASA,OAAO,SAASC,IAAIA,CAACD,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AASA,OAAO,SAASE,IAAIA,CAACF,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AAYA,OAAO,SAASG,IAAIA,CAACC,GAAW,EAAEJ,IAAa,EAAU;EACvD,OAAOA,IAAI,GAAG,IAAIA,IAAI,KAAKI,GAAG,GAAG,GAAG,IAAIA,GAAG,GAAG;AAChD;AAUA,OAAO,SAASC,KAAKA,CAACD,GAAW,EAAEJ,IAAa,EAAU;EACxD,OAAO,KAAKA,IAAI,IAAI,EAAE,KAAKI,GAAG,GAAG;AACnC","ignoreList":[]}
@@ -4,6 +4,9 @@
4
4
  * Markdown: `---`
5
5
  */
6
6
  export declare const horizontalRule = "---";
7
+ type HeadingOptions = {
8
+ level: number;
9
+ };
7
10
  /**
8
11
  * Create a heading block.
9
12
  * Markdown: `# Heading`
@@ -11,7 +14,7 @@ export declare const horizontalRule = "---";
11
14
  * @param text - The text of the heading.
12
15
  * @param level - The level of the heading (defaults to 1).
13
16
  */
14
- export declare function heading(text: string, level?: number): string;
17
+ export declare function heading(text: string, options?: HeadingOptions): string;
15
18
  /**
16
19
  * Create a blockquote block.
17
20
  *
@@ -61,3 +64,4 @@ export declare function list(items: readonly string[]): string;
61
64
  * @param items - The items of the list.
62
65
  */
63
66
  export declare function orderedList(items: readonly string[]): string;
67
+ export {};
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Create a line break.
3
3
  *
4
- * Markdown/Html:: `<br/>`
4
+ * Markdown (as HTML): `<br/>`
5
5
  */
6
6
  export declare const lineBreak = "<br/>";
7
7
  /**
@@ -9,14 +9,14 @@ export declare const lineBreak = "<br/>";
9
9
  */
10
10
  export type DisclosureOptions = {
11
11
  /**
12
- * Whether the disclosure block should be open by default.
12
+ * Whether the disclosure block should be open by default (defaults to false).
13
13
  */
14
14
  open?: boolean;
15
15
  };
16
16
  /**
17
17
  * Create a disclosure block.
18
18
  *
19
- * Markdown/Html:
19
+ * Markdown (as HTML):
20
20
  * ```
21
21
  * <details>
22
22
  * <summary>Title</summary>
@@ -24,8 +24,8 @@ export type DisclosureOptions = {
24
24
  * </details>
25
25
  * ```
26
26
  *
27
- * @param title - The title of the disclosure.
28
- * @param content - The content of the disclosure.
27
+ * @param title - The title of the disclosure (text only or markdown heading: `# heading`).
28
+ * @param content - The content of the disclosure (can include markdown).
29
29
  * @param options - The options for the disclosure.
30
30
  */
31
31
  export declare function disclosure(title: string, content: string, options?: DisclosureOptions): string;
@@ -1,4 +1,3 @@
1
- export { joinBlocks, joinLines } from './join';
2
1
  export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';
3
2
  export { code, italic, bold, link, image } from './inline';
4
3
  export { table } from './table';
@@ -17,7 +17,7 @@ export declare function bold(text: string): string;
17
17
  /**
18
18
  * Create a code text.
19
19
  *
20
- * Markdown: `\`text\``
20
+ * Markdown: `code`
21
21
  *
22
22
  * @param text - The text to be marked as code.
23
23
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-markdown-builder",
3
- "version": "0.2.2",
3
+ "version": "0.3.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",
@@ -24,12 +24,12 @@
24
24
  "typecheck": "tsc --noEmit",
25
25
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
26
26
  "clean": "del-cli dist",
27
- "release": "release-it",
28
- "release:beta": "release-it --preRelease=beta",
29
- "build": "yarn clean && yarn build:commonjs && yarn build:esm && yarn build:typescript",
27
+ "build": "yarn clean && yarn build:commonjs && yarn build:esm && yarn build:types",
30
28
  "build:commonjs": "BABEL_ENV=cjs babel src --out-dir \"dist/commonjs\" --extensions .js,.ts --out-file-extension .js --source-maps --no-comments",
31
29
  "build:esm": "BABEL_ENV=esm babel src --out-dir \"dist/esm\" --extensions .js,.ts --out-file-extension .mjs --source-maps --no-comments",
32
- "build:typescript": "tsc --project tsconfig.release.json --outDir \"dist/types\""
30
+ "build:types": "tsc --project tsconfig.release.json --outDir \"dist/types\"",
31
+ "release": "release-it",
32
+ "release:beta": "release-it --preRelease=beta"
33
33
  },
34
34
  "keywords": [
35
35
  "markdown",
@@ -84,6 +84,15 @@
84
84
  ]
85
85
  },
86
86
  "release-it": {
87
+ "hooks": {
88
+ "before:init": [
89
+ "yarn typecheck",
90
+ "yarn test",
91
+ "yarn lint"
92
+ ],
93
+ "after:bump": "yarn build",
94
+ "after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
95
+ },
87
96
  "git": {
88
97
  "commitMessage": "chore: release ${version}",
89
98
  "tagName": "v${version}"
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- exports.joinBlocks = joinBlocks;
4
- exports.joinLines = joinLines;
5
- var _html = require("./html.js");
6
- function joinBlocks(blocks) {
7
- return blocks.filter(Boolean).map(trimBlock).join('\n\n');
8
- }
9
- function joinLines(lines) {
10
- return lines.filter(Boolean).join(_html.lineBreak);
11
- }
12
- function trimBlock(block) {
13
- return block.replace(/^\n+|\n+$/g, '');
14
- }
15
- //# sourceMappingURL=join.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"join.js","names":["joinBlocks","blocks","filter","Boolean","map","trimBlock","join","joinLines","lines","lineBreak","block","replace"],"sources":["../../src/join.ts"],"sourcesContent":["import { lineBreak } from './html';\n\n/**\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: readonly string[]): string {\n return blocks.filter(Boolean).map(trimBlock).join('\\n\\n');\n}\n\n/**\n * Join lines of text into a single paragraph string with line breaks.\n *\n * @param lines - The lines of text to join.\n * @returns Paragraph string.\n */\nexport function joinLines(lines: string[]) {\n return lines.filter(Boolean).join(lineBreak);\n}\n\nfunction trimBlock(block: string): string {\n return block.replace(/^\\n+|\\n+$/g, '');\n}\n"],"mappings":";;;;;AAQO,SAASA,UAAUA,CAACC,MAAyB,EAAU;EAC5D,OAAOA,MAAM,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,GAAG,CAACC,SAAS,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;AAC3D;AAQO,SAASC,SAASA,CAACC,KAAe,EAAE;EACzC,OAAOA,KAAK,CAACN,MAAM,CAACC,OAAO,CAAC,CAACG,IAAI,CAACG,eAAS,CAAC;AAC9C;AAEA,SAASJ,SAASA,CAACK,KAAa,EAAU;EACxC,OAAOA,KAAK,CAACC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACxC","ignoreList":[]}
package/dist/esm/join.mjs DELETED
@@ -1,11 +0,0 @@
1
- import { lineBreak } from "./html.mjs";
2
- export function joinBlocks(blocks) {
3
- return blocks.filter(Boolean).map(trimBlock).join('\n\n');
4
- }
5
- export function joinLines(lines) {
6
- return lines.filter(Boolean).join(lineBreak);
7
- }
8
- function trimBlock(block) {
9
- return block.replace(/^\n+|\n+$/g, '');
10
- }
11
- //# sourceMappingURL=join.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"join.mjs","names":["lineBreak","joinBlocks","blocks","filter","Boolean","map","trimBlock","join","joinLines","lines","block","replace"],"sources":["../../src/join.ts"],"sourcesContent":["import { lineBreak } from './html';\n\n/**\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: readonly string[]): string {\n return blocks.filter(Boolean).map(trimBlock).join('\\n\\n');\n}\n\n/**\n * Join lines of text into a single paragraph string with line breaks.\n *\n * @param lines - The lines of text to join.\n * @returns Paragraph string.\n */\nexport function joinLines(lines: string[]) {\n return lines.filter(Boolean).join(lineBreak);\n}\n\nfunction trimBlock(block: string): string {\n return block.replace(/^\\n+|\\n+$/g, '');\n}\n"],"mappings":"SAASA,SAAS;AAQlB,OAAO,SAASC,UAAUA,CAACC,MAAyB,EAAU;EAC5D,OAAOA,MAAM,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,GAAG,CAACC,SAAS,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;AAC3D;AAQA,OAAO,SAASC,SAASA,CAACC,KAAe,EAAE;EACzC,OAAOA,KAAK,CAACN,MAAM,CAACC,OAAO,CAAC,CAACG,IAAI,CAACP,SAAS,CAAC;AAC9C;AAEA,SAASM,SAASA,CAACI,KAAa,EAAU;EACxC,OAAOA,KAAK,CAACC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACxC","ignoreList":[]}
@@ -1,14 +0,0 @@
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: readonly string[]): string;
8
- /**
9
- * Join lines of text into a single paragraph string with line breaks.
10
- *
11
- * @param lines - The lines of text to join.
12
- * @returns Paragraph string.
13
- */
14
- export declare function joinLines(lines: string[]): string;