X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=utils%2Ffilter2docs.pl;h=1610f16bf3dcf1a5d21a8bb33cb04addca44dd2b;hb=72fa501cd558feaa66398a40ecc0a7d261fe20f5;hp=6e519a9be4437e11b5e9057f539952269a55c67a;hpb=2becf20eaa0440012213c2d424e245ade1866895;p=privoxy.git
diff --git a/utils/filter2docs.pl b/utils/filter2docs.pl
index 6e519a9b..1610f16b 100755
--- a/utils/filter2docs.pl
+++ b/utils/filter2docs.pl
@@ -1,7 +1,6 @@
#!/usr/bin/perl
-# $Id: filter2docs.pl,v 1.3 2008/05/11 12:31:29 fabiankeil Exp $
-# $Source: /cvsroot/ijbswa/current/utils/filter2docs.pl,v $
+# utils/filter2docs.pl
# Parse the filter names and descriptions from a filter file and
# spit out copy&paste-ready markup for the various places in
@@ -10,41 +9,81 @@
use strict;
use warnings;
-die "Usage: $0 filter-file\n" unless (@ARGV == 1) ;
-open(INPUT, "< $ARGV[0]") or die "Coudln't open input file $ARGV[0] because $!\n";
+my (%comment_lines, %action_lines, %sgml_source_1, %sgml_source_2);
-my ($comment_lines, $action_lines, $sgml_source_1, $sgml_source_2);
+sub main() {
-while () {
- if (/^(FILTER): ([-\w]+) (.*)$/) {
- my $type_uc = $1;
- my $name = $2;
- my $description = $3;
- my $type = lc($type_uc);
+ die "Usage: $0 filter-file\n" unless (@ARGV == 1) ;
+ open(INPUT, "< $ARGV[0]") or die "Couldn't open input file $ARGV[0]: $!\n";
- $comment_lines .= "# $name:" . (" " x (20-length($name))) . "$description\n";
- $action_lines .= "+$type" . "{$name} \\\n";
- $sgml_source_1 .= " \n \n +" . $type . "{$name}" .
- (" " x (20-length($name))) . "# $description\n \n";
- $sgml_source_2 .= " -$type" . "{$name} \\\n";
- }
+ parse_file();
+ print_markup();
}
-print <@>@g;
-$comment_lines
+ return $text;
+}
-Block of filter actions for standard.action:
+sub parse_file() {
+ while () {
+ if (/^((?:(?:SERVER|CLIENT)-HEADER-)?(?:FILTER|TAGGER)): ([-\w]+) (.*)$/) {
+ my $type_uc = $1;
+ my $name = $2;
+ my $description = $3;
+ my $type = lc($type_uc);
+ my $sgml_description = sgml_escape($description);
+ my $white_space = ' ' x (($type eq 'filter' ? 20 : 27) - length($name));
+
+ $comment_lines{$type} .= "# $name:" . $white_space . "$description\n";
+ $action_lines{$type} .= "+$type" . "{$name} \\\n";
+ $sgml_source_1{$type} .= " \n \n" .
+ " +$type" . "{$name}" . $white_space .
+ "# $sgml_description\n \n";
+ $sgml_source_2{$type} .= ' -$type" . "{$name} \\\n";
+ }
+ }
+}
-$action_lines
+sub print_markup() {
-SGML Source for AF chapter in U-M:
+ my @filter_types = (
+ 'filter',
+ 'server-header-filter',
+ 'client-header-filter',
+ 'server-header-tagger',
+ 'client-header-tagger'
+ );
+
+ foreach my $type (@filter_types) {
+
+ next unless defined $action_lines{$type};
+
+ print "=" x 90;
+
+ print <<" DOCMARKUP";
-$sgml_source_1
+Producing $type markup:
+Comment lines for default.action.master:
+
+$comment_lines{$type}
+Block of $type actions for default.action.master:
+
+$action_lines{$type}
+SGML Source for AF chapter in U-M:
+
+$sgml_source_1{$type}
SGML Source for AF Tutorial chapter in U-M:
-$sgml_source_2
-DOCMARKUP
+$sgml_source_2{$type}
+ DOCMARKUP
+ }
+}
+
+main();