Skip to content

chastell/lovely_rufus

Repository files navigation

Lovely Rufus

Lovely Rufus is an executable and a Ruby library for wrapping paragraphs of text in the spirit of Par.

Usage

Lovely Rufus can be used from the command-line by piping text through the lovely-rufus executable:

$ echo 'The Ballyshannon foundered off the coast of Cariboo, And down in fathoms many went the captain and the crew;' | lovely-rufus
The Ballyshannon foundered off the coast of Cariboo,
And down in fathoms many went the captain and the crew;

Lovely Rufus can also be used from Ruby code through the wrap method:

$ irb
>> require 'lovely_rufus'
>> text = 'The Ballyshannon foundered off the coast of Cariboo, And down in fathoms many went the captain and the crew;'
>> puts LovelyRufus.wrap(text)
The Ballyshannon foundered off the coast of Cariboo,
And down in fathoms many went the captain and the crew;

Note that wrap can take optional desired width:

$ irb
>> require 'lovely_rufus'
>> text = 'The Ballyshannon foundered off the coast of Cariboo, And down in fathoms many went the captain and the crew;'
>> puts LovelyRufus.wrap(text, width: 15)
The
Ballyshannon
foundered off
the coast of
Cariboo, And
down in fathoms
many went the
captain and
the crew;

Features

Currently, Lovely Rufus sports the following features:

  • paragraphs are wrapped to the specified width,
  • one-letter words are not left at ends of lines,
  • email quotes (>) are handled properly and normalised (> > >>>>),
  • email-quoted paragraph breaks are cleared,
  • code comments (starting with # and //) are handled properly,
  • multiple paragraphs are wrapped independently.

Name and history

Lovely Rufus was created as a Ruby Mendicant University project and is named after a certain Love Actually character who’s exceptionally good at wrapping.


© MMX-MMXIX Piotr Szotkowski chastell@chastell.net, licensed under AGPL-3.0 (see LICENCE)