https://github.com/botpress/md2ob
Library to convert an array of markdown files to a valid OpenBook JSON schema
https://github.com/botpress/md2ob
Last synced: 8 months ago
JSON representation
Library to convert an array of markdown files to a valid OpenBook JSON schema
- Host: GitHub
- URL: https://github.com/botpress/md2ob
- Owner: botpress
- Created: 2022-07-06T16:11:40.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-09T20:34:22.000Z (over 3 years ago)
- Last Synced: 2025-06-20T23:06:53.512Z (12 months ago)
- Language: TypeScript
- Size: 22.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# md2ob
> Converts a list of markdown files to an OpenBook JSON object
**md2ob** is a lightweight npm library used by the [OpenBook Playground](https://openbook-playground.botpress.tools) to convert users' Markdown files to an OpenBook JSON object for book compilation via [API](https://openbook.botpress.cloud/redoc).
This library can be used by anyone to create custom front-end or back-end OpenBook clients and preserve the same markdown format as our Playground.
## Install
```
npm install md2ob
```
## Usage
```js
import convert from "@botpress/md2ob";
const file1 = `
# Topic 1
This is the description of topic 1
## Subtopic 1
This is the description of subtopic 1
- A very impressive fact about subtopic 1
- `attachment to the fact`
- > a question
- A second fact
`
const result = convert(...[file1]);
if (result.success) {
// Success
console.log(result.book, result.warnings)
else {
// Failure
console.log(result.errors)
}
```