REBOL [ Title: "Wrap 72" Purpose: "Wrap text at 72 characters." Author: "Brett Handley" Date: 27-Feb-2002 ] wrap-72: function [ "Wrap text at 72 characters by inserting newlines." txt [string!] /flow "Repositions newlines." ] [ mark pt other] [ if flow [ parse/all txt [ any [ 2 newline any [mark: newline (remove mark) ] | mark: newline (change mark #" ") mark: any [#" " | #"^-"] pt: (remove/part mark pt) | skip ] ] ] other: complement charset "^/" parse/all txt [ any [ newline | 72 other mark: pt: ( if any [ all [not tail? pt equal? pt/1 " "] pt: find/reverse mark " " pt: find/reverse mark "^-" pt: mark ] [ if greater? subtract index? mark index? pt 60 [pt: mark] if find " ^/" pt/1 [remove pt] pt: insert pt newline ] ) :pt | skip ] ] txt ]