X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=examples%2Fperltidy_okw.pl;fp=examples%2Fperltidy_okw.pl;h=d12370ffab3af861f17f0b2ffb6c2def56065174;hb=d08e4809a710a08f2cc0cb5a6f3964582098e84c;hp=0000000000000000000000000000000000000000;hpb=045a571b1fb0abc413cd19731ee13b5fc232d0f3;p=perltidy.git diff --git a/examples/perltidy_okw.pl b/examples/perltidy_okw.pl new file mode 100644 index 0000000..d12370f --- /dev/null +++ b/examples/perltidy_okw.pl @@ -0,0 +1,43 @@ +#!/usr/bin/perl -w + +# Example use a perltidy postfilter to outdent certain leading keywords + +# Usage: +# perltidy_okw.pl -sil=1 file.pl + +# This version outdents hardwired keywords 'step', 'command', and 'expected' +# The following is an example of the desired effect. The flag -sil=1 is +# needed to get a starting indentation level so that the outdenting +# is visible. + +=pod +step 4; +command 'Share project: project1'; +expected 'A project megjelenik a serveren'; + shareProject ('project1', 'login', '123', Login => 1, PortalServer => +$openJoinAddress); + valueCheck ('project1_share', listBIMCloudData ('projects')); + + +step 5; +command 'quitAC'; + quitAC (); +=cut + +# Run it exactly like perltidy, and the postfilter removes the +# leading whitespace of lines which begin with your keywords. The +# postfilter works on the file as a single string, so the 'm' quote +# modifier is needed to make the ^ and $ string positioners work + +# See http://perltidy.sourceforge.net/Tidy.html for further details +# on how to call Perl::Tidy +use Perl::Tidy; +my $arg_string = undef; +my $err=Perl::Tidy::perltidy( + argv => $arg_string, + postfilter => + sub { $_ = $_[0]; s/^\s*(step|command|expected)(.*)$/$1$2/gm; return $_ } +); +if ($err) { + die "Error calling perltidy\n"; +}