This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rurpy2
Recipients GraylinKim, bethard, denilsonsa, eric.araujo, rurpy2, zbysz
Date 2012-11-23.22:22:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1353709350.36.0.666991776855.issue12806@psf.upfronthosting.co.za>
In-reply-to
Content
I happened upon this issue while Googling for a formatter with the behavior described here.

I put together a formatter derived from the code submitted by GraylinKim (2011-08-22) and offer it for consideration (though it is missing some things like docstrings and hasn't been tested very thoroughly).

As per other comments, it uses additional indentation rather than leading special characters to start a new block.  Differently than GraylinKim's code, additional indentation suppresses wrapping or any formatting.  However, it would be easy to change that as I hope is obvious from the code.

There are two common ways of denoting a block of text (a block being text that should be reformatted as a single unit; aka paragraph)

 1. A group of text lines ending with newlines followed by a blank line to denote the end of the block.

 2. A single (long) text line where the terminating newline denotes the end of the block (i.e. one line == one block).

Both occur in the context of argparse help text:

Example of #1:
   p.add_argument (....,
       help='''block1 block1 block1 block1 
           block1 block1 block1 block1
           block1 block1 block1 block1

           block2 block2 block2 block2
           block2 block2 block2 block2''')

Examples of #2:
   p.add_argument (....,
       help='block1 block1 block1 block1 '
           'block1 block1 block1 block1 '
           'block1 block1 block1 block1 \n'
	   ''
           'block2 block2 block2 block2 '
           'block2 block2 block2 block2 ')

   p.add_argument (....,
       help='''block1 block1 block1 block1 \
           block1 block1 block1 block1 \
           block1 block1 block1 block1 \

           block2 block2 block2 block2 \
           block2 block2 block2 block2 ''')

There is no way, when reading lines of text, to tell whether one is reading text in the form of #1 or #2, when one sees a newline.  So a formatter really needs to be able to be told which form it is being given.  This seems to require two separate formatter classes (though they call common code.)

The first form (call it multiline blocked text) is formatted by ParagraphFormatterML.  The second form (call it single-line blocked text; I often use form #2a) by ParagraphFormatter.
History
Date User Action Args
2012-11-23 22:22:30rurpy2setrecipients: + rurpy2, bethard, eric.araujo, zbysz, denilsonsa, GraylinKim
2012-11-23 22:22:30rurpy2setmessageid: <1353709350.36.0.666991776855.issue12806@psf.upfronthosting.co.za>
2012-11-23 22:22:30rurpy2linkissue12806 messages
2012-11-23 22:22:29rurpy2create