Skip to content

Commit

Permalink
chore: fix jsdocs and readme (#14)
Browse files Browse the repository at this point in the history
* docs: fix jsdocs & README.md

* chore: update automd

* docs: use single quotes in jsdocs examples

* docs: use double quotes
  • Loading branch information
Chilfish authored Feb 12, 2024
1 parent 40aa4a0 commit f91ff9c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 23 deletions.
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const { md } = require("omark");

<!-- AUTOMD_START generator="jsdocs" group="parsing" -->



<!-- AUTOMD_END -->

<!-- AUTOMD_START generator="jsdocs" group="render_utils" -->
Expand Down Expand Up @@ -87,7 +89,7 @@ Render a markdown bold and italic text.
**Example:**

```js
md.bold("Hello, World!");
md.boldAndItalic("Hello, World!");
// => "***Hello, World!***"
```

Expand All @@ -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)`

Expand All @@ -109,7 +111,7 @@ Render a markdown heading.
**Example:**

```js
md.heading(1, "Hello, World!");
md.heading("Hello, World!", 1);
// => "\n# Hello, World!\n"
```

Expand Down Expand Up @@ -142,7 +144,7 @@ Render a markdown italic text.
**Example:**

```js
md.bold("Hello, World!");
md.italic("Hello, World!");
// => "_Hello, World!_"
```

Expand All @@ -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 });
// => "<a href="https://www.google.com" title="Google" target="_blank">Google</a>"
Expand All @@ -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)`
Expand All @@ -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"],
],
});
```


<!-- AUTOMD_END -->

## Development
Expand Down
30 changes: 15 additions & 15 deletions src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @example
*
* ```js
* md.heading('Hello, World!', 1);
* md.heading("Hello, World!", 1);
* // => "\n# Hello, World!\n"
* ```
* @param text Heading title
Expand All @@ -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 });
* // => "<a href="https://www.google.com" title="Google" target="_blank">Google</a>"
* ```
*
Expand Down Expand Up @@ -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)"
* ```
*
Expand All @@ -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```"
* ```
*
Expand Down Expand Up @@ -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!**"
* ```
*
Expand All @@ -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
Expand All @@ -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
Expand All @@ -200,7 +200,7 @@ export function boldAndItalic(text: string): string {
* @example
*
* ```js
* md.blockquote('Hello, World!');
* md.blockquote("Hello, World!");
* // => "> Hello, World!"
* ```
*
Expand All @@ -221,7 +221,7 @@ export function blockquote(text: string): string {
* @example
*
* ```js
* md.strikethrough('Hello, World!');
* md.strikethrough("Hello, World!");
* // => "~~Hello, World!~~"
* ```
*
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f91ff9c

Please sign in to comment.