5 my ($elinks, $option) = @ARGV;
7 if ($option =~ /command/) {
8 open my $pipe, "-|", $elinks, "--long-help" or die;
11 $version =~ s/^ELinks ([-.\w]+).*$/$1/ or die "unusual version: $version";
14 if (/^ {4}(-.*?) *$/) {
15 # ' -anonymous [0|1] (default: 0)'
16 # ' -config-dir <str> (default: "")'
20 } elsif (/^ {12}\t(-eval .*)$/) {
22 } elsif (/^ {12}\t(\w+\(.*\)) +: (.*)$/) {
23 # ' openURL(URL, new-tab) : open URL in new tab'
24 print "\t- `$1`: $2\n";
25 } elsif (/^ {12}\t(\d+) (means .+)$/) {
26 # ' 0 means only show serious errors'
27 print "\t- $1:\t$2\n";
28 } elsif (s/^ {12}//) {
29 s/'([^']+)'/\\'$1\\'/g;
30 s
((~/\.elinks|-dump|-default-mime-type|text/html
|-touch
-files
|-no-connect|-session
-ring
))(`$1`)g
;
31 s/(ELinks|HOME)/'$1'/g;
34 print "\n" unless $blank;
37 $blank = ($blank == 2);
39 print "Generated using output from ELinks version $version.\n";
40 } elsif ($option =~ /config/) {
41 open my $pipe, "-|", $elinks, "--config-help" or die;
42 my $version = <$pipe>;
44 $version =~ s/^ELinks ([-.\w]+).*$/$1/ or die "unusual version: $version";
48 if (/^ {2}[^ ].*: \(([-.\w]+)\)$/) {
49 # ' Active link: (document.browse.links.active_link)'
51 } elsif (/^ {4}([^ ].*?)$/) {
52 # ' bookmarks.file_format <num> (default: 0)'
54 } elsif (/^ {12,}$/) {
57 } elsif (s/^ {12,}//) {
58 # escape things that might look like AsciiDoc markup
60 s/\{(.*?)\}/\\{$1\\}/g;
61 # add the actual AsciiDoc markup
62 s/(ELinks|WWW_HOME)/'$1'/g;
63 s
((~/\
.elinks
))(`$1`)g
;
64 if (/^(-?\d[-+\d]*?) +(.*)$/) {
65 # ' 1+ is use cookie's expiration date, but limit age to the given'
66 print "\t- $1:\t$2\n";
67 } elsif ($continued) {
73 print "\n" unless $blank;
77 $blank = ($blank == 2);
79 print "Generated using output from ELinks version $version.\n";
81 die "usage: $0 ELINKS-EXECUTABLE option-command.txt\n"
82 . " or: $0 ELINKS-EXECUTABLE option-config.txt\n";