Re: Long help lines and wrapping

David Goodger <[email protected]> Mon, 11 Nov 2002 21:51:20 -0500
Newsgroups gmane.comp.python.optik.user
Message-ID <B9F5D6D7.2B954%[email protected]>
Bob van der Poel said:
> Replace the wrap_text() function called in format_option() with a
> routine specific to optik. This would follow the rules in the existing
> wrap_text() with the following addition: if a \n is found in the text to
> be wrapped, the text will be wrapped at this point. In addition, any
> white space following the \n will be preserved.
> 
> If this was to work I could then set up my option like:
> 
>         parser.add_option("-p", "--pattern", type="string",
>            action="store", dest="pattern",
>            help="Set Pattern. Available patterns are:\n" +
>                 "   xx use the xx pattern\n" +
>                 "   yy use the yy pattern")

Greg Ward wrote:
> This sounds eminently sensible to me.  Easy to implement too.  I think
> David's idea is massive flaming overkill.

That's what you thought last time too :)

Seriously though, the "inline" solution could be workable, if more limited
than a full "object" solution, as long as all the details are well thought
out and correctly handled.  Specifically, notice that the second and third
lines of Bob's example are indented.  If these strings get wrapped, what
should the behavior be?  Beginning with:

    "   'xx': use the xx pattern if you're in that kind of mood"

Should it be wrapped and the indent duplicated?

    ["   'xx': use the xx pattern if you're",
     "   in that kind of mood"]

Or just wrapped?

    ["   'xx': use the xx pattern if you're",
     "in that kind of mood"]

What about if the text were a proper bullet list item?

    "   * 'xx': use the xx pattern if you're in that kind of mood"

I would expect this to wrap like this (note the indent):

    ["   * 'xx': use the xx pattern if you're",
     "     in that kind of mood"]

That could be tricky though.  We'd have to specify that a line matching the
pattern "^\s*[*+-] " is a list item and has that wrapping behavior.

How about enumerated lists (items beginning with "1. ", "2. " etc.)?
Documents are complex things.  Once we open the door, it'll be hard to close
it.  Once we go beyond the dirt-simple, complications multiply.  I'm sure
there are cases I haven't thought of yet, and I'm doubly sure that such
cases *will* arise.

-- 
David Goodger  <[email protected]>  Open-source projects:
  - Python Docutils: http://docutils.sourceforge.net/
    (includes reStructuredText: http://docutils.sf.net/rst.html)
  - The Go Tools Project: http://gotools.sourceforge.net/



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf