https://github.com/palerdot/slate-mark
Slate to Markdown convertor
https://github.com/palerdot/slate-mark
Last synced: about 1 year ago
JSON representation
Slate to Markdown convertor
- Host: GitHub
- URL: https://github.com/palerdot/slate-mark
- Owner: palerdot
- License: mit
- Created: 2021-08-15T03:44:15.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-10-31T10:13:55.000Z (over 4 years ago)
- Last Synced: 2025-02-28T07:49:39.323Z (over 1 year ago)
- Language: TypeScript
- Size: 274 KB
- Stars: 15
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# slate-mark
Slate to Markdown parser.
Compatible with [plate-editor](https://github.com/udecode/plate/) out of the box.
## Usage
```javascript
// if using with typescript, import type from '@udecode/plate-core' or `@udecode/plate`
// please make sure your input has similar strucutre to TNode
import type { TNode } from '@udecode/plate-core'
// or
// import type { TNode } from '@udecode/plate'
import { plateToMarkdown, plateToMarkdownAsync } from 'slate-mark'
// input type is `TNode` (https://plate-api.udecode.io/modules.html#tnode)
const myInput: TNode = [
{
type: 'p',
children: [
{
text: 'Hello `universe !!!`',
},
],
},
...
]
// sync version
// output will be a markdown string
const output = plateToMarkdown(myInput)
// async/promise version
plateToMarkdownAsync(myInput)
.then(result => {
// result will be a markdown string
})
```
*Please make sure you have either `@udecode/plate-core` or `@udecode/plate` as your dependency if you are using it with typescript. The input type for the parser utility functions is [TNode](https://plate-api.udecode.io/modules.html#tnode)*