#!/use/bin/perl
=head

Hello,

  I read the documentation for Autoformat. It seeks to provide
  "automatic formatting" meaning formatting while taking cognizance
  of the context. I can appreciate the value of such a tool. And I
  can appreciate the complexity of the task involved. I would like
  to understand how its author, Damian Conway, has gone about
  providing the functionality. I tried reading the module, but
  didn't get very far.

  So I thought I would present on this list some examples where the
  tool does odd things. The hope is that someone more skilled than I
  will come up with fixes, and by going over the fixes I will get a
  better understanding of the tool.

  I am not sure how fruitful such an endeavor will be, but am giving
  it a try anyway.

  Please bear in mind that the tool is very useful as-is. I use it
  several times a day, everyday. Do not take the mal-examples
  given here as a reflection of the tool. It is a very useful and
  good tool.

  The output of running the code below is given after the __END__.

  Thanks,

  --Suresh

=cut

BEGIN {(*STDERR = *STDOUT) || die;}
use diagnostics;
use warnings;
use strict;
$| = 1;
use Text::Autoformat;


my $mal_example;
my $should_be;

print "\n\n";

$mal_example=<<'BREAK_IN_MIDDLE';
  product is used to 
  implement 
  it.  But so far Banyon/Deccolleate have been 
BREAK_IN_MIDDLE

$should_be=<<'BREAK_IN_MIDDLE_SHOULD_BE';
  product is used to implement it.  But so far Banyon/Deccolleate 
  have been 
BREAK_IN_MIDDLE_SHOULD_BE

  print "___Break in the middle___\nFollowing:\n\n$mal_example\n";
  print "gets formatted incorrectly as:\n\n";
  print autoformat($mal_example, {right=>68}) . "\n";
  print "instead of as:\n\n$should_be\n";

$mal_example=<<'LEFT_BRACKET';
    Q: The customer points out ABCD-PQRS (works with ABC-ABCD03):
       http://www.abcdef.com/abcdefgh123.html. Are you competitive
       with this product?
LEFT_BRACKET

  print "___Left bracket___\nFollowing:\n\n$mal_example\n";
  print "gets formatted incorrectly as:\n\n";
  print autoformat($mal_example, {right=>68});
  print "But if the left bracket, '(', is replaced by 'B',\n";
  $mal_example =~ s/\(/B/;
  print "then it gets formatted as expected:\n\n"; 
  print autoformat($mal_example, {right=>68});

$mal_example=<<'LAST_WORD';
     * The support component would be restricted to helping the
       customer run our sample applications. Support will 
LAST_WORD

  print "___Last word___\nFollowing:\n\n$mal_example\n";
  print "gets formatted incorrectly as:\n\n";
  print autoformat($mal_example, {right=>68});
  print "But if the last word 'will' is removed\n";
  $mal_example =~ s/will//;
  print "then it gets formatted as expected:\n\n"; 
  print autoformat($mal_example, {right=>68});
  print "Or if 'not' is added to the original text and the 'the' in the first 
line removed\n";
  $mal_example =~ s/the//;
  $mal_example =~ s/Support/Support will not/;
  print "then too it gets formatted as expected:\n\n"; 
  print autoformat($mal_example, {right=>68});

$mal_example=<<'VIM_IS_SPECIAL__ROMAN';
     asked people on
     vim.org for help with cleaning it up.
VIM_IS_SPECIAL__ROMAN

  print "___Vim is special-roman___\nFollowing:\n\n$mal_example\n";
  print "gets formatted incorrectly as:\n\n";
  print autoformat($mal_example, {right=>68}) . "\n";
  print "But if 'vim' (roman numeral!) is replaced by 'abc'\n";
  $mal_example =~ s/vim/abc/;
  print "then it gets formatted as expected:\n\n"; 
  print autoformat($mal_example, {right=>68}) . "\n";


__END__

OUTPUT:


___Break in the middle___
Following:

  product is used to 
  implement 
  it.  But so far Banyon/Deccolleate have been 

gets formatted incorrectly as:

  product is used to implement
  it.  But so far Banyon/Deccolleate have been 

instead of as:

  product is used to implement it.  But so far Banyon/Deccolleate 
  have been 

___Left bracket___
Following:

    Q: The customer points out ABCD-PQRS (works with ABC-ABCD03):
       http://www.abcdef.com/abcdefgh123.html. Are you competitive
       with this product?

gets formatted incorrectly as:

    Q: The customer points out ABCD-PQRS (works with ABC-ABCD03):
    http://www.abcdef.com/abcdefgh123.html. Are you competitive with
    this product?

But if the left bracket, '(', is replaced by 'B',
then it gets formatted as expected:

    Q: The customer points out ABCD-PQRS Bworks with ABC-ABCD03):
       http://www.abcdef.com/abcdefgh123.html. Are you competitive
       with this product?

___Last word___
Following:

     * The support component would be restricted to helping the
       customer run our sample applications. Support will 

gets formatted incorrectly as:

*      The support component would be restricted to helping the
          customer run our sample applications. Support will

But if the last word 'will' is removed
then it gets formatted as expected:

     * The support component would be restricted to helping the
       customer run our sample applications. Support

Or if 'not' is added to the original text and the 'the' in the first line 
removed
then too it gets formatted as expected:

     * The support component would be restricted to helping customer
       run our sample applications. Support will not

___Vim is special-roman___
Following:

     asked people on
     vim.org for help with cleaning it up.

gets formatted incorrectly as:

     asked people on
     vim.org for help with cleaning it up.

But if 'vim' (roman numeral!) is replaced by 'abc'
then it gets formatted as expected:

     asked people on abc.org for help with cleaning it up.


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to