@beckkramer/letterpress
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

letterpress

npm

npm bundle size

A tiny typography utility library

Methods

tidyLines

This function prevents Runts: when a single word wrapping to a new line by itself. This is done by inserting the HTML entity for a non-breaking space ( ) in place of the last space.

If there's room for all the words on a given line, there will be no visible effect. Screen readers will treat this character as they would any other space.

Before:

Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna
aliqua.

After:

Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore 
magna aliqua.

Useage:

const originalText = "An example sentence."
const formattedText = Letterpress.tidyLines(originalText)

// formattedText:
"An example sentence."

Readme

Keywords

none

Package Sidebar

Install

npm i @beckkramer/letterpress

Weekly Downloads

1

Version

0.3.0

License

MIT

Unpacked Size

13.4 kB

Total Files

17

Last publish

Collaborators

  • beckkramer