mdisk: Remove color from "Already mounted" message
[sunny256-utils.git] / htmlfold
blob66a698ca1546120bf38badb3d986914ff2c74fb8
1 #!/usr/bin/env perl
3 # htmlfold
4 # File ID: 2c77e8de-5d3d-11df-8a6a-90e6ba3022ac
5 # Inserts fold marks in HTML source before and after stdin.
6 # Select text in visual line mode and filter the block through this script.
8 use strict;
9 use warnings;
10 use Getopt::Std;
11 our ($opt_c, $opt_h) =
12 ( 0, 0);
13 getopts('ch') || die("Option error, use -h for help.");
15 $| = 1;
17 $opt_h && usage(0);
19 my $Line = <STDIN>;
20 my ($Indent, $Title) =
21 ( "", "");
23 defined($ARGV[0]) && ($Title = join(" ", @ARGV) . " ");
24 $Line =~ /^(\s+)/ && ($Indent = $1);
25 my $c_S = $opt_c ? "" : " -->";
26 my $c_E = $opt_c ? "" : "<!-- ";
27 print("$Indent<!-- $Title\x7B\x7B\x7B$c_S\n$Line");
29 while (<STDIN>) {
30 print($_);
33 print("$Indent$c_E$Title\x7D\x7D\x7D -->\n");
35 sub usage {
36 my $Retval = shift;
37 print(<<END);
39 Usage: $0 [options] [Fold_text]
41 Adds Vim fold markers around text read from stdin, hidden by a HTML
42 comment.
44 Options:
46 -c Also comment out the text from stdin instead of creating folds only.
47 -h This help.
49 END
50 exit($Retval);