non-breaking-spaces

Js module boilerPlate

Usage no npm install needed!

<script type="module">
  import nonBreakingSpaces from 'https://cdn.skypack.dev/non-breaking-spaces';
</script>

README

Library

The description of the library.

Installation and Usage

Installation

To install this javascript module.

npm install non-breaking-spaces

Usage

Convert text and HTML so that white spaces before ponctuation are transformed into non-breaking spaces (&nbsp;).

// import CommonJS
var nonBreakingSpaces = require('non-breaking-spaces');

var text = nonBreakingSpaces.noBreak('Ce texte nécessite une petite correction !');
// Ce texte nécessite une petite correction&nbsp;!

or with EcmaScript6:

// import ES6 Module
import {noBreak as nonBreakingSpaces} from 'non-breaking-spaces';

var text = nonBreakingSpaces('Ce texte nécessite une petite correction !');
// Ce texte nécessite une petite correction&nbsp;!

You may also want to change the replacer:

nonBreakingSpaces.setOptions('replacer', '&#160;');
// or
nonBreakingSpaces.setOptions({
  replacer: '\\u00a0'
});