Socket
Socket
Sign inDemoInstall

drycleaner

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    drycleaner

Tiny library for manipulating html strings


Version published
Weekly downloads
2
decreased by-77.78%
Maintainers
1
Install size
18.8 kB
Created
Weekly downloads
 

Readme

Source

drycleaner

A very tiny library for manipulating HTML entity strings

see a demo here

This library was created to make working with MS Word documents easier, especially if you need to insert html or possibly even color-coded html into the document.

To install
$ npm install drycleaner

##API

An instance of the Drycleaner object contains three methods:

  • escape escapes the initial string passed.
  • unescape unescapes the initial string passed.
  • wrap wrappes the initial string passed into a dom element.

##Options

wrap takes a single object as its argument. It contains two properties. The result of the object on which wrap was called will become a dom object, not an escaped html string.

el {string}: node name of the html element you wish create.

style {object}: style properties that will be appended inline to the html element wrapper.

var html = new Drycleaner("<b>Hello world</b>");
var processed = html.wrap({
    el: "pre",
    style: {
        background-color: "yellow",
        color: "grey"
    }
})
var result = processed.str;
--> <pre style="background-color: yellow; color: grey"><b>hello world</b></pre>    

escape and unescape can each take a single object as their argument. It contains four properties.

nbsp {boolean}: if set to true, non-breaking white space will be converted to and from " " and &nbsp; The default value is false.

var html = new Drycleaner("<b>hello world</b>");
var processed = html.escape({ npsp: true });
var result = processed.str;
--> &lt;b&gt;hello&nbsp;world&lt;/b&gt;

except {array}: an array of characters or html entity strings you wish to filter.

var html = new Drycleaner("<b>hello world</b>");
var processed = html.escape({ except: ["<"] });
var result = processed.str;
--> <b&gt;hello world</b&gt;

on {string}: the property you wish to perform work on. Set to str by default.

var html = new Drycleaner("<b>Hello world</b>");
var processed = html.escape({ result: "myResult" })
                    .unescape({ on: "myResult" });
var result = processed.myResult;
--> <b>Hello world</b>

result {string}: the property you wish to set the result of an operation on. Set to str by default.

var html = new Drycleaner("<b>Hello world</b>");
var processed = html.escape({ result: "myResult" });
var result = processed.myResult;
--> &lt;b&gt;hello world&lt;/b&gt;

Keywords

FAQs

Last updated on 30 Aug 2015

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