ts-markdown-builder 0.4.1 → 0.6.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
@@ -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 = joinBlocks([
30
+ const output = md.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:',
@@ -59,33 +59,35 @@ It supports:
59
59
 
60
60
  ### Utils
61
61
 
62
- - `joinBlocks(blocks: string[])` - join blocks of text into a single markdown document (string)
62
+ - [`joinBlocks(blocks: string[])`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#joinblocks) - join blocks of text into a single markdown document (string)
63
63
 
64
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`
65
+ - [`heading(text: string, options?: { level: number = 1 })`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#heading)
66
+ - [`blockquote(text: string | string[])`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#blockquote)
67
+ - [`codeBlock(text: string, options?: { language?: string = '' })`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#codeblock)
68
+ - [`list(items: string[])`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#list)
69
+ - [`orderedList(items: string[])`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#orderedlist)
70
+ - [`taskList(items: (string | TaskListItem)[])`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#tasklist) - GFM task list with checkboxes (items can be strings or `{ text: string, done?: boolean }`)
71
+ - [`horizontalRule`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#horizontalrule)
71
72
 
72
73
  ### Inline
73
74
 
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)`
75
+ - [`bold(text: string)`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#bold)
76
+ - [`italic(text: string)`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#italic)
77
+ - [`strikethrough(text: string)`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#strikethrough) - GFM strikethrough
78
+ - [`code(text: string)`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#code)
79
+ - [`link(url: string, text?: string)`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#link) - link or autolink
80
+ - [`image(url: string, text?: string)`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#image)
81
+ - [`escape(text: string)`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#escape)
80
82
 
81
83
  ### Table
82
84
 
83
- - `table(headers: string[], rows: string[][])`
85
+ - [`table(headers: string[], rows: string[][])`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#table)
84
86
 
85
87
  ### HTML
86
88
 
87
- - `disclosure(title: string, content: string, options?: { open?: boolean })`
88
- - `lineBreak`
89
+ - [`disclosure(title: string, content: string, options?: { open?: boolean })`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#disclosure)
90
+ - [`lineBreak`](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md#linebreak)
89
91
 
90
92
  ## Contributing
91
93
 
@@ -97,4 +99,4 @@ MIT
97
99
 
98
100
  ## Reference
99
101
 
100
- TODO
102
+ See the full [API Reference](https://github.com/mdjastrzebski/ts-markdown-builder/blob/main/API.md) for detailed documentation, parameter descriptions, and usage examples.
@@ -6,6 +6,7 @@ exports.heading = heading;
6
6
  exports.horizontalRule = void 0;
7
7
  exports.list = list;
8
8
  exports.orderedList = orderedList;
9
+ exports.taskList = taskList;
9
10
  var _utils = require("./utils.js");
10
11
  const horizontalRule = exports.horizontalRule = '---';
11
12
  function heading(text, options) {
@@ -15,9 +16,10 @@ function heading(text, options) {
15
16
  function blockquote(content) {
16
17
  return (0, _utils.prefixLines)((0, _utils.joinBlocks)(content), '> ');
17
18
  }
18
- function codeBlock(content) {
19
+ function codeBlock(content, options) {
20
+ const language = options?.language ?? '';
19
21
  const backticks = Math.max((0, _utils.maxBackticks)(content), 2) + 1;
20
- return '`'.repeat(backticks) + '\n' + content + '\n' + '`'.repeat(backticks);
22
+ return '`'.repeat(backticks) + language + '\n' + content + '\n' + '`'.repeat(backticks);
21
23
  }
22
24
  function list(items) {
23
25
  return items.map(item => `- ${item}`).join('\n');
@@ -25,4 +27,13 @@ function list(items) {
25
27
  function orderedList(items) {
26
28
  return items.map((item, index) => `${index + 1}. ${item}`).join('\n');
27
29
  }
30
+ function taskList(items) {
31
+ const result = [];
32
+ for (const item of items) {
33
+ const text = typeof item === 'string' ? item : item.text;
34
+ const done = typeof item === 'string' ? false : item.done;
35
+ result.push(`- [${done ? 'x' : ' '}] ${text}`);
36
+ }
37
+ return result.join('\n');
38
+ }
28
39
  //# sourceMappingURL=block.js.map
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"file":"block.js","names":["horizontalRule","exports","heading","text","options","level","repeat","blockquote","content","prefixLines","joinBlocks","codeBlock","language","backticks","Math","max","maxBackticks","list","items","map","item","join","orderedList","index","taskList","result","done","push"],"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\ntype CodeBlockOptions = {\n language?: string;\n};\n\n/**\n * Create a code block.\n *\n * Markdown:\n * ```js\n * Content\n * ```\n *\n * @param content - The content of the code block.\n * @param language - The language of the code block.\n */\nexport function codeBlock(content: string, options?: CodeBlockOptions): string {\n const language = options?.language ?? '';\n const backticks = Math.max(maxBackticks(content), 2) + 1;\n return '`'.repeat(backticks) + language + '\\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\nexport type TaskListItem = {\n text: string;\n done?: boolean;\n};\n\n/**\n * Create a task list block.\n *\n * Markdown:\n * ```\n * - [x] Done item\n * - [ ] Pending item\n * ```\n *\n * @param items - The items of the task list.\n */\nexport function taskList(items: readonly (string | TaskListItem)[]): string {\n const result = [];\n for (const item of items) {\n const text = typeof item === 'string' ? item : item.text;\n const done = typeof item === 'string' ? false : item.done;\n result.push(`- [${done ? 'x' : ' '}] ${text}`);\n }\n\n return result.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;AAiBO,SAASG,SAASA,CAACH,OAAe,EAAEJ,OAA0B,EAAU;EAC7E,MAAMQ,QAAQ,GAAGR,OAAO,EAAEQ,QAAQ,IAAI,EAAE;EACxC,MAAMC,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,IAAAC,mBAAY,EAACR,OAAO,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC;EACxD,OAAO,GAAG,CAACF,MAAM,CAACO,SAAS,CAAC,GAAGD,QAAQ,GAAG,IAAI,GAAGJ,OAAO,GAAG,IAAI,GAAG,GAAG,CAACF,MAAM,CAACO,SAAS,CAAC;AACzF;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;AAkBO,SAASG,QAAQA,CAACN,KAAyC,EAAU;EAC1E,MAAMO,MAAM,GAAG,EAAE;EACjB,KAAK,MAAML,IAAI,IAAIF,KAAK,EAAE;IACxB,MAAMf,IAAI,GAAG,OAAOiB,IAAI,KAAK,QAAQ,GAAGA,IAAI,GAAGA,IAAI,CAACjB,IAAI;IACxD,MAAMuB,IAAI,GAAG,OAAON,IAAI,KAAK,QAAQ,GAAG,KAAK,GAAGA,IAAI,CAACM,IAAI;IACzDD,MAAM,CAACE,IAAI,CAAC,MAAMD,IAAI,GAAG,GAAG,GAAG,GAAG,KAAKvB,IAAI,EAAE,CAAC;EAChD;EAEA,OAAOsB,MAAM,CAACJ,IAAI,CAAC,IAAI,CAAC;AAC1B","ignoreList":[]}
@@ -90,12 +90,24 @@ Object.defineProperty(exports, "orderedList", {
90
90
  return _block.orderedList;
91
91
  }
92
92
  });
93
+ Object.defineProperty(exports, "strikethrough", {
94
+ enumerable: true,
95
+ get: function () {
96
+ return _inline.strikethrough;
97
+ }
98
+ });
93
99
  Object.defineProperty(exports, "table", {
94
100
  enumerable: true,
95
101
  get: function () {
96
102
  return _table.table;
97
103
  }
98
104
  });
105
+ Object.defineProperty(exports, "taskList", {
106
+ enumerable: true,
107
+ get: function () {
108
+ return _block.taskList;
109
+ }
110
+ });
99
111
  var _block = require("./block.js");
100
112
  var _inline = require("./inline.js");
101
113
  var _table = require("./table.js");
@@ -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 { escape, 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 {\n horizontalRule,\n heading,\n blockquote,\n orderedList,\n list,\n codeBlock,\n taskList,\n} from './block';\nexport { code, italic, bold, strikethrough, 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';\nexport type { TaskListItem } from './block';\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
+ exports.strikethrough = strikethrough;
8
9
  var _utils = require("./utils.js");
9
10
  function italic(text) {
10
11
  return `*${text}*`;
@@ -12,6 +13,9 @@ function italic(text) {
12
13
  function bold(text) {
13
14
  return `**${text}**`;
14
15
  }
16
+ function strikethrough(text) {
17
+ return `~~${text}~~`;
18
+ }
15
19
  function code(text) {
16
20
  const backticksCount = (0, _utils.maxBackticks)(text) + 1;
17
21
  const backticks = '`'.repeat(backticksCount);
@@ -1 +1 @@
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
+ {"version":3,"file":"inline.js","names":["italic","text","bold","strikethrough","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 strikethrough text.\n *\n * Markdown: `~~text~~`\n *\n * @param text - The text to be struck through.\n */\nexport function strikethrough(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,aAAaA,CAACF,IAAY,EAAU;EAClD,OAAO,KAAKA,IAAI,IAAI;AACtB;AASO,SAASG,IAAIA,CAACH,IAAY,EAAU;EACzC,MAAMI,cAAc,GAAG,IAAAC,mBAAY,EAACL,IAAI,CAAC,GAAG,CAAC;EAC7C,MAAMM,SAAS,GAAG,GAAG,CAACC,MAAM,CAACH,cAAc,CAAC;EAC5C,MAAMI,YAAY,GAAGR,IAAI,CAACS,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE;EACpD,MAAMC,WAAW,GAAGV,IAAI,CAACW,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE;EACjD,OAAO,GAAGL,SAAS,GAAGE,YAAY,GAAGR,IAAI,GAAGU,WAAW,GAAGJ,SAAS,EAAE;AACvE;AAYO,SAASM,IAAIA,CAACC,GAAW,EAAEb,IAAa,EAAU;EACvD,OAAOA,IAAI,GAAG,IAAIA,IAAI,KAAKa,GAAG,GAAG,GAAG,IAAIA,GAAG,GAAG;AAChD;AAUO,SAASC,KAAKA,CAACD,GAAW,EAAEb,IAAa,EAAU;EACxD,OAAO,KAAKA,IAAI,IAAI,EAAE,KAAKa,GAAG,GAAG;AACnC","ignoreList":[]}
@@ -7,9 +7,10 @@ export function heading(text, options) {
7
7
  export function blockquote(content) {
8
8
  return prefixLines(joinBlocks(content), '> ');
9
9
  }
10
- export function codeBlock(content) {
10
+ export function codeBlock(content, options) {
11
+ const language = options?.language ?? '';
11
12
  const backticks = Math.max(maxBackticks(content), 2) + 1;
12
- return '`'.repeat(backticks) + '\n' + content + '\n' + '`'.repeat(backticks);
13
+ return '`'.repeat(backticks) + language + '\n' + content + '\n' + '`'.repeat(backticks);
13
14
  }
14
15
  export function list(items) {
15
16
  return items.map(item => `- ${item}`).join('\n');
@@ -17,4 +18,13 @@ export function list(items) {
17
18
  export function orderedList(items) {
18
19
  return items.map((item, index) => `${index + 1}. ${item}`).join('\n');
19
20
  }
21
+ export function taskList(items) {
22
+ const result = [];
23
+ for (const item of items) {
24
+ const text = typeof item === 'string' ? item : item.text;
25
+ const done = typeof item === 'string' ? false : item.done;
26
+ result.push(`- [${done ? 'x' : ' '}] ${text}`);
27
+ }
28
+ return result.join('\n');
29
+ }
20
30
  //# sourceMappingURL=block.mjs.map
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"file":"block.mjs","names":["joinBlocks","maxBackticks","prefixLines","horizontalRule","heading","text","options","level","repeat","blockquote","content","codeBlock","language","backticks","Math","max","list","items","map","item","join","orderedList","index","taskList","result","done","push"],"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\ntype CodeBlockOptions = {\n language?: string;\n};\n\n/**\n * Create a code block.\n *\n * Markdown:\n * ```js\n * Content\n * ```\n *\n * @param content - The content of the code block.\n * @param language - The language of the code block.\n */\nexport function codeBlock(content: string, options?: CodeBlockOptions): string {\n const language = options?.language ?? '';\n const backticks = Math.max(maxBackticks(content), 2) + 1;\n return '`'.repeat(backticks) + language + '\\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\nexport type TaskListItem = {\n text: string;\n done?: boolean;\n};\n\n/**\n * Create a task list block.\n *\n * Markdown:\n * ```\n * - [x] Done item\n * - [ ] Pending item\n * ```\n *\n * @param items - The items of the task list.\n */\nexport function taskList(items: readonly (string | TaskListItem)[]): string {\n const result = [];\n for (const item of items) {\n const text = typeof item === 'string' ? item : item.text;\n const done = typeof item === 'string' ? false : item.done;\n result.push(`- [${done ? 'x' : ' '}] ${text}`);\n }\n\n return result.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;AAiBA,OAAO,SAASC,SAASA,CAACD,OAAe,EAAEJ,OAA0B,EAAU;EAC7E,MAAMM,QAAQ,GAAGN,OAAO,EAAEM,QAAQ,IAAI,EAAE;EACxC,MAAMC,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACd,YAAY,CAACS,OAAO,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC;EACxD,OAAO,GAAG,CAACF,MAAM,CAACK,SAAS,CAAC,GAAGD,QAAQ,GAAG,IAAI,GAAGF,OAAO,GAAG,IAAI,GAAG,GAAG,CAACF,MAAM,CAACK,SAAS,CAAC;AACzF;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;AAkBA,OAAO,SAASG,QAAQA,CAACN,KAAyC,EAAU;EAC1E,MAAMO,MAAM,GAAG,EAAE;EACjB,KAAK,MAAML,IAAI,IAAIF,KAAK,EAAE;IACxB,MAAMZ,IAAI,GAAG,OAAOc,IAAI,KAAK,QAAQ,GAAGA,IAAI,GAAGA,IAAI,CAACd,IAAI;IACxD,MAAMoB,IAAI,GAAG,OAAON,IAAI,KAAK,QAAQ,GAAG,KAAK,GAAGA,IAAI,CAACM,IAAI;IACzDD,MAAM,CAACE,IAAI,CAAC,MAAMD,IAAI,GAAG,GAAG,GAAG,GAAG,KAAKpB,IAAI,EAAE,CAAC;EAChD;EAEA,OAAOmB,MAAM,CAACJ,IAAI,CAAC,IAAI,CAAC;AAC1B","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from "./block.mjs";
2
- export { code, italic, bold, link, image } from "./inline.mjs";
1
+ export { horizontalRule, heading, blockquote, orderedList, list, codeBlock, taskList } from "./block.mjs";
2
+ export { code, italic, bold, strikethrough, link, image } from "./inline.mjs";
3
3
  export { table } from "./table.mjs";
4
4
  export { lineBreak, disclosure } from "./html.mjs";
5
5
  export { escape, joinBlocks } from "./utils.mjs";
@@ -1 +1 @@
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
+ {"version":3,"file":"index.mjs","names":["horizontalRule","heading","blockquote","orderedList","list","codeBlock","taskList","code","italic","bold","strikethrough","link","image","table","lineBreak","disclosure","escape","joinBlocks"],"sources":["../../src/index.ts"],"sourcesContent":["export {\n horizontalRule,\n heading,\n blockquote,\n orderedList,\n list,\n codeBlock,\n taskList,\n} from './block';\nexport { code, italic, bold, strikethrough, 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';\nexport type { TaskListItem } from './block';\n"],"mappings":"SACEA,cAAc,EACdC,OAAO,EACPC,UAAU,EACVC,WAAW,EACXC,IAAI,EACJC,SAAS,EACTC,QAAQ;AAAA,SAEDC,IAAI,EAAEC,MAAM,EAAEC,IAAI,EAAEC,aAAa,EAAEC,IAAI,EAAEC,KAAK;AAAA,SAC9CC,KAAK;AAAA,SACLC,SAAS,EAAEC,UAAU;AAAA,SACrBC,MAAM,EAAEC,UAAU","ignoreList":[]}
@@ -5,6 +5,9 @@ export function italic(text) {
5
5
  export function bold(text) {
6
6
  return `**${text}**`;
7
7
  }
8
+ export function strikethrough(text) {
9
+ return `~~${text}~~`;
10
+ }
8
11
  export function code(text) {
9
12
  const backticksCount = maxBackticks(text) + 1;
10
13
  const backticks = '`'.repeat(backticksCount);
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"file":"inline.mjs","names":["maxBackticks","italic","text","bold","strikethrough","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 strikethrough text.\n *\n * Markdown: `~~text~~`\n *\n * @param text - The text to be struck through.\n */\nexport function strikethrough(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,aAAaA,CAACF,IAAY,EAAU;EAClD,OAAO,KAAKA,IAAI,IAAI;AACtB;AASA,OAAO,SAASG,IAAIA,CAACH,IAAY,EAAU;EACzC,MAAMI,cAAc,GAAGN,YAAY,CAACE,IAAI,CAAC,GAAG,CAAC;EAC7C,MAAMK,SAAS,GAAG,GAAG,CAACC,MAAM,CAACF,cAAc,CAAC;EAC5C,MAAMG,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;AAYA,OAAO,SAASM,IAAIA,CAACC,GAAW,EAAEZ,IAAa,EAAU;EACvD,OAAOA,IAAI,GAAG,IAAIA,IAAI,KAAKY,GAAG,GAAG,GAAG,IAAIA,GAAG,GAAG;AAChD;AAUA,OAAO,SAASC,KAAKA,CAACD,GAAW,EAAEZ,IAAa,EAAU;EACxD,OAAO,KAAKA,IAAI,IAAI,EAAE,KAAKY,GAAG,GAAG;AACnC","ignoreList":[]}
@@ -27,17 +27,21 @@ export declare function heading(text: string, options?: HeadingOptions): string;
27
27
  * @param text - The content of the blockquote.
28
28
  */
29
29
  export declare function blockquote(content: string | readonly string[]): string;
30
+ type CodeBlockOptions = {
31
+ language?: string;
32
+ };
30
33
  /**
31
34
  * Create a code block.
32
35
  *
33
36
  * Markdown:
34
- * ```
37
+ * ```js
35
38
  * Content
36
39
  * ```
37
40
  *
38
41
  * @param content - The content of the code block.
42
+ * @param language - The language of the code block.
39
43
  */
40
- export declare function codeBlock(content: string): string;
44
+ export declare function codeBlock(content: string, options?: CodeBlockOptions): string;
41
45
  /**
42
46
  * Create an unordered list block.
43
47
  *
@@ -62,4 +66,20 @@ export declare function list(items: readonly string[]): string;
62
66
  * @param items - The items of the list.
63
67
  */
64
68
  export declare function orderedList(items: readonly string[]): string;
69
+ export type TaskListItem = {
70
+ text: string;
71
+ done?: boolean;
72
+ };
73
+ /**
74
+ * Create a task list block.
75
+ *
76
+ * Markdown:
77
+ * ```
78
+ * - [x] Done item
79
+ * - [ ] Pending item
80
+ * ```
81
+ *
82
+ * @param items - The items of the task list.
83
+ */
84
+ export declare function taskList(items: readonly (string | TaskListItem)[]): string;
65
85
  export {};
@@ -1,7 +1,8 @@
1
- export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';
2
- export { code, italic, bold, link, image } from './inline';
1
+ export { horizontalRule, heading, blockquote, orderedList, list, codeBlock, taskList, } from './block';
2
+ export { code, italic, bold, strikethrough, link, image } from './inline';
3
3
  export { table } from './table';
4
4
  export { lineBreak, disclosure } from './html';
5
5
  export { escape, joinBlocks } from './utils';
6
6
  export type { TableOptions } from './table';
7
7
  export type { DisclosureOptions } from './html';
8
+ export type { TaskListItem } from './block';
@@ -14,6 +14,14 @@ export declare function italic(text: string): string;
14
14
  * @param text - The text to be bolded.
15
15
  */
16
16
  export declare function bold(text: string): string;
17
+ /**
18
+ * Create a strikethrough text.
19
+ *
20
+ * Markdown: `~~text~~`
21
+ *
22
+ * @param text - The text to be struck through.
23
+ */
24
+ export declare function strikethrough(text: string): string;
17
25
  /**
18
26
  * Create a code text.
19
27
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-markdown-builder",
3
- "version": "0.4.1",
3
+ "version": "0.6.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",
@@ -28,6 +28,10 @@
28
28
  "build:commonjs": "BABEL_ENV=cjs babel src --out-dir \"dist/commonjs\" --extensions .js,.ts --out-file-extension .js --source-maps --no-comments",
29
29
  "build:esm": "BABEL_ENV=esm babel src --out-dir \"dist/esm\" --extensions .js,.ts --out-file-extension .mjs --source-maps --no-comments",
30
30
  "build:types": "tsc --project tsconfig.release.json --outDir \"dist/types\"",
31
+ "format": "prettier --write \"**/*.{js,ts,tsx}\"",
32
+ "format:check": "prettier --check \"**/*.{js,ts,tsx}\"",
33
+ "validate": "yarn typecheck && yarn lint && yarn test && yarn format:check",
34
+ "validate:fix": "yarn format && yarn lint --fix && yarn typecheck && yarn test && yarn build",
31
35
  "release": "release-it",
32
36
  "release:beta": "release-it --preRelease=beta"
33
37
  },
@@ -46,29 +50,29 @@
46
50
  "registry": "https://registry.npmjs.org/"
47
51
  },
48
52
  "devDependencies": {
49
- "@babel/cli": "^7.24.8",
50
- "@babel/core": "^7.25.2",
51
- "@babel/plugin-syntax-flow": "^7.24.7",
52
- "@babel/plugin-transform-react-jsx": "^7.25.2",
53
- "@babel/preset-env": "^7.25.4",
54
- "@babel/preset-typescript": "^7.24.7",
53
+ "@babel/cli": "^7.28.3",
54
+ "@babel/core": "^7.28.3",
55
+ "@babel/plugin-syntax-flow": "^7.27.1",
56
+ "@babel/plugin-transform-react-jsx": "^7.27.1",
57
+ "@babel/preset-env": "^7.28.3",
58
+ "@babel/preset-typescript": "^7.27.1",
55
59
  "@callstack/eslint-config": "^15.0.0",
56
- "@release-it/conventional-changelog": "^9.0.0",
57
- "@size-limit/preset-small-lib": "^11.1.6",
58
- "@types/jest": "^29.5.12",
60
+ "@release-it/conventional-changelog": "^10.0.1",
61
+ "@size-limit/preset-small-lib": "^11.2.0",
62
+ "@types/jest": "^30.0.0",
59
63
  "babel-plugin-add-import-extension": "^1.6.0",
60
64
  "del-cli": "^6.0.0",
61
- "eslint": "^8.57.0",
62
- "eslint-config-prettier": "^8.10.0",
65
+ "eslint": "^8.57.1",
66
+ "eslint-config-prettier": "^10.1.8",
63
67
  "eslint-plugin-flowtype": "^8.0.3",
64
- "eslint-plugin-import": "^2.29.1",
65
- "eslint-plugin-prettier": "^4.2.1",
66
- "jest": "^29.7.0",
67
- "prettier": "^2.8.8",
68
- "release-it": "^17.10.0",
69
- "typescript": "^5.5.4"
68
+ "eslint-plugin-import": "^2.32.0",
69
+ "eslint-plugin-prettier": "^5.5.4",
70
+ "jest": "^30.1.2",
71
+ "prettier": "^3.6.2",
72
+ "release-it": "^19.0.4",
73
+ "typescript": "^5.9.2"
70
74
  },
71
- "packageManager": "yarn@4.4.1",
75
+ "packageManager": "yarn@4.9.4+sha512.7b1cb0b62abba6a537b3a2ce00811a843bea02bcf53138581a6ae5b1bf563f734872bd47de49ce32a9ca9dcaff995aa789577ffb16811da7c603dcf69e73750b",
72
76
  "engines": {
73
77
  "node": ">= 18.0.0"
74
78
  },