Skip to content

Commit af18fb0

Browse files
committed
📝
1 parent f346b15 commit af18fb0

File tree

2 files changed

+31
-28
lines changed

2 files changed

+31
-28
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,21 @@ Converts a JSON input to markdown.
9595

9696
**Supported elements**
9797

98-
| Type | Element | Data | Example |
99-
|--------------|--------------------|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|
100-
| `h1` | Heading 1 | The heading text as string. | `{ h1: "heading 1" }` |
101-
| `h2` | Heading 2 | The heading text as string. | `{ h2: "heading 2" }` |
102-
| `h3` | Heading 3 | The heading text as string. | `{ h3: "heading 3" }` |
103-
| `h4` | Heading 4 | The heading text as string. | `{ h4: "heading 4" }` |
104-
| `h5` | Heading 5 | The heading text as string. | `{ h5: "heading 5" }` |
105-
| `h6` | Heading 6 | The heading text as string. | `{ h6: "heading 6" }` |
106-
| `p` | Paragraphs | The paragraph text as string or array (multiple paragraphs). | `{ p: "Hello World"}` or multiple paragraphs: `{ p: ["Hello", "World"] }` |
107-
| `blockquote` | Blockquote | The blockquote as string or array (multiple blockquotes) | `{ blockquote: "Hello World"}` or multiple blockquotes: `{ blockquote: ["Hello", "World"] }` |
108-
| `img` | Image | An object or an array of objects containing the `title` and `source` fields. | `{ img: { title: "My image title", source: "http://example.com/image.png" } }` |
109-
| `ul` | Unordered list | An array of strings representing the items. | `{ ul: ["item 1", "item 2"] }` |
110-
| `ol` | Ordered list | An array of strings representing the items. | `{ ol: ["item 1", "item 2"] }` |
111-
| `code` | Code block element | An object containing the `language` (`String`) and `content` (`Array` or `String`) fields. | `{ code: { "language": "html", "content": "<script src='dummy.js'></script>" } } |
98+
| Type | Element | Data | Example |
99+
|--------------|--------------------|--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
100+
| `h1` | Heading 1 | The heading text as string. | `{ h1: "heading 1" }` |
101+
| `h2` | Heading 2 | The heading text as string. | `{ h2: "heading 2" }` |
102+
| `h3` | Heading 3 | The heading text as string. | `{ h3: "heading 3" }` |
103+
| `h4` | Heading 4 | The heading text as string. | `{ h4: "heading 4" }` |
104+
| `h5` | Heading 5 | The heading text as string. | `{ h5: "heading 5" }` |
105+
| `h6` | Heading 6 | The heading text as string. | `{ h6: "heading 6" }` |
106+
| `p` | Paragraphs | The paragraph text as string or array (multiple paragraphs). | `{ p: "Hello World"}` or multiple paragraphs: `{ p: ["Hello", "World"] }` |
107+
| `blockquote` | Blockquote | The blockquote as string or array (multiple blockquotes) | `{ blockquote: "Hello World"}` or multiple blockquotes: `{ blockquote: ["Hello", "World"] }` |
108+
| `img` | Image | An object or an array of objects containing the `title` and `source` fields. | `{ img: { title: "My image title", source: "http://example.com/image.png" } }` |
109+
| `ul` | Unordered list | An array of strings representing the items. | `{ ul: ["item 1", "item 2"] }` |
110+
| `ol` | Ordered list | An array of strings representing the items. | `{ ol: ["item 1", "item 2"] }` |
111+
| `code` | Code block element | An object containing the `language` (`String`) and `content` (`Array` or `String`) fields. | `{ code: { "language": "html", "content": "<script src='dummy.js'></script>" } }` |
112+
| `table` | Table | An object containing the `headers` (`Array` of `String`s) and `rows` (`Array` of `Array`s or `Object`s). | `{ table: { headers: ["a", "b"], rows: [{ a: "col1", b: "col2" }] } }` or `{ table: { headers: ["a", "b"], rows: [["col1", "col2"]] } }` |
112113

113114
You can extend the `json2md.converters` object to support your custom types.
114115

lib/index.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ var converters = require("./converters");
77
*
88
* **Supported elements**
99
*
10-
* | Type | Element | Data | Example |
11-
* |--------------|--------------------|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|
12-
* | `h1` | Heading 1 | The heading text as string. | `{ h1: "heading 1" }` |
13-
* | `h2` | Heading 2 | The heading text as string. | `{ h2: "heading 2" }` |
14-
* | `h3` | Heading 3 | The heading text as string. | `{ h3: "heading 3" }` |
15-
* | `h4` | Heading 4 | The heading text as string. | `{ h4: "heading 4" }` |
16-
* | `h5` | Heading 5 | The heading text as string. | `{ h5: "heading 5" }` |
17-
* | `h6` | Heading 6 | The heading text as string. | `{ h6: "heading 6" }` |
18-
* | `p` | Paragraphs | The paragraph text as string or array (multiple paragraphs). | `{ p: "Hello World"}` or multiple paragraphs: `{ p: ["Hello", "World"] }` |
19-
* | `blockquote` | Blockquote | The blockquote as string or array (multiple blockquotes) | `{ blockquote: "Hello World"}` or multiple blockquotes: `{ blockquote: ["Hello", "World"] }` |
20-
* | `img` | Image | An object or an array of objects containing the `title` and `source` fields. | `{ img: { title: "My image title", source: "http://example.com/image.png" } }` |
21-
* | `ul` | Unordered list | An array of strings representing the items. | `{ ul: ["item 1", "item 2"] }` |
22-
* | `ol` | Ordered list | An array of strings representing the items. | `{ ol: ["item 1", "item 2"] }` |
23-
* | `code` | Code block element | An object containing the `language` (`String`) and `content` (`Array` or `String`) fields. | `{ code: { "language": "html", "content": "<script src='dummy.js'></script>" } } |
10+
* | Type | Element | Data | Example |
11+
* |--------------|--------------------|--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
12+
* | `h1` | Heading 1 | The heading text as string. | `{ h1: "heading 1" }` |
13+
* | `h2` | Heading 2 | The heading text as string. | `{ h2: "heading 2" }` |
14+
* | `h3` | Heading 3 | The heading text as string. | `{ h3: "heading 3" }` |
15+
* | `h4` | Heading 4 | The heading text as string. | `{ h4: "heading 4" }` |
16+
* | `h5` | Heading 5 | The heading text as string. | `{ h5: "heading 5" }` |
17+
* | `h6` | Heading 6 | The heading text as string. | `{ h6: "heading 6" }` |
18+
* | `p` | Paragraphs | The paragraph text as string or array (multiple paragraphs). | `{ p: "Hello World"}` or multiple paragraphs: `{ p: ["Hello", "World"] }` |
19+
* | `blockquote` | Blockquote | The blockquote as string or array (multiple blockquotes) | `{ blockquote: "Hello World"}` or multiple blockquotes: `{ blockquote: ["Hello", "World"] }` |
20+
* | `img` | Image | An object or an array of objects containing the `title` and `source` fields. | `{ img: { title: "My image title", source: "http://example.com/image.png" } }` |
21+
* | `ul` | Unordered list | An array of strings representing the items. | `{ ul: ["item 1", "item 2"] }` |
22+
* | `ol` | Ordered list | An array of strings representing the items. | `{ ol: ["item 1", "item 2"] }` |
23+
* | `code` | Code block element | An object containing the `language` (`String`) and `content` (`Array` or `String`) fields. | `{ code: { "language": "html", "content": "<script src='dummy.js'></script>" } }` |
24+
* | `table` | Table | An object containing the `headers` (`Array` of `String`s) and `rows` (`Array` of `Array`s or `Object`s). | `{ table: { headers: ["a", "b"], rows: [{ a: "col1", b: "col2" }] } }` or `{ table: { headers: ["a", "b"], rows: [["col1", "col2"]] } }` |
25+
*
2426
*
2527
* You can extend the `json2md.converters` object to support your custom types.
2628
*

0 commit comments

Comments
 (0)