]> git.donarmstrong.com Git - perltidy.git/commitdiff
add 'perltidy_hide.pl' for testing issue in git #65
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 13 Jun 2021 13:55:11 +0000 (06:55 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 13 Jun 2021 13:55:11 +0000 (06:55 -0700)
examples/perltidy_hide.pl [new file with mode: 0755]

diff --git a/examples/perltidy_hide.pl b/examples/perltidy_hide.pl
new file mode 100755 (executable)
index 0000000..a98a5a1
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+package main;
+use Perl::Tidy;
+
+=pod
+
+Hide sections of as script from perltidy which are between special comments,
+like this:
+
+#<<V
+
+anything between '#<<V' and '#>>V' is hidden from perltidy but seen by perl
+
+#>>V
+
+This works by converting #<<V into =pod and $>>V into =cut before
+processing, and then converting back after processing.
+
+This was created for issue git #65. 
+
+=cut
+
+my $arg_string = undef;
+
+exit Perl::Tidy::perltidy(
+    argv      => $arg_string,
+    prefilter => sub {
+        $_ = $_[0];
+        s/^(#<<V\b.*)$/=pod $1/gm;
+        s/^(#>>V\b.*)$/=cut $1/gm;
+        return $_;
+    },
+    postfilter => sub {
+        $_ = $_[0];
+        s/^=pod (#<<V\b)/$1/gm;
+        s/^=cut (#>>V\b)/$1/gm;
+        return $_;
+    },
+);