slate-mark
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

slate-mark

Slate to Markdown parser.

Compatible with plate-editor out of the box.

Usage

// 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

Package Sidebar

Install

npm i slate-mark

Weekly Downloads

114

Version

0.0.6

License

MIT

Unpacked Size

39.5 kB

Total Files

41

Last publish

Collaborators

  • palerdot