3 # This script is used by the config-file target in GNUMakefile.
5 # It removes garbage in the w3m output and separates comments
6 # and active directives.
16 my $unfolding_enabled = 0;
17 my $windows_section_reached = 0;
21 if (!$unfolding_enabled and m/=========/) {
22 # We passed the table of contents
23 # and can try to unfold unintentional
25 $unfolding_enabled = 1;
27 if (m/specific to the Windows GUI/) {
28 # The Windows section is formatted differently.
29 $windows_section_reached = 1;
32 s/^1\. \@\@TITLE\@\@/ /i;
35 $header_len += length($_);
37 } elsif (m/^(\d*\.){1,3}\s/) {
38 # Remove the first digit as it's the
39 # config file section in the User Manual.
42 # If it's a section header, uppercase it.
43 $_ = uc() if (/^\d\.\s+/);
45 # Remember to underline it.
47 $header_len = length($_);
55 # processing a continuation of a @@ line
56 if ( /^\s*$/ ) { # blank line
63 if ($unfolding_enabled and
64 (m/(\s+#)\s*$/ or m/forward-socks5 and$/)) {
69 # XXX: someone should figure out what this stuff
70 # is supposed to do (and if it really does that).
71 s/^# #/####/ if /^# #{12,}/;
75 $hit_option = 1 if s/^#\s+@@//;
77 if ($windows_section_reached) {
78 # Do not drop empty lines in the Windows section
82 print unless (/^\s*$/);
84 if ($hit_header and !$unfold_mode) {
85 # The previous line was a section
86 # header so we better underline it.
87 die "Invalid header length" unless defined $header_len;
88 print "# " . "=" x $header_len . "\n";