diff --git a/manuals/scripts/check_tex.pl b/manuals/scripts/check_tex.pl deleted file mode 100755 index 6a0deff..0000000 --- a/manuals/scripts/check_tex.pl +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/perl -w -# Finds potential problems in tex files, and issues warnings to the console -# about what it finds. Takes a list of files as its only arguments, -# and does checks on all the files listed. The assumption is that these are -# valid (or close to valid) LaTeX files. It follows \include statements -# recursively to pick up any included tex files. -# -# -# -# Currently the following checks are made: -# -# -- Multiple hyphens not inside a verbatim environment (or \verb). These -# should be placed inside a \verb{} contruct so they will not be converted -# to single hyphen by latex and latex2html. - - -# Original creation 3-8-05 by Karl Cunningham karlc -at- keckec -dot- com -# -# - -use strict; - -# The following builds the test string to identify and change multiple -# hyphens in the tex files. Several constructs are identified but only -# multiple hyphens are changed; the others are fed to the output -# unchanged. -my $b = '\\\\begin\\*?\\s*\\{\\s*'; # \begin{ -my $e = '\\\\end\\*?\\s*\\{\\s*'; # \end{ -my $c = '\\s*\\}'; # closing curly brace - -# This captures entire verbatim environments. These are passed to the output -# file unchanged. -my $verbatimenv = $b . "verbatim" . $c . ".*?" . $e . "verbatim" . $c; - -# This captures \verb{..{ constructs. They are passed to the output unchanged. -my $verb = '\\\\verb\\*?(.).*?\\1'; - -# This captures multiple hyphens with a leading and trailing space. These are not changed. -my $hyphsp = '\\s\\-{2,}\\s'; - -# This identifies other multiple hyphens. -my $hyphens = '\\-{2,}'; - -# This identifies \hyperpage{..} commands, which should be ignored. -my $hyperpage = '\\\\hyperpage\\*?\\{.*?\\}'; - -# This builds the actual test string from the above strings. -#my $teststr = "$verbatimenv|$verb|$tocentry|$hyphens"; -my $teststr = "$verbatimenv|$verb|$hyphsp|$hyperpage|$hyphens"; - - -sub get_includes { - # Get a list of include files from the top-level tex file. The first - # argument is a pointer to the list of files found. The rest of the - # arguments is a list of filenames to check for includes. - my $files = shift; - my ($fileline,$includefile,$includes); - - while (my $filename = shift) { - # Get a list of all the html files in the directory. - open my $if,"<$filename" or die "Cannot open input file $filename\n"; - $fileline = 0; - $includes = 0; - while (<$if>) { - chomp; - $fileline++; - # If a file is found in an include, process it. - if (($includefile) = /\\include\s*\{(.*?)\}/) { - $includes++; - # Append .tex to the filename - $includefile .= '.tex'; - - # If the include file has already been processed, issue a warning - # and don't do it again. - my $found = 0; - foreach (@$files) { - if ($_ eq $includefile) { - $found = 1; - last; - } - } - if ($found) { - print "$includefile found at line $fileline in $filename was previously included\n"; - } else { - # The file has not been previously found. Save it and - # recursively process it. - push (@$files,$includefile); - get_includes($files,$includefile); - } - } - } - close IF; - } -} - - -sub check_hyphens { - my (@files) = @_; - my ($filedata,$this,$linecnt,$before); - - # Build the test string to check for the various environments. - # We only do the conversion if the multiple hyphens are outside of a - # verbatim environment (either \begin{verbatim}...\end{verbatim} or - # \verb{--}). Capture those environments and pass them to the output - # unchanged. - - foreach my $file (@files) { - # Open the file and load the whole thing into $filedata. A bit wasteful but - # easier to deal with, and we don't have a problem with speed here. - $filedata = ""; - open IF,"<$file" or die "Cannot open input file $file"; - while () { - $filedata .= $_; - } - close IF; - - # Set up to process the file data. - $linecnt = 1; - - # Go through the file data from beginning to end. For each match, save what - # came before it and what matched. $filedata now becomes only what came - # after the match. - # Chech the match to see if it starts with a multiple-hyphen. If so - # warn the user. Keep track of line numbers so they can be output - # with the warning message. - while ($filedata =~ /$teststr/os) { - $this = $&; - $before = $`; - $filedata = $'; - $linecnt += $before =~ tr/\n/\n/; - - # Check if the multiple hyphen is present outside of one of the - # acceptable constructs. - if ($this =~ /^\-+/) { - print "Possible unwanted multiple hyphen found in line ", - "$linecnt of file $file\n"; - } - $linecnt += $this =~ tr/\n/\n/; - } - } -} -################################################################## -# MAIN #### -################################################################## - -my (@includes,$cnt); - -# Examine the file pointed to by the first argument to get a list of -# includes to test. -get_includes(\@includes,@ARGV); - -check_hyphens(@includes); diff --git a/manuals/scripts/fix_tex.pl b/manuals/scripts/fix_tex.pl deleted file mode 100755 index e8bb0ca..0000000 --- a/manuals/scripts/fix_tex.pl +++ /dev/null @@ -1,184 +0,0 @@ -#!/usr/bin/perl -w -# Fixes various things within tex files. - -use strict; - -my %args; - - -sub get_includes { - # Get a list of include files from the top-level tex file. - my (@list,$file); - - foreach my $filename (@_) { - $filename or next; - # Start with the top-level latex file so it gets checked too. - push (@list,$filename); - - # Get a list of all the html files in the directory. - open IF,"<$filename" or die "Cannot open input file $filename"; - while () { - chomp; - push @list,"$1.tex" if (/\\include\{(.*?)\}/); - } - - close IF; - } - return @list; -} - -sub convert_files { - my (@files) = @_; - my ($linecnt,$filedata,$output,$itemcnt,$indentcnt,$cnt); - - $cnt = 0; - foreach my $file (@files) { - # Open the file and load the whole thing into $filedata. A bit wasteful but - # easier to deal with, and we don't have a problem with speed here. - $filedata = ""; - open IF,"<$file" or die "Cannot open input file $file"; - while () { - $filedata .= $_; - } - close IF; - - # We look for a line that starts with \item, and indent the two next lines (if not blank) - # by three spaces. - my $linecnt = 3; - $indentcnt = 0; - $output = ""; - # Process a line at a time. - foreach (split(/\n/,$filedata)) { - $_ .= "\n"; # Put back the return. - # If this line is less than the third line past the \item command, - # and the line isn't blank and doesn't start with whitespace - # add three spaces to the start of the line. Keep track of the number - # of lines changed. - if ($linecnt < 3 and !/^\\item/) { - if (/^[^\n\s]/) { - $output .= " " . $_; - $indentcnt++; - } else { - $output .= $_; - } - $linecnt++; - } else { - $linecnt = 3; - $output .= $_; - } - /^\\item / and $linecnt = 1; - } - - - # This is an item line. We need to process it too. If inside a \begin{description} environment, convert - # \item {\bf xxx} to \item [xxx] or \item [{xxx}] (if xxx contains '[' or ']'. - $itemcnt = 0; - $filedata = $output; - $output = ""; - my ($before,$descrip,$this,$between); - - # Find any \begin{description} environment - while ($filedata =~ /(\\begin[\s\n]*\{[\s\n]*description[\s\n]*\})(.*?)(\\end[\s\n]*\{[\s\n]*description[\s\n]*\})/s) { - $output .= $` . $1; - $filedata = $3 . $'; - $descrip = $2; - - # Search for \item {\bf xxx} - while ($descrip =~ /\\item[\s\n]*\{[\s\n]*\\bf[\s\n]*/s) { - $descrip = $'; - $output .= $`; - ($between,$descrip) = find_matching_brace($descrip); - if (!$descrip) { - $linecnt = $output =~ tr/\n/\n/; - print STDERR "Missing matching curly brace at line $linecnt in $file\n" if (!$descrip); - } - - # Now do the replacement. - $between = '{' . $between . '}' if ($between =~ /\[|\]/); - $output .= "\\item \[$between\]"; - $itemcnt++; - } - $output .= $descrip; - } - $output .= $filedata; - - # If any hyphens or \item commnads were converted, save the file. - if ($indentcnt or $itemcnt) { - open OF,">$file" or die "Cannot open output file $file"; - print OF $output; - close OF; - print "$indentcnt indent", ($indentcnt == 1) ? "" : "s"," added in $file\n"; - print "$itemcnt item", ($itemcnt == 1) ? "" : "s"," Changed in $file\n"; - } - - $cnt += $indentcnt + $itemcnt; - } - return $cnt; -} - -sub find_matching_brace { - # Finds text up to the next matching brace. Assumes that the input text doesn't contain - # the opening brace, but we want to find text up to a matching closing one. - # Returns the text between the matching braces, followed by the rest of the text following - # (which does not include the matching brace). - # - my $str = shift; - my ($this,$temp); - my $cnt = 1; - - while ($cnt) { - # Ignore verbatim constructs involving curly braces, or if the character preceding - # the curly brace is a backslash. - if ($str =~ /\\verb\*?\{.*?\{|\\verb\*?\}.*?\}|\{|\}/s) { - $this .= $`; - $str = $'; - $temp = $&; - - if ((substr($this,-1,1) eq '\\') or - $temp =~ /^\\verb/) { - $this .= $temp; - next; - } - - $cnt += ($temp eq '{') ? 1 : -1; - # If this isn't the matching curly brace ($cnt > 0), include the brace. - $this .= $temp if ($cnt); - } else { - # No matching curly brace found. - return ($this . $str,''); - } - } - return ($this,$str); -} - -sub check_arguments { - # Checks command-line arguments for ones starting with -- puts them into - # a hash called %args and removes them from @ARGV. - my $args = shift; - my $i; - - for ($i = 0; $i < $#ARGV; $i++) { - $ARGV[$i] =~ /^\-+/ or next; - $ARGV[$i] =~ s/^\-+//; - $args{$ARGV[$i]} = ""; - delete ($ARGV[$i]); - - } -} - -################################################################## -# MAIN #### -################################################################## - -my @includes; -my $cnt; - -check_arguments(\%args); -die "No Files given to Check\n" if ($#ARGV < 0); - -# Examine the file pointed to by the first argument to get a list of -# includes to test. -@includes = get_includes(@ARGV); - -$cnt = convert_files(@includes); -print "No lines changed\n" unless $cnt; diff --git a/manuals/scripts/index.pl b/manuals/scripts/index.pl deleted file mode 100644 index 2f0a55b..0000000 --- a/manuals/scripts/index.pl +++ /dev/null @@ -1,564 +0,0 @@ -# This module does multiple indices, supporting the style of the LaTex 'index' -# package. - -# Version Information: -# 16-Feb-2005 -- Original Creation. Karl E. Cunningham -# 14-Mar-2005 -- Clarified and Consolodated some of the code. -# Changed to smoothly handle single and multiple indices. - -# Two LaTeX index formats are supported... -# --- SINGLE INDEX --- -# \usepackage{makeidx} -# \makeindex -# \index{entry1} -# \index{entry2} -# \index{entry3} -# ... -# \printindex -# -# --- MULTIPLE INDICES --- -# -# \usepackage{makeidx} -# \usepackage{index} -# \makeindex -- latex2html doesn't care but LaTeX does. -# \newindex{ref1}{ext1}{ext2}{title1} -# \newindex{ref2}{ext1}{ext2}{title2} -# \newindex{ref3}{ext1}{ext2}{title3} -# \index[ref1]{entry1} -# \index[ref1]{entry2} -# \index[ref3]{entry3} -# \index[ref2]{entry4} -# \index{entry5} -# \index[ref3]{entry6} -# ... -# \printindex[ref1] -# \printindex[ref2] -# \printindex[ref3] -# \printindex -# ___________________ -# -# For the multiple-index style, each index is identified by the ref argument to \newindex, \index, -# and \printindex. A default index is allowed, which is indicated by omitting the optional -# argument. The default index does not require a \newindex command. As \index commands -# are encountered, their entries are stored according -# to the ref argument. When the \printindex command is encountered, the stored index -# entries for that argument are retrieved and printed. The title for each index is taken -# from the last argument in the \newindex command. -# While processing \index and \printindex commands, if no argument is given the index entries -# are built into a default index. The title of the default index is simply "Index". -# This makes the difference between single- and multiple-index processing trivial. -# -# Another method can be used by omitting the \printindex command and just using \include to -# pull in index files created by the makeindex program. These files will start with -# \begin{theindex}. This command is used to determine where to print the index. Using this -# approach, the indices will be output in the same order as the newindex commands were -# originally found (see below). Using a combination of \printindex and \include{indexfile} has not -# been tested and may produce undesireable results. -# -# The index data are stored in a hash for later sorting and output. As \printindex -# commands are handled, the order in which they were found in the tex filea is saved, -# associated with the ref argument to \printindex. -# -# We use the original %index hash to store the index data into. We append a \002 followed by the -# name of the index to isolate the entries in different indices from each other. This is necessary -# so that different indices can have entries with the same name. For the default index, the \002 is -# appended without the name. -# -# Since the index order in the output cannot be determined if the \include{indexfile} -# command is used, the order will be assumed from the order in which the \newindex -# commands were originally seen in the TeX files. This order is saved as well as the -# order determined from any printindex{ref} commands. If \printindex commnads are used -# to specify the index output, that order will be used. If the \include{idxfile} command -# is used, the order of the original newindex commands will be used. In this case the -# default index will be printed last since it doesn't have a corresponding \newindex -# command and its order cannot be determined. Mixing \printindex and \include{idxfile} -# commands in the same file is likely to produce less than satisfactory results. -# -# -# The hash containing index data is named %indices. It contains the following data: -#{ -# 'title' => { -# $ref1 => $indextitle , -# $ref2 => $indextitle , -# ... -# }, -# 'newcmdorder' => [ ref1, ref2, ..., * ], # asterisk indicates the position of the default index. -# 'printindorder' => [ ref1, ref2, ..., * ], # asterisk indicates the position of the default index. -#} - - -# Globals to handle multiple indices. -my %indices; - -# This tells the system to use up to 7 words in index entries. -$WORDS_IN_INDEX = 10; - -# KEC 2-18-05 -# Handles the \newindex command. This is called if the \newindex command is -# encountered in the LaTex source. Gets the index ref and title from the arguments. -# Saves the index ref and title. -# Note that we are called once to handle multiple \newindex commands that are -# newline-separated. -sub do_cmd_newindex { - my $data = shift; - # The data is sent to us as fields delimited by their ID #'s. We extract the - # fields. - foreach my $line (split("\n",$data)) { - my @fields = split (/(?:\<\#\d+?\#\>)+/,$line); - - # The index name and title are the second and fourth fields in the data. - if ($line =~ /^ \001 - # @ -> \002 - # | -> \003 - $* = 1; $str =~ s/\n\s*/ /g; $* = 0; # remove any newlines - # protect \001 occurring with images - $str =~ s/\001/\016/g; # 0x1 to 0xF - $str =~ s/\\\\/\011/g; # Double backslash -> 0xB - $str =~ s/\\;SPMquot;/\012/g; # \;SPMquot; -> 0xC - $str =~ s/;SPMquot;!/\013/g; # ;SPMquot; -> 0xD - $str =~ s/!/\001/g; # Exclamation point -> 0x1 - $str =~ s/\013/!/g; # 0xD -> Exclaimation point - $str =~ s/;SPMquot;@/\015/g; # ;SPMquot;@ to 0xF - $str =~ s/@/\002/g; # At sign -> 0x2 - $str =~ s/\015/@/g; # 0xF to At sign - $str =~ s/;SPMquot;\|/\017/g; # ;SMPquot;| to 0x11 - $str =~ s/\|/\003/g; # Vertical line to 0x3 - $str =~ s/\017/|/g; # 0x11 to vertical line - $str =~ s/;SPMquot;(.)/\1/g; # ;SPMquot; -> whatever the next character is - $str =~ s/\012/;SPMquot;/g; # 0x12 to ;SPMquot; - $str =~ s/\011/\\\\/g; # 0x11 to double backslash - local($key_part, $pageref) = split("\003", $str, 2); - - # For any keys of the form: blablabla!blablabla, which want to be split at the - # exclamation point, replace the ! with a comma and a space. We don't do it - # that way for this index. - $key_part =~ s/\001/, /g; - local(@keys) = split("\001", $key_part); - # If TITLE is not yet available use $before. - $TITLE = $saved_title if (($saved_title)&&(!($TITLE)||($TITLE eq $default_title))); - $TITLE = $before unless $TITLE; - # Save the reference - local($words) = ''; - if ($SHOW_SECTION_NUMBERS) { $words = &make_idxnum; } - elsif ($SHORT_INDEX) { $words = &make_shortidxname; } - else { $words = &make_idxname; } - local($super_key) = ''; - local($sort_key, $printable_key, $cur_key); - foreach $key (@keys) { - $key =~ s/\016/\001/g; # revert protected \001s - ($sort_key, $printable_key) = split("\002", $key); - # - # RRM: 16 May 1996 - # any \label in the printable-key will have already - # created a label where the \index occurred. - # This has to be removed, so that the desired label - # will be found on the Index page instead. - # - if ($printable_key =~ /tex2html_anchor_mark/ ) { - $printable_key =~ s/><\/A>$cross_ref_mark/ - $printable_key =~ s/$cross_ref_mark#([^#]+)#([^>]+)>$cross_ref_mark/ - do { ($label,$id) = ($1,$2); - $ref_label = $external_labels{$label} unless - ($ref_label = $ref_files{$label}); - '"' . "$ref_label#$label" . '">' . - &get_ref_mark($label,$id)} - /geo; - } - $printable_key =~ s/<\#[^\#>]*\#>//go; - #RRM - # recognise \char combinations, for a \backslash - # - $printable_key =~ s/\&\#;\'134/\\/g; # restore \\s - $printable_key =~ s/\&\#;\`
/\\/g; # ditto - $printable_key =~ s/\&\#;*SPMquot;92/\\/g; # ditto - # - # $sort_key .= "@$printable_key" if !($printable_key); # RRM - $sort_key .= "@$printable_key" if !($sort_key); # RRM - $sort_key =~ tr/A-Z/a-z/; - if ($super_key) { - $cur_key = $super_key . "\001" . $sort_key; - $sub_index{$super_key} .= $cur_key . "\004"; - } else { - $cur_key = $sort_key; - } - - # Append the $index_name to the current key with a \002 delimiter. This will - # allow the same index entry to appear in more than one index. - $index_key = $cur_key . "\002$index_name"; - - $index{$index_key} .= ""; - - # - # RRM, 15 June 1996 - # if there is no printable key, but one is known from - # a previous index-entry, then use it. - # - if (!($printable_key) && ($printable_key{$index_key})) - { $printable_key = $printable_key{$index_key}; } -# if (!($printable_key) && ($printable_key{$cur_key})) -# { $printable_key = $printable_key{$cur_key}; } - # - # do not overwrite the printable_key if it contains an anchor - # - if (!($printable_key{$index_key} =~ /tex2html_anchor_mark/ )) - { $printable_key{$index_key} = $printable_key || $key; } -# if (!($printable_key{$cur_key} =~ /tex2html_anchor_mark/ )) -# { $printable_key{$cur_key} = $printable_key || $key; } - - $super_key = $cur_key; - } - # - # RRM - # page-ranges, from |( and |) and |see - # - if ($pageref) { - if ($pageref eq "\(" ) { - $pageref = ''; - $next .= " from "; - } elsif ($pageref eq "\)" ) { - $pageref = ''; - local($next) = $index{$index_key}; -# local($next) = $index{$cur_key}; - # $next =~ s/[\|] *$//; - $next =~ s/(\n )?\| $//; - $index{$index_key} = "$next to "; -# $index{$cur_key} = "$next to "; - } - } - - if ($pageref) { - $pageref =~ s/\s*$//g; # remove trailing spaces - if (!$pageref) { $pageref = ' ' } - $pageref =~ s/see/see <\/i> /g; - # - # RRM: 27 Dec 1996 - # check if $pageref corresponds to a style command. - # If so, apply it to the $words. - # - local($tmp) = "do_cmd_$pageref"; - if (defined &$tmp) { - $words = &$tmp("<#0#>$words<#0#>"); - $words =~ s/<\#[^\#]*\#>//go; - $pageref = ''; - } - } - # - # RRM: 25 May 1996 - # any \label in the pageref section will have already - # created a label where the \index occurred. - # This has to be removed, so that the desired label - # will be found on the Index page instead. - # - if ($pageref) { - if ($pageref =~ /tex2html_anchor_mark/ ) { - $pageref =~ s/><\/A>
$cross_ref_mark/ - $pageref =~ s/$cross_ref_mark#([^#]+)#([^>]+)>$cross_ref_mark/ - do { ($label,$id) = ($1,$2); - $ref_files{$label} = ''; # ???? RRM - if ($index_labels{$label}) { $ref_label = ''; } - else { $ref_label = $external_labels{$label} - unless ($ref_label = $ref_files{$label}); - } - '"' . "$ref_label#$label" . '">' . &get_ref_mark($label,$id)}/geo; - } - $pageref =~ s/<\#[^\#>]*\#>//go; - - if ($pageref eq ' ') { $index{$index_key}='@'; } - else { $index{$index_key} .= $pageref . "\n | "; } - } else { - local($thisref) = &make_named_href('',"$CURRENT_FILE#$br_id",$words); - $thisref =~ s/\n//g; - $index{$index_key} .= $thisref."\n | "; - } - #print "\nREF: $sort_key : $index_key :$index{$index_key}"; - - #join('',"$anchor_invisible_mark<\/A>",$_); - - "$anchor_invisible_mark<\/A>"; -} - - -# KEC. -- Copied from makeidx.perl, then modified to do multiple indices. -# Feeds the index entries to the output. This is called for each index to be built. -# -# Generates a list of lookup keys for index entries, from both %printable_keys -# and %index keys. -# Sorts the keys according to index-sorting rules. -# Removes keys with a 0x01 token. (duplicates?) -# Builds a string to go to the index file. -# Adds the index entries to the string if they belong in this index. -# Keeps track of which index is being worked on, so only the proper entries -# are included. -# Places the index just built in to the output at the proper place. -{ my $index_number = 0; -sub add_real_idx { - print "\nDoing the index ... Index Number $index_number\n"; - local($key, @keys, $next, $index, $old_key, $old_html); - my ($idx_ref,$keyref); - # RRM, 15.6.96: index constructed from %printable_key, not %index - @keys = keys %printable_key; - - while (/$idx_mark/) { - # Get the index reference from what follows the $idx_mark and - # remove it from the string. - s/$idxmark\002(.*?)\002/$idxmark/; - $idx_ref = $1; - $index = ''; - # include non- makeidx index-entries - foreach $key (keys %index) { - next if $printable_key{$key}; - $old_key = $key; - if ($key =~ s/###(.*)$//) { - next if $printable_key{$key}; - push (@keys, $key); - $printable_key{$key} = $key; - if ($index{$old_key} =~ /HREF="([^"]*)"/i) { - $old_html = $1; - $old_html =~ /$dd?([^#\Q$dd\E]*)#/; - $old_html = $1; - } else { $old_html = '' } - $index{$key} = $index{$old_key} . $old_html."\n | "; - }; - } - @keys = sort makeidx_keysort @keys; - @keys = grep(!/\001/, @keys); - my $cnt = 0; - foreach $key (@keys) { - my ($keyref) = $key =~ /.*\002(.*)/; - next unless ($idx_ref eq $keyref); # KEC. - $index .= &add_idx_key($key); - $cnt++; - } - print "$cnt Index Entries Added\n"; - $index = '
'.$index unless ($index =~ /^\s*/); - $index_number++; # KEC. - if ($SHORT_INDEX) { - print "(compact version with Legend)"; - local($num) = ( $index =~ s/\ 50 ) { - s/$idx_mark/$preindex
\n$index\n<\/DL>$preindex/o; - } else { - s/$idx_mark/$preindex
\n$index\n<\/DL>/o; - } - } else { - s/$idx_mark/
\n$index\n<\/DL>/o; } - } -} -} - -# KEC. Copied from latex2html.pl and modified to support multiple indices. -# The bibliography and the index should be treated as separate sections -# in their own HTML files. The \bibliography{} command acts as a sectioning command -# that has the desired effect. But when the bibliography is constructed -# manually using the thebibliography environment, or when using the -# theindex environment it is not possible to use the normal sectioning -# mechanism. This subroutine inserts a \bibliography{} or a dummy -# \textohtmlindex command just before the appropriate environments -# to force sectioning. -sub add_bbl_and_idx_dummy_commands { - local($id) = $global{'max_id'}; - - s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg; - ## if ($bbl_cnt == 1) { - s/([\\]begin\s*$O\d+$C\s*thebibliography)/$id++; "\\bibliography$O$id$C$O$id$C $1"/geo; - #} - $global{'max_id'} = $id; - # KEC. Modified to global substitution to place multiple index tokens. - s/[\\]begin\s*($O\d+$C)\s*theindex/\\textohtmlindex$1/go; - # KEC. Modified to pick up the optional argument to \printindex - s/[\\]printindex\s*(\[.*?\])?/ - do { (defined $1) ? "\\textohtmlindex $1" : "\\textohtmlindex []"; } /ego; - &lib_add_bbl_and_idx_dummy_commands() if defined(&lib_add_bbl_and_idx_dummy_commands); -} - -# KEC. Copied from latex2html.pl and modified to support multiple indices. -# For each textohtmlindex mark found, determine the index titles and headers. -# We place the index ref in the header so the proper index can be generated later. -# For the default index, the index ref is blank. -# -# One problem is that this routine is called twice.. Once for processing the -# command as originally seen, and once for processing the command when -# doing the name for the index file. We can detect that by looking at the -# id numbers (or ref) surrounding the \theindex command, and not incrementing -# index_number unless a new id (or ref) is seen. This has the side effect of -# having to unconventionally start the index_number at -1. But it works. -# -# Gets the title from the list of indices. -# If this is the first index, save the title in $first_idx_file. This is what's referenced -# in the navigation buttons. -# Increment the index_number for next time. -# If the indexname command is defined or a newcommand defined for indexname, do it. -# Save the index TITLE in the toc -# Save the first_idx_file into the idxfile. This goes into the nav buttons. -# Build index_labels if needed. -# Create the index headings and put them in the output stream. - -{ my $index_number = 0; # Will be incremented before use. - my $first_idx_file; # Static - my $no_increment = 0; - -sub do_cmd_textohtmlindex { - local($_) = @_; - my ($idxref,$idxnum,$index_name); - - # We get called from make_name with the first argument = "\001noincrement". This is a sign - # to not increment $index_number the next time we are called. We get called twice, once - # my make_name and once by process_command. Unfortunately, make_name calls us just to set the name - # but doesn't use the result so we get called a second time by process_command. This works fine - # except for cases where there are multiple indices except if they aren't named, which is the case - # when the index is inserted by an include command in latex. In these cases we are only able to use - # the index number to decide which index to draw from, and we don't know how to increment that index - # number if we get called a variable number of times for the same index, as is the case between - # making html (one output file) and web (multiple output files) output formats. - if (/\001noincrement/) { - $no_increment = 1; - return; - } - - # Remove (but save) the index reference - s/^\s*\[(.*?)\]/{$idxref = $1; "";}/e; - - # If we have an $idxref, the index name was specified. In this case, we have all the - # information we need to carry on. Otherwise, we need to get the idxref - # from the $index_number and set the name to "Index". - if ($idxref) { - $index_name = $indices{'title'}{$idxref}; - } else { - if (defined ($idxref = $indices{'newcmdorder'}->[$index_number])) { - $index_name = $indices{'title'}{$idxref}; - } else { - $idxref = ''; - $index_name = "Index"; - } - } - - $idx_title = "Index"; # The name displayed in the nav bar text. - - # Only set $idxfile if we are at the first index. This will point the - # navigation panel to the first index file rather than the last. - $first_idx_file = $CURRENT_FILE if ($index_number == 0); - $idxfile = $first_idx_file; # Pointer for the Index button in the nav bar. - $toc_sec_title = $index_name; # Index link text in the toc. - $TITLE = $toc_sec_title; # Title for this index, from which its filename is built. - if (%index_labels) { &make_index_labels(); } - if (($SHORT_INDEX) && (%index_segment)) { &make_preindex(); } - else { $preindex = ''; } - local $idx_head = $section_headings{'textohtmlindex'}; - local($heading) = join('' - , &make_section_heading($TITLE, $idx_head) - , $idx_mark, "\002", $idxref, "\002" ); - local($pre,$post) = &minimize_open_tags($heading); - $index_number++ unless ($no_increment); - $no_increment = 0; - join('',"
\n" , $pre, $_); -} -} - -# Returns an index key, given the key passed as the first argument. -# Not modified for multiple indices. -sub add_idx_key { - local($key) = @_; - local($index, $next); - if (($index{$key} eq '@' )&&(!($index_printed{$key}))) { - if ($SHORT_INDEX) { $index .= "

\n
".&print_key."\n
"; } - else { $index .= "

\n
".&print_key."\n
"; } - } elsif (($index{$key})&&(!($index_printed{$key}))) { - if ($SHORT_INDEX) { - $next = "
".&print_key."\n : ". &print_idx_links; - } else { - $next = "
".&print_key."\n
". &print_idx_links; - } - $index .= $next."\n"; - $index_printed{$key} = 1; - } - - if ($sub_index{$key}) { - local($subkey, @subkeys, $subnext, $subindex); - @subkeys = sort(split("\004", $sub_index{$key})); - if ($SHORT_INDEX) { - $index .= "
".&print_key unless $index_printed{$key}; - $index .= "
\n"; - } else { - $index .= "
".&print_key."\n
" unless $index_printed{$key}; - $index .= "
\n"; - } - foreach $subkey (@subkeys) { - $index .= &add_sub_idx_key($subkey) unless ($index_printed{$subkey}); - } - $index .= "
\n"; - } - return $index; -} - -1; # Must be present as the last line. diff --git a/manuals/scripts/latex2html-init.pl b/manuals/scripts/latex2html-init.pl deleted file mode 100755 index b03db63..0000000 --- a/manuals/scripts/latex2html-init.pl +++ /dev/null @@ -1,10 +0,0 @@ -# This file serves as a place to put initialization code and constants to -# affect the behavior of latex2html for generating the bacula manuals. - -# $LINKPOINT specifies what filename to use to link to when creating -# index.html. Not that this is a hard link. -$LINKPOINT='"$OVERALL_TITLE"'; - - -# The following must be the last line of this file. -1; diff --git a/manuals/scripts/translate_images.pl b/manuals/scripts/translate_images.pl deleted file mode 100755 index 41b7234..0000000 --- a/manuals/scripts/translate_images.pl +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/perl -w -# -use strict; - -# Used to change the names of the image files generated by latex2html from imgxx.png -# to meaningful names. Provision is made to go either from or to the meaningful names. -# The meaningful names are obtained from a file called imagename_translations, which -# is generated by extensions to latex2html in the make_image_file subroutine in -# bacula.perl. - -# Opens the file imagename_translations and reads the contents into a hash. -# The hash is creaed with the imgxx.png files as the key if processing TO -# meaningful filenames, and with the meaningful filenames as the key if -# processing FROM meaningful filenames. -# Then opens the html file(s) indicated in the command-line arguments and -# changes all image references according to the translations described in the -# above file. Finally, it renames the image files. -# -# Original creation: 3-27-05 by Karl Cunningham. -# Modified 5-21-05 to go FROM and TO meaningful filenames. -# -my $TRANSFILE = "imagename_translations"; -my $path; - -# Loads the contents of $TRANSFILE file into the hash referenced in the first -# argument. The hash is loaded to translate old to new if $direction is 0, -# otherwise it is loaded to translate new to old. In this context, the -# 'old' filename is the meaningful name, and the 'new' filename is the -# imgxx.png filename. It is assumed that the old image is the one that -# latex2html has used as the source to create the imgxx.png filename. -# The filename extension is taken from the file -sub read_transfile { - my ($trans,$direction) = @_; - - if (!open IN,"<$path$TRANSFILE") { - print "WARNING: Cannot open image translation file $path$TRANSFILE for reading\n"; - print " Image filename translation aborted\n\n"; - exit 0; - } - - while () { - chomp; - my ($new,$old) = split(/\001/); - - # Old filenames will usually have a leading ./ which we don't need. - $old =~ s/^\.\///; - - # The filename extension of the old filename must be made to match - # the new filename because it indicates the encoding format of the image. - my ($ext) = $new =~ /(\.[^\.]*)$/; - $old =~ s/\.[^\.]*$/$ext/; - if ($direction == 0) { - $trans->{$new} = $old; - } else { - $trans->{$old} = $new; - } - } - close IN; -} - -# Translates the image names in the file given as the first argument, according to -# the translations in the hash that is given as the second argument. -# The file contents are read in entirely into a string, the string is processed, and -# the file contents are then written. No particular care is taken to ensure that the -# file is not lost if a system failure occurs at an inopportune time. It is assumed -# that the html files being processed here can be recreated on demand. -# -# Links to other files are added to the %filelist for processing. That way, -# all linked files will be processed (assuming they are local). -sub translate_html { - my ($filename,$trans,$filelist) = @_; - my ($contents,$out,$this,$img,$dest); - my $cnt = 0; - - # If the filename is an external link ignore it. And drop any file:// from - # the filename. - $filename =~ /^(http|ftp|mailto)\:/ and return 0; - $filename =~ s/^file\:\/\///; - # Load the contents of the html file. - if (!open IF,"<$path$filename") { - print "WARNING: Cannot open $path$filename for reading\n"; - print " Image Filename Translation aborted\n\n"; - exit 0; - } - - while () { - $contents .= $_; - } - close IF; - - # Now do the translation... - # First, search for an image filename. - while ($contents =~ /\<\s*IMG[^\>]*SRC=\"/si) { - $contents = $'; - $out .= $` . $&; - - # The next thing is an image name. Get it and translate it. - $contents =~ /^(.*?)\"/s; - $contents = $'; - $this = $&; - $img = $1; - # If the image is in our list of ones to be translated, do it - # and feed the result to the output. - $cnt += $this =~ s/$img/$trans->{$img}/ if (defined($trans->{$img})); - $out .= $this; - } - $out .= $contents; - - # Now send the translated text to the html file, overwriting what's there. - open OF,">$path$filename" or die "Cannot open $path$filename for writing\n"; - print OF $out; - close OF; - - # Now look for any links to other files and add them to the list of files to do. - while ($out =~ /\<\s*A[^\>]*HREF=\"(.*?)\"/si) { - $out = $'; - $dest = $1; - # Drop an # and anything after it. - $dest =~ s/\#.*//; - $filelist->{$dest} = '' if $dest; - } - return $cnt; -} - -# REnames the image files spefified in the %translate hash. -sub rename_images { - my $translate = shift; - my ($response); - - foreach (keys(%$translate)) { - if (! $translate->{$_}) { - print " WARNING: No destination Filename for $_\n"; - } else { - $response = `mv -f $path$_ $path$translate->{$_} 2>&1`; - $response and print "ERROR from system $response\n"; - } - } -} - -################################################# -############# MAIN ############################# -################################################ - -# %filelist starts out with keys from the @ARGV list. As files are processed, -# any links to other files are added to the %filelist. A hash of processed -# files is kept so we don't do any twice. - -# The first argument must be either --to_meaningful_names or --from_meaningful_names - -my (%translate,$search_regex,%filelist,%completed,$thisfile); -my ($cnt,$direction); - -my $arg0 = shift(@ARGV); -$arg0 =~ /^(--to_meaningful_names|--from_meaningful_names)$/ or - die "ERROR: First argument must be either \'--to_meaningful_names\' or \'--from_meaningful_names\'\n"; - -$direction = ($arg0 eq '--to_meaningful_names') ? 0 : 1; - -(@ARGV) or die "ERROR: Filename(s) to process must be given as arguments\n"; - -# Use the first argument to get the path to the file of translations. -my $tmp = $ARGV[0]; -($path) = $tmp =~ /(.*\/)/; -$path = '' unless $path; - -read_transfile(\%translate,$direction); - -foreach (@ARGV) { - # Strip the path from the filename, and use it later on. - if (s/(.*\/)//) { - $path = $1; - } else { - $path = ''; - } - $filelist{$_} = ''; - - while ($thisfile = (keys(%filelist))[0]) { - $cnt += translate_html($thisfile,\%translate,\%filelist) if (!exists($completed{$thisfile})); - delete($filelist{$thisfile}); - $completed{$thisfile} = ''; - } - print "translate_images.pl: $cnt image filenames translated ",($direction)?"from":"to"," meaningful names\n"; -} - -rename_images(\%translate);