New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@slite/unified-mdast-to-delta

Package Overview
Dependencies
Maintainers
18
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slite/unified-mdast-to-delta

A unified plugin to convert markdown to delta

  • 1.7.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-70.97%
Maintainers
18
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 19 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc