0.3.0 • Published 3 years ago

@beckkramer/letterpress v0.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

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."
0.3.0

3 years ago

0.2.0

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.0

3 years ago