diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-09-18 16:47:55 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-09-18 16:47:55 -0300 |
commit | b4e2708c6f8cc2191c581aef404803478e65e678 (patch) | |
tree | 703d3f7f8f96d9564e7cc3f8ebf85a38c93ab3e1 /misc/sed/justify.sed | |
parent | 4fdd3ebb2b0622fb6cff7376a02a5b92c1aba2ae (diff) | |
download | scripts-b4e2708c6f8cc2191c581aef404803478e65e678.tar.gz scripts-b4e2708c6f8cc2191c581aef404803478e65e678.tar.bz2 |
Moved scripts to custom repos
Diffstat (limited to 'misc/sed/justify.sed')
-rwxr-xr-x | misc/sed/justify.sed | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/misc/sed/justify.sed b/misc/sed/justify.sed deleted file mode 100755 index 0a2e5af..0000000 --- a/misc/sed/justify.sed +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sed -f -# justify.sed - aurélio marinho jargas <verde (a) aurelio net> -# -# it gets a text already wrapped on the desired number of columns -# and add extra white spaces, from left to right, word by word, -# to justify all the lines. there is a maximum of 5 spaces to be -# inserted between the words. if this limit is reached, the line -# is not justified (come on, more than 5 is horrible). empty -# lines are ignored. btw, this comments were justified with this -# script &:) -# -# 20000715 1st release -# 20000722 code cleaned - -# cleaning extra spaces of the line -s/ \+/ /g -s/^ // -s/ $// - -# we'll only justify lines with less than 65 chars -/^.\{65\}/b - -# backup of the 'stripped' line -h - -# spaces -> pattern -# convert series of spaces to a internal pattern `n -:s2p -s/ /`5/g -s/ /`4/g -s/ /`3/g -s/ /`2/g -s/ /`1/g -t 1space -b - -# pattern -> spaces -# restore the spaces converted to the internal pattern `n -:p2s -s/`5/ /g -s/`4/ /g -s/`3/ /g -s/`2/ /g -s/`1/ /g -t check -b - -# check if we've reached our right limit -# if not, continue adding spaces -:check -/^.\{65\}/!b s2p -b - -# here's the "magic": -# add 1 space to the first and minor internal pattern found. -# this way, the extra spaces are always added from left to right, -# always balanced, one by one. -# right after the substitution, we'll restore the spaces and -# test if our limit was reached. -:1space -s/`1/`2/ ; t p2s -s/`2/`3/ ; t p2s -s/`3/`4/ ; t p2s -s/`4/`5/ ; t p2s - -# we don't want to justify with more than 5 added spaces between -# words, so let's restore the original line -/`5/x |