Socket
Socket
Sign inDemoInstall

paste-html-to-govspeak

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    paste-html-to-govspeak

Converts HTML formatted rich content to govspeak format (a markdown extension library for government editors) when pasted from clipboard into a form input or textarea.


Version published
Weekly downloads
122
increased by50.62%
Maintainers
1
Install size
66.4 kB
Created
Weekly downloads
 

Changelog

Source

0.4.0

  • Add table plugin for handling tables
  • Update dependencies

Readme

Source

Paste HTML to govspeak

This package provides an event listener that will convert pasted HTML content on form inputs and textareas into Govspeak (a markdown extension library for government publishers).

The HTML data available to the browser clipboard is complicated and inconsistent, learn more about this functionality and its limitations.

Installation

Add this project to your package.json file via NPM or Yarn:

# NPM
npm install paste-html-to-govspeak --save
# Yarn
yarn add paste-html-to-govspeak

Manual installation

Download paste-html-to-markdown.js and add it to your application assets.

Usage

Using a bundler (e.g. Webpack)

import { pasteListener } from 'paste-html-to-govspeak'

element.addEventListener('paste', pasteListener)

Without a bundler

element.addEventListener('paste', window.pasteHtmlToGovspeak.pasteListener)

Browser support

  • Chrome
  • Firefox
  • Safari
  • Internet Explorer 11
  • Microsoft Edge

Debugging

This package triggers events at different stages in the conversion process which can be monitored to understand how a particular scenario is occurring. These events are triggered on the element the pasteListener has been applied to.

These are:

  • htmlpaste - which is the received HTML from the paste event
  • textpaste - which is the received text from the paste event
  • govspeak - which is the resultant govspeak of the HTML conversion, this will only be triggered if HTML was present in the paste event.

There is also a htmlToGovspeak method that is exposed by the package. Given a HTML string input this will return Govspeak.

This repo contains example usages of these debugging tools.

Development

npm install
npm test

To continuously build files while developing run:

npm run watch

License

MIT License

Keywords

FAQs

Last updated on 29 Sep 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc