diff options
author | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2015-09-18 11:51:28 +0100 |
---|---|---|
committer | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2015-09-18 11:51:28 +0100 |
commit | b0a14e013b318fa87714414b8ece95780527bddf (patch) | |
tree | a9427383ab6e38a4421c9c4313043f6dfcb8e90e /equote |
Initial commit
Diffstat (limited to 'equote')
-rwxr-xr-x | equote | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -0,0 +1,31 @@ +#!/usr/bin/env ruby + +LINELENGTH = (ARGV.shift || 72).to_i + +lines = $stdin.readlines + +lines = lines.map { |line| + if line.length > (LINELENGTH-2) then + newlines = [] + while line.length > (LINELENGTH-2) do + i = LINELENGTH-2 + while line[i] != " " do + i -= 1 + end + newlines << line[0...i] + line = line[i..-1] + end + newlines << line + newlines + else + line + end +} + +lines = lines.flatten + +lines = lines.map { |line| + "> #{line}" +} + +puts lines |