ts-markdown-builder 0.4.0 → 0.4.1

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
@@ -27,7 +27,7 @@ npm install ts-markdown-builder
27
27
  ```js
28
28
  import * as md from 'ts-markdown-builder';
29
29
 
30
- const output = [
30
+ const output = joinBlocks([
31
31
  md.heading('Welcome to TS Markdown Builder'),
32
32
  "It's an easy to use modern markdown generator.",
33
33
  'It supports:',
@@ -38,7 +38,7 @@ const output = [
38
38
  'blockquotes',
39
39
  'and more!',
40
40
  ]),
41
- ].join('\n\n');
41
+ ]);
42
42
  ```
43
43
 
44
44
  ```markdown
@@ -55,6 +55,38 @@ It supports:
55
55
  - and more!
56
56
  ```
57
57
 
58
+ ## Functions
59
+
60
+ ### Utils
61
+
62
+ - `joinBlocks(blocks: string[])` - join blocks of text into a single markdown document (string)
63
+
64
+ ### Block
65
+ - `heading(text: string, options?: { level: number = 1 })`
66
+ - `blockquote(text: string | string[])`
67
+ - `codeBlock(text: string)`
68
+ - `list(items: string[])`
69
+ - `orderedList(items: string[])`
70
+ - `horizontalRule`
71
+
72
+ ### Inline
73
+
74
+ - `bold(text: string)`
75
+ - `italic(text: string)`
76
+ - `code(text: string)`
77
+ - `link(url: string, text?: string)` - link or autolink
78
+ - `image(url: string, text?: string)`
79
+ - `escape(text: string)`
80
+
81
+ ### Table
82
+
83
+ - `table(headers: string[], rows: string[][])`
84
+
85
+ ### HTML
86
+
87
+ - `disclosure(title: string, content: string, options?: { open?: boolean })`
88
+ - `lineBreak`
89
+
58
90
  ## Contributing
59
91
 
60
92
  See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
@@ -16,7 +16,8 @@ function blockquote(content) {
16
16
  return (0, _utils.prefixLines)((0, _utils.joinBlocks)(content), '> ');
17
17
  }
18
18
  function codeBlock(content) {
19
- return `\`\`\`\n${content}\n\`\`\``;
19
+ const backticks = Math.max((0, _utils.maxBackticks)(content), 2) + 1;
20
+ return '`'.repeat(backticks) + '\n' + content + '\n' + '`'.repeat(backticks);
20
21
  }
21
22
  function list(items) {
22
23
  return items.map(item => `- ${item}`).join('\n');
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"file":"block.js","names":["horizontalRule","exports","heading","text","options","level","repeat","blockquote","content","prefixLines","joinBlocks","codeBlock","backticks","Math","max","maxBackticks","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { joinBlocks, maxBackticks, 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 * Content\n * ```\n *\n * @param content - The content of the code block.\n */\nexport function codeBlock(content: string): string {\n const backticks = Math.max(maxBackticks(content), 2) + 1;\n return '`'.repeat(backticks) + '\\n' + content + '\\n' + '`'.repeat(backticks);\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;AAYO,SAASG,SAASA,CAACH,OAAe,EAAU;EACjD,MAAMI,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,IAAAC,mBAAY,EAACP,OAAO,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC;EACxD,OAAO,GAAG,CAACF,MAAM,CAACM,SAAS,CAAC,GAAG,IAAI,GAAGJ,OAAO,GAAG,IAAI,GAAG,GAAG,CAACF,MAAM,CAACM,SAAS,CAAC;AAC9E;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":[]}
@@ -30,6 +30,12 @@ Object.defineProperty(exports, "disclosure", {
30
30
  return _html.disclosure;
31
31
  }
32
32
  });
