Loading ...
Sorry, an error occurred while loading the content.

RE: How do you make list items into

Expand Messages
  • Tietjen, Richard
    Here s a set of clips to format text using Perl s amazing Text::Autoformat library, available from CPAN. It will handle all kinds of formatting chores with
    Message 1 of 1 , May 11, 2001
    • 0 Attachment
      Here's a set of clips to format text using Perl's amazing Text::Autoformat
      library, available from CPAN. It will handle all kinds of formatting chores
      with nearly artificial intelligence. I think you could use Text:Wrap or
      Text::Format instead if you didn't want to download Autoformat.

      For example, from the doco:

      In comp.lang.perl.misc you wrote:
      : > <CN = Clooless Noobie> writes:
      : > CN> PERL sux because:
      : > CN> * It doesn't have a switch statement and you have to
      put $
      : > CN>signs in front of everything
      : > CN> * There are too many OR operators: having |, || and
      'or'
      : > CN>operators is confusing
      : > CN> * VB rools, yeah!!!!!!!!!
      : > CN> So anyway, how can I stop reloads on a web page?
      : > CN> Email replies only, thanks - I don't read this
      newsgroup.
      : >
      : > Begone, sirrah! You are a pathetic, Bill-loving,
      microcephalic
      : > script-infant.
      : Sheesh, what's with this group - ask a question, get toasted!
      And how
      : *dare* you accuse me of Ianuphilia!

      The Text::Autoformat module provides a subroutine named `autoformat'
      that wraps text to specified margins. However, `autoformat' reformats
      its input by analysing the text's structure, so it wraps the above
      example like so:

      In comp.lang.perl.misc you wrote:
      : > <CN = Clooless Noobie> writes:
      : > CN> PERL sux because:
      : > CN> * It doesn't have a switch statement and you
      : > CN> have to put $ signs in front of everything
      : > CN> * There are too many OR operators: having |, ||
      : > CN> and 'or' operators is confusing
      : > CN> * VB rools, yeah!!!!!!!!! So anyway, how can I
      : > CN> stop reloads on a web page? Email replies
      : > CN> only, thanks - I don't read this newsgroup.
      : >
      : > Begone, sirrah! You are a pathetic, Bill-loving,
      : > microcephalic script-infant.
      : Sheesh, what's with this group - ask a question, get toasted!
      : And how *dare* you accuse me of Ianuphilia!

      Note that the various quoting conventions have been observed. In fact,
      their structure has been used to determine where some paragraphs begin.
      Furthermore `autoformat' correctly distinguished between the leading '*'
      bullets of the nested list (which were outdented) and the leading
      emphatic '*' of "*dare*" (which was inlined).

      ===========================

      here are the necessary clips:

      The perl code first:

      H="_Reformat script"
      #
      use Text::Autoformat;
      $text = join( '', (<>));

      print autoformat($text,
      {
      all => 1,
      left => 1,
      right => 72,
      justify => 'left',
      fill => 1,
      });

      And a helper 'function' to generalize the process of running perl on a
      buffer:

      H="Perl helper"
      ; helper: expects ^& argument to cotain name of script or clip
      ; to run on current buffer

      ^!Set %script%=^&

      ;Check if a Perl interpreter has been setup. If not, jump to the label
      NoPerl
      ^!IfFileExist ^$GetPerlExe$ Next ELSE NoPerl
      ;Delete the file "StdError.err" from the NoteTab program directory, if it
      exists
      ^!DeleteFile ^$GetAppPath$StdError.err
      ;Execute the Perl interpreter with a script or clip
      ^!RunPerl "^%script%"
      ;If the interpreter generated error messages, load them from the file
      "StdError.err"
      ^!IfFileExist ^$GetAppPath$StdError.err Next ELSE End
      ^!Open ^$GetAppPath$StdError.err
      ^!Prompt Perl has reported some errors!
      ^!GoTo End
      :NoPerl
      ^!Prompt Cannot execute this Clip without a Perl interpreter!


      And the Reformat clip to tie things together for convenient invocation.

      H="Reformat"
      ^!Clip "Perl helper" Reformat script


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.