Skip to content

Commit 7710a9d

Browse files
committed
Updated docs
1 parent e449d20 commit 7710a9d

File tree

3 files changed

+66
-9
lines changed

3 files changed

+66
-9
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Contributions are more than welcome!
5959

6060
Thanks! :sweat_smile:
6161

62+
63+
6264
[1]: https://github.com/IonicaBizau/json2md/issues
6365

64-
[2]: https://github.com/IonicaBizau/code-style
66+
[2]: https://github.com/IonicaBizau/code-style

DOCUMENTATION.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## Documentation
2+
3+
You can see below the API reference of this module.
4+
5+
### `json2md(data, prefix)`
6+
Converts a JSON input to markdown.
7+
8+
**Supported elements**
9+
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+
26+
You can extend the `json2md.converters` object to support your custom types.
27+
28+
```js
29+
json2md.converters.sayHello = function (input, json2md) {
30+
return "Hello " + input + "!";
31+
};
32+
```
33+
34+
Then you can use it:
35+
36+
```js
37+
json2md({ sayHello: "World" });
38+
// => "Hello World!"
39+
```
40+
41+
#### Params
42+
- **Array|Object|String** `data`: The input JSON data.
43+
- **String** `prefix`: A snippet to add before each line.
44+
45+
#### Return
46+
- **String** The generated markdown result.
47+

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
[![json2md](http://i.imgur.com/uj64JFw.png)](#)
23

34
# json2md [![PayPal](https://img.shields.io/badge/%24-paypal-f39c12.svg)][paypal-donations] [![Version](https://img.shields.io/npm/v/json2md.svg)](https://www.npmjs.com/package/json2md) [![Downloads](https://img.shields.io/npm/dt/json2md.svg)](https://www.npmjs.com/package/json2md) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
@@ -6,13 +7,16 @@
67
78
If you're looking to use this on the client side, that's also possible. Check out the [`dist`](/dist) directory.
89

9-
## Installation
10+
## :cloud: Installation
1011

1112
```sh
1213
$ npm i --save json2md
1314
```
1415

15-
## Example
16+
17+
## :clipboard: Example
18+
19+
1620

1721
```js
1822
// Dependencies
@@ -88,7 +92,8 @@ console.log(json2md([
8892
// ```
8993
```
9094

91-
## Documentation
95+
## :memo: Documentation
96+
9297

9398
### `json2md(data, prefix)`
9499
Converts a JSON input to markdown.
@@ -133,15 +138,18 @@ json2md({ sayHello: "World" });
133138
#### Return
134139
- **String** The generated markdown result.
135140

136-
## How to contribute
141+
142+
143+
## :yum: How to contribute
137144
Have an idea? Found a bug? See [how to contribute][contributing].
138145

139-
## Where is this library used?
146+
## :dizzy: Where is this library used?
140147
If you are using this library in one of your projects, add it in this list. :sparkles:
141148

142-
I am using this library to generate documentation for my projects, being integrated with [blah](https://github.com/IonicaBizau/node-blah).
143149

144-
## License
150+
- [`doc-cli`](https://github.com/cnio/doc-cli#readme) (by CNIO)—doc generator for nodejsI am using this library to generate documentation for my projects, being integrated with [blah](https://github.com/IonicaBizau/node-blah).
151+
152+
## :scroll: License
145153

146154
[MIT][license] © [Ionică Bizău][website]
147155

@@ -151,4 +159,4 @@ I am using this library to generate documentation for my projects, being integra
151159
[license]: http://showalicense.com/?fullname=Ionic%C4%83%20Biz%C4%83u%20%3Cbizauionica%40gmail.com%3E%20(http%3A%2F%2Fionicabizau.net)&year=2015#license-mit
152160
[website]: http://ionicabizau.net
153161
[contributing]: /CONTRIBUTING.md
154-
[docs]: /DOCUMENTATION.md
162+
[docs]: /DOCUMENTATION.md

0 commit comments

Comments
 (0)