Socket
Book a DemoInstallSign in
Socket

buddy-system

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buddy-system

Prevent single words from breaking to a new line.

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Buddy-System

Created by: ajkochanowicz

Demo

Demo (jQuery)

Avoids single words breaking onto the last line of text.

Install

npm install buddy-system

Require in node (currently only supported as a jquery plugin)

var $ = require('jquery');
require('buddy-system')($); <----- Attaches itself to the jquery object

Usage

Without jQuery

Use dist/buddysystem.js and simply pass in an array of objects into buddySystem()

objs = document.getElementsByClassName('corrected')
buddySystem(objs)

With jQuery

Use dist/buddysystem.jquery.js after jQuery and $.buddySystem() on any element or elements.

$('.corrected').buddySystem()

How it works

Because you don't need yet another library in your app to do something so simple, this code snippet has been golfed to be as small as possible.

BuddySystem looks for the last space in a phrase like this one

The rain in Spain falls mainly on the plains

And replaces it with &nbsp;, causing the last two words to be parsed as one...holding hands together, the buddy system.

The rain in Spain falls mainly on the&nbsp;plains

Of course, because &nbsp; is unicode markup for a non-breaking space, the text will appear as:

"The rain in Spain falls mainly on
the plains"

If the line breaks after the last "the".

Want to contribute?

git clone https://github.com/olsonpm/buddy-system.git
cd buddy-system
npm install
make test
// dev your heart out

Keywords

buddy-system buddysystem buddy system concatenation orphan widow

FAQs

Package last updated on 17 Feb 2015

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.