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

slate-serializers

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slate-serializers

Serialize Slate JSON objects to HTML and vice versa. Define rules to modify the end result.

  • 0.0.6
  • npm
  • Socket score

Version published
Weekly downloads
3.3K
increased by24.47%
Maintainers
1
Weekly downloads
 
Created
Source

slate-serializers

A collection of serializers to convert Slate JSON objects to various formats and vice versa. Designed to work in both Node.js and browser environments.

Serializers included so far:

  • slateToHtml
  • htmlToSlate

Installation

yarn add slate-serializers
# or
npm install slate-serializers

Example usage:

import { slateToHtml, htmlToSlate } from 'slate-serializers'

const slate = [
  {
    children: [
      {
        text: 'Heading 1',
      },
    ],
    type: 'h1',
  },
  {
    children: [
      {
        text: 'Paragraph 1',
      },
    ],
    type: 'p',
  },
]

const serializedToHtml = slateToHtml(slate)
// output
// <h1>Heading 1</h1><p>Paragraph 1</p>

// ...and convert back to Slate
const serializedToSlate = htmlToSlate(serializedToHtml)

Details

slateToHtml

Based on logic in Deserializing | Serializing | Slate.

htmlparser2 is used to parse HTML instead of the DOMHandler object. Rationale:

  • Works in all environments, including Node.js.
  • Speed - htmlparser2 is the fastest HTML parser.
  • Forgiving regarding HTML spec compliance.

htmlToSlate

Based on logic in HTML | Serializing | Slate.

Development

Commits

TLDR: contributors can format commit messages in any way, maintainers should use conventional commits.

This repository uses conventional commits.

Conventional commits are not enforced. General guidance:

  • Commit messages can be formatted in any way on a pull request.
  • Conventional commit messages are preferred on pull request squash and merge.

Run npx cz instead of git commit to lint commit messages using @commitlint/cli.

FAQs

Package last updated on 24 Nov 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