1.7.3 • Published 2 years ago

@slite/unified-mdast-to-delta v1.7.3

Weekly downloads
138
License
MIT
Repository
github
Last release
2 years ago

unified-delta

A unified plugin that is able to compile a Markdown Ast to Delta.

Usage

const toDelta = require("unified-delta")

const markdown = `# Hello & World

> A block quote.

* Some _emphasis_, **importance**, and \`code\`.`

toDelta()
  .process(markdown)
  .then(({ contents }) => console.log(JSON.stringify(contents)))
  .catch(e => console.log(e))

This will output the following:

[
  { "insert": "Hello & World" },
  {
    "insert": "\n",
    "attributes": { "type": "header-one", "data": { "depth": 0 } }
  },
  { "insert": "A block quote." },
  { "insert": "\n", "attributes": { "type": "unstyled" } },
  { "insert": "\n", "attributes": { "type": "quote-block" } },
  { "insert": "Some " },
  { "insert": "emphasis", "attributes": { "italic": true } },
  { "insert": ", " },
  { "insert": "importance", "attributes": { "bold": true } },
  { "insert": ", and " },
  { "insert": "code", "attributes": { "code": true } },
  { "insert": "." },
  { "insert": "\n", "attributes": { "type": "unstyled" } },
  {
    "insert": "\n",
    "attributes": { "type": "unordered-list-item", "data": { "depth": 0 } }
  },
  { "insert": "\n", "attributes": { "type": "unstyled" } }
]

API

[...].use(toDelta[, options])

options
options.endWithNewline (default true)

Wether to finish the Delta inserts with a newline. This is mandatory per Delta's spec, but the option is here for testing purposes.

Todo:

[] Make the visitors system extensible

Since each client will implement its own set of attributes for their delta format we can't cover everything here.

1.7.3

2 years ago

1.7.2

2 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.4

4 years ago

1.6.3

4 years ago

1.5.3

4 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.0

6 years ago

1.1.20

6 years ago

1.1.19

6 years ago

1.1.16

6 years ago

1.1.15

6 years ago

1.1.14

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.1

6 years ago

1.0.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago