about summary refs log tree commit diff stats
path: root/scripts/cfg2html.pl
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2012-02-20 02:08:17 -0500
committerThomas E. Dickey <dickey@invisible-island.net>2012-02-20 02:08:17 -0500
commitbc0fa578036583231edb567b328b4f69ce6860fe (patch)
tree99b322070bf62270218a0d80257a1f50bbefe147 /scripts/cfg2html.pl
parentbb5fd6e44e480f571bcb713788cc50eea44095e5 (diff)
downloadgenerated by cgit-pink 1.4.1-2-gfad0 (git 2.36.2.497.gbbea4dcf42) at 2025-07-05 06:13:58 +0000 ; + if ( $h1 ne "" ) { + printf FP " &ndash; <a href=\"cattoc.html#%s\">%s</a>", $cats{$h1}, $h1; + } + printf FP "</h2>\n"; + printf FP "<h3><em>Description</em></h3>\n"; + $any++; + $first = 0; + } + + # Convert tabs first, to retain relative alignment + $c =~ s#^\t#' 'x8#e; + while ( $c =~ /\t/ ) { + $c =~ s#(^[^\t]+)\t#$1 . $sp x (9 - (length($1) % 8 ))#e; + } + + # Strip off the comment marker + $c =~ s/^#//; + + # and convert simple expressions: + $c =~ s/&/&amp;/g; + $c =~ s/>/&gt;/g; + $c =~ s/</&lt;/g; + #hvv - something wrong was with next statement + $c =~ s/'([^ ])'/"<strong>$1<\/strong>"/g; + + my $k = 0; + if ( $c =~ /^[[:alpha:]_][[:alnum:]_]+:/ ) { + $t = $c; + $t =~ s/:.*//; + $k = $keys{$t}; + } + + if ( $c =~ /^$/ ) { + if ( $nf ) { + printf FP "\n"; + } else { + $p = 1; + } + } elsif ( $ex != 0 ) { + printf FP "<br><code>%s</code><br>\n", $c; + $ex--; + } elsif ( $k ) { + if ( $d != $n && ! $nf ) { + printf FP "<h3><em>Default value</em></h3>\n"; + } + $c =~ s/:$/:<em>none<\/em>/; + $c =~ s/:/<\/code>:<code>/; + $c = "<code>" . $c . "</code>"; + if ( ! $nf ) { + $c .= "<br>"; + } + printf FP "%s\n", $c; + $d = $n + 1; + } else { + if ( $p && ! $nf ) { + printf FP "<p>\n"; + } + $p = 0; + if ( $input[$n+1] =~ /^#\s*==/ ) { + $c = "<br><em>$c</em>"; + if ( ! $nf ) { + $c .= "<br>"; + } + $next++; + } + printf FP "%s\n", $c; + } + if ( $nf != 0 && $nf-- == 0 ) { + printf FP "</pre>\n"; + } + } + } + close(FP); + # Here we collect files with description of needed lynx.cfg + # options in the proper (natural or sorted) order. + open(FP,">>$output") || do { + print STDERR "Can't open $output: $!\n"; + return; + }; + { + my @ordered = (defined $opt_s ? (sort keys(%optname_to_fname)) : @optnames); + if (defined $opt_s) { + print FP "Options are sorted by name.\n"; + } else { + print FP "Options are in the same order as lynx.cfg.\n"; + } + foreach $l (@ordered) { + my $fnm = $tmpdir . $optname_to_fname{$l}; + open(FP1,"<$fnm") || do { + print STDERR "Can't open $fnm: $!\n"; + return; + }; + my $avail = ok($l); + if (defined $opt_a || $avail) { + my @lines = <FP1>; + print FP @lines; + if (!$avail && defined $opt_m) { + print FP <<'EOF'; +<p>Support for this setting was disabled at compile-time. +EOF + } + } + close(FP1); + } + foreach $l (values(%optname_to_fname)) { + unlink $l; + } + } + + print FP <<'EOF'; +</body> +</html> +EOF + close(FP); +} + +sub gen_cattoc { + my @input = @_; + my @major; + my %descs; + my %index; + my ($n, $m, $c, $d, $found, $h1, $nf, $ex, $count, $once); + my $output = "cattoc.html"; + + open(FP,">$output") || do { + print STDERR "Can't open $output: $!\n"; + return; + }; + print FP <<'EOF'; +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<link rev="made" href="mailto:lynx-dev@nongnu.org"> +<title>Settings by category</title> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> +</head> +<body> +<h1>Settings by category</h1> +These are the major categories of configuration settings in Lynx: +<ul> +EOF + $m = -1; + $h1 = 0; + $nf = 0; + for $n (0..$#input) { + my $count = $#input; + my $once = 1; + $c = $input[$n]; + if ( $input[$n] =~ /^\.h1\s/ ) { + $h1 = 1; + $c =~ s/^.h1\s*//; + $m = $#major + 1; + $d = 0; + $found = 0; + while ( $d <= $#major && ! $found ) { + if ( $major[$d] eq $c ) { + $m = $d; + $found = 1; + } + $d++; + } + if ( ! $found ) { + $major[$m] = $c; + $descs{$major[$m]} = ""; + $index{$major[$m]} = ""; + } + next; + } elsif ( $h1 != 0 ) { + if ( $c =~ /^\.(nf|ex)/ ) { + my $s = $c; + $s =~ s/^\.[[:lower:]]+\s//; + if ( $s =~ /^[[:digit:]]+$/ ) { + $count = $s; + $once = $s; + } + } + if ( $input[$n] =~ /^$/ ) { + $h1 = 0; + } elsif ( $input[$n] =~ /^\.nf/ ) { + $descs{$major[$m]} .= "<pre>" . "\n"; + $nf = $count; + } elsif ( $input[$n] =~ /^\.fi/ ) { + $descs{$major[$m]} .= "</pre>" . "\n"; + $nf = 0; + } elsif ( $input[$n] =~ /^\.ex/ ) { + $ex = $once; + $descs{$major[$m]} .= + "<h3><em>Example" + . + ($ex > 1 ? "s" : "") + . + ":</em></h3>\n" + . "\n"; + } elsif ( $input[$n] =~ /^\s*#/ ) { + $c = $input[$n]; + $c =~ s/^\s*#\s*//; + $descs{$major[$m]} .= $c . "\n"; + } + } + if ( $m >= 0 && $input[$n] =~ /^\.h2\s/ ) { + $c = $input[$n]; + $c =~ s/^.h2\s*//; + $index{$major[$m]} .= $c . "\n" + if (defined $opt_a || ok($c)); + $h1 = 0; + } + if ( $nf != 0 && $nf-- == 0 ) { + $descs{$major[$m]} .= "</pre>\n"; + } + } + @major = sort @major; + for $n (0..$#major) { + $cats{$major[$n]} = sprintf("header%03d", $n); + printf FP "<li><a href=\"#%s\">%s</a>\n", $cats{$major[$n]}, $major[$n]; + } + printf FP "</ul>\n"; + for $n (0..$#major) { + printf FP "\n"; + printf FP "<h2><a name=\"%s\">%s</a></h2>\n", $cats{$major[$n]}, $major[$n]; + if ($descs{$major[$n]} !~ /^$/) { + printf FP "<h3>Description</h3>\n%s\n", $descs{$major[$n]}; + } + $c = $index{$major[$n]}; + if ( $c ne "" ) { + my @c = split(/\n/, $c); + @c = sort @c; + printf FP "<p>Here is a list of settings that belong to this category\n"; + printf FP "<ul>\n"; + for $m (0..$#c) { + my $avail = ok($c[$m]); + my $mark = (!$avail && defined $opt_m) ? "*" : ""; + printf FP "<li><a href=\"body.html#%s\">%s</a>\n", $c[$m], $c[$m] . $mark; + } + printf FP "</ul>\n"; + } + } + my $str = <<'EOF' +<p> +<a href=alphatoc.html>To list of settings by name</a> +EOF +. (defined $opt_a && defined $opt_m ? +"<p>Support for all settings suffixed with '*' was disabled at compile time." : + "") . <<'EOF' +</body> +</html> +EOF + ;print FP $str; + close(FP); + return @cats; +}