https://github.com/lbwa/mark-to-json
:truck: Parse the markdown into a JSON static file.
https://github.com/lbwa/mark-to-json
json markdown-parser markdown-parsing markdown-to-json parser static static-files
Last synced: 4 months ago
JSON representation
:truck: Parse the markdown into a JSON static file.
- Host: GitHub
- URL: https://github.com/lbwa/mark-to-json
- Owner: lbwa
- Created: 2018-08-21T07:18:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-26T02:36:01.000Z (over 7 years ago)
- Last Synced: 2024-04-30T04:04:06.768Z (over 1 year ago)
- Topics: json, markdown-parser, markdown-parsing, markdown-to-json, parser, static, static-files
- Language: TypeScript
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# mark-to-json [](https://www.npmjs.com/package/mark-to-json) [](https://www.npmjs.com/package/mark-to-json)
> Parse the markdown into a JSON static file, also support multiple-level directories.
## Installing
```bash
# npm
npm i mark-to-json --save
# yarn
yarn add mark-to-json
```
## Usage
| API | Required | default | Description |
| --- | -------- | ------- | ----------- |
| token | true | | Your markdown file content including yaml matter |
| dest | false | `./default.json` | Your JSON static file will be created at the place based on the current nodejs working path |
| extraHeader | false | `{}` | It will be mix in JSON file if you want to add some extra data to JSON static file |
| contentKey | false | `content` | It will be the key of markdown content part in JSON static file |
| filter | false || It can be used to change output schema ([sample][filter-sample]). |
[filter-sample]:./samples/index.ts
## Sample
```js
const Mtj = require('mark-to-json')
new Mtj({
token: '---\ntitle: Hello world\n---\nThis is content.',
dest: './writings/hello-world.json',
extraHeader: {
errno: 0
},
contentKey: 'content',
// Only work with one parameter: schema
filter (schema) {
// do something
// `return` is optional
}
})
// You can find your json file at the './writings/hello-world.json' based on the current nodejs working path
```
The sample output file: [here]
[here]:https://github.com/lbwa/mark-to-json/tree/master/samples/nested
## Changelog
[Changelog](./CHANGELOG.md)