33
+ Object.defineProperty(exports, "escape", {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _utils.escape;
37
+ }
38
+ });
33
39
  Object.defineProperty(exports, "heading", {
34
40
  enumerable: true,
35
41
  get: function () {
@@ -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';\nexport { joinBlocks } from './utils';\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 { escape, joinBlocks } from './utils';\n\nexport type { TableOptions } from './table';\nexport type { DisclosureOptions } from './html';\n"],"mappings":"","ignoreList":[]}
@@ -5,6 +5,7 @@ exports.code = code;
5
5
  exports.image = image;
6
6
  exports.italic = italic;
7
7
  exports.link = link;
8
+ var _utils = require("./utils.js");
8
9
  function italic(text) {
9
10
  return `*${text}*`;
10
11
  }
@@ -12,7 +13,11 @@ function bold(text) {
12
13
  return `**${text}**`;
13
14
  }
14
15
  function code(text) {
15
- return `\`${text}\``;
16
+ const backticksCount = (0, _utils.maxBackticks)(text) + 1;
17
+ const backticks = '`'.repeat(backticksCount);
18
+ const frontPadding = text.startsWith('`') ? ' ' : '';
19
+ const backPadding = text.endsWith('`') ? ' ' : '';
20
+ return `${backticks}${frontPadding}${text}${backPadding}${backticks}`;
16
21
  }
17
22
  function link(url, text) {
18
23
  return text ? `[${text}](${url})` : `<${url}>`;
@@ -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: `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
+ {"version":3,"file":"inline.js","names":["italic","text","bold","code","backticksCount","maxBackticks","backticks","repeat","frontPadding","startsWith","backPadding","endsWith","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["import { maxBackticks } from './utils';\n\n/**\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 const backticksCount = maxBackticks(text) + 1;\n const backticks = '`'.repeat(backticksCount);\n const frontPadding = text.startsWith('`') ? ' ' : '';\n const backPadding = text.endsWith('`') ? ' ' : '';\n return `${backticks}${frontPadding}${text}${backPadding}${backticks}`;\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":";;;;;;;;AASO,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,MAAMG,cAAc,GAAG,IAAAC,mBAAY,EAACJ,IAAI,CAAC,GAAG,CAAC;EAC7C,MAAMK,SAAS,GAAG,GAAG,CAACC,MAAM,CAACH,cAAc,CAAC;EAC5C,MAAMI,YAAY,GAAGP,IAAI,CAACQ,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE;EACpD,MAAMC,WAAW,GAAGT,IAAI,CAACU,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE;EACjD,OAAO,GAAGL,SAAS,GAAGE,YAAY,GAAGP,IAAI,GAAGS,WAAW,GAAGJ,SAAS,EAAE;AACvE;AAYO,SAASM,IAAIA,CAACC,GAAW,EAAEZ,IAAa,EAAU;EACvD,OAAOA,IAAI,GAAG,IAAIA,IAAI,KAAKY,GAAG,GAAG,GAAG,IAAIA,GAAG,GAAG;AAChD;AAUO,SAASC,KAAKA,CAACD,GAAW,EAAEZ,IAAa,EAAU;EACxD,OAAO,KAAKA,IAAI,IAAI,EAAE,KAAKY,GAAG,GAAG;AACnC","ignoreList":[]}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
+ exports.escape = escape;
3
4
  exports.joinBlocks = joinBlocks;
5
+ exports.maxBackticks = maxBackticks;
4
6
  exports.prefixLines = prefixLines;
5
7
  function joinBlocks(blocks) {
6
8
  blocks = typeof blocks === 'string' ? [blocks] : blocks;
@@ -13,4 +15,20 @@ function prefixLines(text, prefix) {
13
15
  const lines = text.split('\n');
14
16
  return lines.map(line => `${prefix}${line}`).join('\n');
15
17
  }
18
+ function escape(text) {
19
+ return text.replace(/([\\`*_{}[\]()#+\-.!|<>])/g, '\\$1');
20
+ }
21
+ function maxBackticks(text) {
22
+ let max = 0;
23
+ let current = 0;
24
+ for (let i = 0; i < text.length; i++) {
25
+ if (text[i] === '`') {
26
+ current++;
27
+ max = Math.max(max, current);
28
+ } else {
29
+ current = 0;
30
+ }
31
+ }
32
+ return max;
33
+ }
16
34
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"utils.js","names":["joinBlocks","blocks","map","trimBlock","filter","Boolean","join","block","replace","prefixLines","text","prefix","lines","split","line","escape","maxBackticks","max","current","i","length","Math"],"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\nexport function escape(text: string): string {\n return text.replace(/([\\\\`*_{}[\\]()#+\\-.!|<>])/g, '\\\\$1');\n}\n\nexport function maxBackticks(text: string): number {\n let max = 0;\n let current = 0;\n\n for (let i = 0; i < text.length; i++) {\n if (text[i] === '`') {\n current++;\n max = Math.max(max, current);\n } else {\n current = 0;\n }\n }\n\n return max;\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;AAEO,SAASS,MAAMA,CAACL,IAAY,EAAU;EAC3C,OAAOA,IAAI,CAACF,OAAO,CAAC,4BAA4B,EAAE,MAAM,CAAC;AAC3D;AAEO,SAASQ,YAAYA,CAACN,IAAY,EAAU;EACjD,IAAIO,GAAG,GAAG,CAAC;EACX,IAAIC,OAAO,GAAG,CAAC;EAEf,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGT,IAAI,CAACU,MAAM,EAAED,CAAC,EAAE,EAAE;IACpC,IAAIT,IAAI,CAACS,CAAC,CAAC,KAAK,GAAG,EAAE;MACnBD,OAAO,EAAE;MACTD,GAAG,GAAGI,IAAI,CAACJ,GAAG,CAACA,GAAG,EAAEC,OAAO,CAAC;IAC9B,CAAC,MAAM;MACLA,OAAO,GAAG,CAAC;IACb;EACF;EAEA,OAAOD,GAAG;AACZ","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { joinBlocks, prefixLines } from "./utils.mjs";
1
+ import { joinBlocks, maxBackticks, prefixLines } from "./utils.mjs";
2
2
  export const horizontalRule = '---';
3
3
  export function heading(text, options) {
4
4
  const level = options?.level ?? 1;
@@ -8,7 +8,8 @@ export function blockquote(content) {
8
8
  return prefixLines(joinBlocks(content), '> ');
9
9
  }
10
10
  export function codeBlock(content) {
11
- return `\`\`\`\n${content}\n\`\`\``;
11
+ const backticks = Math.max(maxBackticks(content), 2) + 1;
12
+ return '`'.repeat(backticks) + '\n' + content + '\n' + '`'.repeat(backticks);
12
13
  }
13
14
  export function list(items) {
14
15
  return items.map(item => `- ${item}`).join('\n');
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"file":"block.mjs","names":["joinBlocks","maxBackticks","prefixLines","horizontalRule","heading","text","options","level","repeat","blockquote","content","codeBlock","backticks","Math","max","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { joinBlocks, maxBackticks, 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 * Content\n * ```\n *\n * @param content - The content of the code block.\n */\nexport function codeBlock(content: string): string {\n const backticks = Math.max(maxBackticks(content), 2) + 1;\n return '`'.repeat(backticks) + '\\n' + content + '\\n' + '`'.repeat(backticks);\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,YAAY,EAAEC,WAAW;AAO9C,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,CAACF,UAAU,CAACU,OAAO,CAAC,EAAE,IAAI,CAAC;AAC/C;AAYA,OAAO,SAASC,SAASA,CAACD,OAAe,EAAU;EACjD,MAAME,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACb,YAAY,CAACS,OAAO,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC;EACxD,OAAO,GAAG,CAACF,MAAM,CAACI,SAAS,CAAC,GAAG,IAAI,GAAGF,OAAO,GAAG,IAAI,GAAG,GAAG,CAACF,MAAM,CAACI,SAAS,CAAC;AAC9E;AAaA,OAAO,SAASG,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,5 +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
+ export { escape, joinBlocks } from "./utils.mjs";
6
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","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
+ {"version":3,"file":"index.mjs","names":["horizontalRule","heading","blockquote","orderedList","list","codeBlock","code","italic","bold","link","image","table","lineBreak","disclosure","escape","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 { escape, 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,MAAM,EAAEC,UAAU","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ import { maxBackticks } from "./utils.mjs";
1
2
  export function italic(text) {
2
3
  return `*${text}*`;
3
4
  }
@@ -5,7 +6,11 @@ export function bold(text) {
5
6
  return `**${text}**`;
6
7
  }
7
8
  export function code(text) {
8
- return `\`${text}\``;
9
+ const backticksCount = maxBackticks(text) + 1;
10
+ const backticks = '`'.repeat(backticksCount);
11
+ const frontPadding = text.startsWith('`') ? ' ' : '';
12
+ const backPadding = text.endsWith('`') ? ' ' : '';
13
+ return `${backticks}${frontPadding}${text}${backPadding}${backticks}`;
9
14
  }
10
15
  export function link(url, text) {
11
16
  return text ? `[${text}](${url})` : `<${url}>`;
@@ -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: `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":[]}
1
+ {"version":3,"file":"inline.mjs","names":["maxBackticks","italic","text","bold","code","backticksCount","backticks","repeat","frontPadding","startsWith","backPadding","endsWith","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["import { maxBackticks } from './utils';\n\n/**\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 const backticksCount = maxBackticks(text) + 1;\n const backticks = '`'.repeat(backticksCount);\n const frontPadding = text.startsWith('`') ? ' ' : '';\n const backPadding = text.endsWith('`') ? ' ' : '';\n return `${backticks}${frontPadding}${text}${backPadding}${backticks}`;\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":"SAASA,YAAY;AASrB,OAAO,SAASC,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,MAAMG,cAAc,GAAGL,YAAY,CAACE,IAAI,CAAC,GAAG,CAAC;EAC7C,MAAMI,SAAS,GAAG,GAAG,CAACC,MAAM,CAACF,cAAc,CAAC;EAC5C,MAAMG,YAAY,GAAGN,IAAI,CAACO,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE;EACpD,MAAMC,WAAW,GAAGR,IAAI,CAACS,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE;EACjD,OAAO,GAAGL,SAAS,GAAGE,YAAY,GAAGN,IAAI,GAAGQ,WAAW,GAAGJ,SAAS,EAAE;AACvE;AAYA,OAAO,SAASM,IAAIA,CAACC,GAAW,EAAEX,IAAa,EAAU;EACvD,OAAOA,IAAI,GAAG,IAAIA,IAAI,KAAKW,GAAG,GAAG,GAAG,IAAIA,GAAG,GAAG;AAChD;AAUA,OAAO,SAASC,KAAKA,CAACD,GAAW,EAAEX,IAAa,EAAU;EACxD,OAAO,KAAKA,IAAI,IAAI,EAAE,KAAKW,GAAG,GAAG;AACnC","ignoreList":[]}
@@ -9,4 +9,20 @@ export function prefixLines(text, prefix) {
9
9
  const lines = text.split('\n');
10
10
  return lines.map(line => `${prefix}${line}`).join('\n');
11
11
  }
12
+ export function escape(text) {
13
+ return text.replace(/([\\`*_{}[\]()#+\-.!|<>])/g, '\\$1');
14
+ }
15
+ export function maxBackticks(text) {
16
+ let max = 0;
17
+ let current = 0;
18
+ for (let i = 0; i < text.length; i++) {
19
+ if (text[i] === '`') {
20
+ current++;
21
+ max = Math.max(max, current);
22
+ } else {
23
+ current = 0;
24
+ }
25
+ }
26
+ return max;
27
+ }
12
28
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"file":"utils.mjs","names":["joinBlocks","blocks","map","trimBlock","filter","Boolean","join","block","replace","prefixLines","text","prefix","lines","split","line","escape","maxBackticks","max","current","i","length","Math"],"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\nexport function escape(text: string): string {\n return text.replace(/([\\\\`*_{}[\\]()#+\\-.!|<>])/g, '\\\\$1');\n}\n\nexport function maxBackticks(text: string): number {\n let max = 0;\n let current = 0;\n\n for (let i = 0; i < text.length; i++) {\n if (text[i] === '`') {\n current++;\n max = Math.max(max, current);\n } else {\n current = 0;\n }\n }\n\n return max;\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;AAEA,OAAO,SAASS,MAAMA,CAACL,IAAY,EAAU;EAC3C,OAAOA,IAAI,CAACF,OAAO,CAAC,4BAA4B,EAAE,MAAM,CAAC;AAC3D;AAEA,OAAO,SAASQ,YAAYA,CAACN,IAAY,EAAU;EACjD,IAAIO,GAAG,GAAG,CAAC;EACX,IAAIC,OAAO,GAAG,CAAC;EAEf,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGT,IAAI,CAACU,MAAM,EAAED,CAAC,EAAE,EAAE;IACpC,IAAIT,IAAI,CAACS,CAAC,CAAC,KAAK,GAAG,EAAE;MACnBD,OAAO,EAAE;MACTD,GAAG,GAAGI,IAAI,CAACJ,GAAG,CAACA,GAAG,EAAEC,OAAO,CAAC;IAC9B,CAAC,MAAM;MACLA,OAAO,GAAG,CAAC;IACb;EACF;EAEA,OAAOD,GAAG;AACZ","ignoreList":[]}
@@ -31,11 +31,9 @@ export declare function blockquote(content: string | readonly string[]): string;
31
31
  * Create a code block.
32
32
  *
33
33
  * Markdown:
34
- * ````
35
34
  * ```
36
35
  * Content
37
36
  * ```
38
- * ````
39
37
  *
40
38
  * @param content - The content of the code block.
41
39
  */
@@ -2,6 +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
+ export { escape, joinBlocks } from './utils';
6
6
  export type { TableOptions } from './table';
7
7
  export type { DisclosureOptions } from './html';
@@ -6,3 +6,5 @@
6
6
  */
7
7
  export declare function joinBlocks(blocks: string | readonly string[]): string;
8
8
  export declare function prefixLines(text: string, prefix: string): string;
9
+ export declare function escape(text: string): string;
10
+ export declare function maxBackticks(text: string): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-markdown-builder",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Elegant markdown builder with minimal bundle size.",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "module": "dist/esm/index.mjs",