Giter Club home page Giter Club logo

alphagov.paste-html-to-govspeak's Introduction

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

Via NPM (recommended)

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

Distributed under the MIT license. See LICENSE for details.

alphagov.paste-html-to-govspeak's People

Contributors

kevindew avatar dependabot-preview[bot] avatar alex-ju avatar murilodalri avatar dependabot[bot] avatar emmabeynon avatar benthorner avatar thomasleese avatar chrisbashton avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.