From f91ff9c502a5937d56870ce417c6036e826b64f2 Mon Sep 17 00:00:00 2001 From: Chilfish Date: Tue, 13 Feb 2024 04:48:30 +0800 Subject: [PATCH] chore: fix jsdocs and readme (#14) * docs: fix jsdocs & README.md * chore: update automd * docs: use single quotes in jsdocs examples * docs: use double quotes --- README.md | 35 +++++++++++++++++++++++++++-------- src/render.ts | 30 +++++++++++++++--------------- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 036f220..0d013ee 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ const { md } = require("omark"); + + @@ -87,7 +89,7 @@ Render a markdown bold and italic text. **Example:** ```js -md.bold("Hello, World!"); +md.boldAndItalic("Hello, World!"); // => "***Hello, World!***" ``` @@ -97,10 +99,10 @@ Format a string as a code block. **Example:** -````js +```js md.codeBlock('console.log("Hello, World!");', "js"); // => "```js\nconsole.log("Hello, World!");\n```" -```` +``` ### `heading(text, level)` @@ -109,7 +111,7 @@ Render a markdown heading. **Example:** ```js -md.heading(1, "Hello, World!"); +md.heading("Hello, World!", 1); // => "\n# Hello, World!\n" ``` @@ -142,7 +144,7 @@ Render a markdown italic text. **Example:** ```js -md.bold("Hello, World!"); +md.italic("Hello, World!"); // => "_Hello, World!_" ``` @@ -156,7 +158,6 @@ Render a markdown link. md.link("https://www.google.com", "Google"); // => "[Google](https://www.google.com)" ``` - ```js md.link("https://www.google.com", "Google", { external: true }); // => "Google" @@ -172,10 +173,9 @@ Render a markdown ordered or unordered list. md.list(["Item 1", "Item 2", "Item 3"]); // => "- Item 1\n- Item 2\n- Item 3" ``` - ```js md.list(["Item 1", "Item 2", "Item 3"], { ordered: true }); -// => "1. Item 1\n2. Item 2\n3. Item 3") +// => "1. Item 1\n2. Item 2\n3. Item 3" ``` ### `strikethrough(text)` @@ -189,6 +189,25 @@ md.strikethrough("Hello, World!"); // => "~~Hello, World!~~" ``` +### `table(table: { rows[][], columns[] })` + +Render a markdown table. + +**Example:** + +```js +md.table({ + columns: ["Breed", "Origin", "Size", "Temperament"], + rows: [ + ["Abyssinian", "Egypt", "Medium", "Active"], + ["Aegean", "Greece", "Medium", "Active"], + ["American Bobtail", "United States", "Medium", "Active"], + ["Applehead Siamese", "Thailand", "Medium", "Active"], + ], +}); +``` + + ## Development diff --git a/src/render.ts b/src/render.ts index 977d9fe..a942ca9 100644 --- a/src/render.ts +++ b/src/render.ts @@ -4,7 +4,7 @@ * @example * * ```js - * md.heading('Hello, World!', 1); + * md.heading("Hello, World!", 1); * // => "\n# Hello, World!\n" * ``` * @param text Heading title @@ -24,12 +24,12 @@ export function heading(text: string, level: number): string { * @example * * ```js - * md.link('https://www.google.com', 'Google'); - * // => "[Google](https://www.google.com)" + * md.link("https://www.google.com", "Google"); + * // => "[Google](https://www.google.com)" * ``` * * ```js - * md.link('https://www.google.com', 'Google', { external: true }); + * md.link("https://www.google.com", "Google", { external: true }); * // => "Google" * ``` * @@ -59,7 +59,7 @@ export function link( * @example * * ```js - * md.image('https://cataas.com/cat', 'Cute Cat'); + * md.image("https://cataas.com/cat", "Cute Cat"); * // => "![Cute Cat](https://cataas.com/cat)" * ``` * @@ -86,7 +86,7 @@ export function image( * @example * * ```js - * md.codeBlock('console.log("Hello, World!");', 'js'); + * md.codeBlock('console.log("Hello, World!");', "js"); * // => "```js\nconsole.log("Hello, World!");\n```" * ``` * @@ -143,7 +143,7 @@ export function table(table: { rows: string[][]; columns: string[] }): string { * @example * * ```js - * md.bold('Hello, World!'); + * md.bold("Hello, World!"); * // => "**Hello, World!**" * ``` * @@ -162,11 +162,11 @@ export function bold(text: string): string { * @example * * ```js - * md.bold('Hello, World!'); + * md.italic("Hello, World!"); * // => "_Hello, World!_" * ``` * - * @param text Text to be formatted as bold + * @param text Text to be formatted as italic * @returns Rendered markdown string * * @group render_utils @@ -181,11 +181,11 @@ export function italic(text: string): string { * @example * * ```js - * md.bold('Hello, World!'); + * md.boldAndItalic("Hello, World!"); * // => "***Hello, World!***" * ``` * - * @param text Text to be formatted as bold + * @param text Text to be formatted as bold and italic * @returns Rendered markdown string * * @group render_utils @@ -200,7 +200,7 @@ export function boldAndItalic(text: string): string { * @example * * ```js - * md.blockquote('Hello, World!'); + * md.blockquote("Hello, World!"); * // => "> Hello, World!" * ``` * @@ -221,7 +221,7 @@ export function blockquote(text: string): string { * @example * * ```js - * md.strikethrough('Hello, World!'); + * md.strikethrough("Hello, World!"); * // => "~~Hello, World!~~" * ``` * @@ -259,13 +259,13 @@ export function hr(length: number): string { * @example * * ```js - * md.list(['Item 1', 'Item 2', 'Item 3']); + * md.list(["Item 1", "Item 2", "Item 3"]); * // => "- Item 1\n- Item 2\n- Item 3" * ``` * * ```js * md.list(["Item 1", "Item 2", "Item 3"], { ordered: true }); - * // => "1. Item 1\n2. Item 2\n3. Item 3") + * // => "1. Item 1\n2. Item 2\n3. Item 3" * ``` * * @param items List of items