On Jan 23, 2013, at 11:15 AM, Oliver Taylor <[email protected]> wrote:
> I write lists in the following format:
>
> 1. Lorem ipsum dolor sit amet.
> 2. Consectetur adipisicing elit, sed do eiusmod
> tempor incididunt ut labore et dolore magna
> aliqua.
> 3. Ut enim ad minim veniam, quis nostrud
> exercitation ullamco laboris nisi ut aliquip
> ex ea commodo consequat.
> 4. Duis aute irure dolor.
>
> Hard-wrapped, indented, in this case wrapped at ~50 characters.
>
> I do this all the time. Is there a text filter out there that wraps, and/or
> re-wraps, lists in this format? My Unix-fu is not strong enough for this one.
It turns out my regex-fu is stronger than I thought... For anyone who's
interested:
#!/usr/bin/ruby
a = ARGF.read
# Unwrap the list
a = a.gsub(/(\n[ \t]+)(?=[^\n]|\Z)/, "")
# Wrap to 77 Characters
a = a.gsub(/(.{1,77})( +|$)\n?|(.{77})/, "\\1\\3\n")
# Indent wrapped-lines
a = a.gsub(/^(?![\d\s])/, " ")
print a
--
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.