Sentence Length Colorization
I think I had the same wooahhhhh coool reaction as so many others did when this tweet was going around:
The art of sentence length. Swoon pic.twitter.com/K91GEZTnKm
— Lucy Foulkes (@lfoulkesy) March 30, 2016
Certainly, good writing is more than just varied sentence length, but this is a fantastic visualization that makes an excellent point. It wouldn’t hurt to be able to see this kind of thing in our own writing, in an on-demand fashion while editing.
After tweeting that I wasn’t quite sure how best to go about it, a bunch of folks chimed in with their takes on how they would do it.
Dave took a crack at it within a single tweet. His idea is essentially:
- Loop through all paragraphs.
- Make an array of sentences by splitting the whole string on periods.
- Wrap each sentence in a span with a data attribute of how many words in that sentence.
The data attributes could then be used in CSS selectors to colorize. The idea didn’t quite work as written, but I was able to extrapolate that idea into a working concept, if slightly more verbose:
Note that this demo:
- Doesn’t take into account almost any edge case. Note the hyphenated word fail there. Things like “Mrs. Robinson” would be an obvious edge case this doesn’t deal with.
- Isn’t particularly efficient.
Before we get too far here, It was pointed out several times to me that the UI shown in that tweet looks an awful lot like Hemmingway App.
Indeed it does. I wonder if it’s some kind of hidden feature or something? I wasn’t able to find any sentence length colorizer feature poking around in there a bit. It highlights other things in useful ways though.
And speaking of highlighting sentences for useful alterior purposes, Tone Analyzer is an experiment to do that:
There is also an Angular JS lib that can be used to colorize arbitrary lengths of text:
Pim Derks created an actual bookmarklet to do the job! Very cool.
I’ll post here for posterity:
I was able to get it to work:
I also un-URL Encoded it, and dropped it here in a fork of my Pen so you can take a look at the code more easily (has some minor bugs like doubling up periods at the end):
Brandon Brule took a crack at it:
[data-wc] approach was hard because you have to be very explicit. You can’t really do
Antoinette Janus has a nicely-done take as well:
Jonathan Williamson created a demo with a textarea and the colorization is separate and updated as-you-type:
The original tweet was all about the beauty of varied sentence length. Beauty in how the writing feels and reads. It wasn’t really about the colors or visualization of it, that just served to explain the message. But the colors were kinda beautiful too.
In another bit of prior art here, Sanne Peters did some visualized poems that maps words to colors so you can see them as well as read them:
Also remember we’re no stranger to Boomarklets That Help With Text™. A few years ago we tackled one that helped show you where an ideal line length for readability should land:
See the Pen Bookmarklet to make the text between 45 and 75 characters turn red. by Chris Coyier (@chriscoyier) on CodePen.
And that is what an active tweet thread can bring!