utisam / marton

Convert markdown to notion blocks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Marton

CI NPM Version GitHub License

Convert markdown to notion v2 blocks.

import { markdownToBlocks } from '@utisam/marton';

const blocks = markdownToBlocks(`
# Test

* aaa
  * bbb
`.trim());
console.log(JSON.stringify(blocks, null, "  "));

API

markdownToBlocks(file[, option])

Parameters

  • file (vfile.Compatible) — virtual file representing the input document
  • option (Option) — virtual file representing the input document

Returns

Array of Notion Block object.

markdownToRichText(file[, option])

Parameters

  • file (vfile.Compatible) — virtual file representing the input document
  • option (Option) — virtual file representing the input document

Returns

Array of Notion Rich Text object.

Option

Fields

  • logWarn? ((string) => void) — Callback to print warning logs.
  • toMarkdown? ((Nodes) => string) — Callback to convert markdown to plain text.
  • unsupportedError? (boolean) — Error will be thrown when an unimplemented Markdown syntax was found.

rootToBlocks(root[, option])

Parameters

  • root (mdast.Root) — virtual file representing the input document
  • option (Option) — virtual file representing the input document

Returns

Iterable of Notion Block object.

rootToRichText(root[, option])

Parameters

  • root (mdast.Root) — virtual file representing the input document
  • option (Option) — virtual file representing the input document

Returns

Iterable of Notion Rich Text object.

About

Convert markdown to notion blocks

License:MIT License


Languages

Language:TypeScript 94.0%Language:JavaScript 4.2%Language:Shell 1.8%