Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including entity-convert with all npm packages installed. Try it out:

var entityConvert = require("entity-convert")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

entity-convert v1.0.0

convert all special characters in a string to their corresponding HTML and CSS entities


convert special characters in a string to their HTML or CSS charcode entities (useful for build tools et. al.)

The module works as AMD or CommonJS module and exports an Object exposing two methods: .html(string) and .css(string). In a non-AMD and non-CommonJS environment .entityconvert will be attached to the global object.

AMD usage:

require(['entityconvert'], function(entityconvert){
    var converted = entityconvert.html('We äll löve Ümläutß!');
    // => We äll löve Ümläutß!

CommonJS usage:

var entityconvert = require('entity-convert');
var converted = entityconvert.css('We äll löve Ümläutß!');
// => We \00e4ll l\00f6ve \00dcml\00e4ut\00df!

Script tag usage:

<script src="entityconvert.js"></script>
    var converted = entityconvert.html('Yäy!');
    // => Y&#228;y!

Available via npm:

npm install entity-convert --save

##License MIT © Frederik Ring

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free