|
NAMEhypertoc - generate a table of contents for HTML documentsVERSIONversion 3.20SYNOPSIShypertoc --help | --manpage | --man_help | --manhypertoc [--bak string ] [ --debug ] [ --entrysep string ] [ --footer file ] [ --header file ] [ --ignore_only_one ] [ --ignore_sole_first ] [ --inline ] [ --make_anchors ] [ --make_toc ] [ --notoc_match string ] [ --ol | --nool ] [ --ol_num_levels ] [ --outfile file ] [ --overwrite ] [ --quiet ] [ --textonly ] [ --title string ] { --toc_after tag=suffix } { --toc_before tag=prefix } { --toc_end tag=endtag } { --toc_entry tag=level } [ --toc_label string ] [ --toc_only | --notoc_only ] [ --toc_tag string ] [ --toc_tag_replace ] [ --use_id ] [ --useorg ] file ... DESCRIPTIONhypertoc allows you to specify "significant elements" that will be hyperlinked to in a "Table of Contents" (ToC) for a given set of HTML documents.Basically, the ToC generated is a multi-level level list containing links to the significant elements. hypertoc inserts the links into the ToC to significant elements at a level specified by the user. Example: If H1s are specified as level 1, than they appear in the first level list of the ToC. If H2s are specified as a level 2, than they appear in a second level list in the ToC. There are two aspects to the ToC generation: (1) putting suitable anchors into the HTML documents (--make_anchors), and (2) generating the ToC from HTML documents which have anchors in them for the ToC to link to (--make_toc). One can choose to do one or both of these. hypertoc also supports the ability to incorporate the ToC into the HTML document itself via the --inline option. In order for hypertoc to support linking to significant elements, hypertoc inserts anchors into the significant elements. One can use hypertoc as a filter, outputing the result to another file, or one can overwrite the original file, with the original backed up with a suffix (default: "org") appended to the filename. One can also define options in a config file as well as on the command-line. OPTIONSOptions can start with "--" or "-"; boolean options can be negated by preceding them with "no"; options with hash or array values can be added to by giving the option again for each value.See Getopt::Long for more information.
FILE FORMATSOptions FilesOptions can be given in files as well as on the command-line by using the --argfile filename option in the command-line. Also, the files ~/.hypertocrc and ./.hypertocrc are checked for options.The format is as follows: Lines starting with # are comments. Lines enclosed in PoD markers are also comments. Blank lines are ignored. The options themselves should be given the way they would be on the command line, that is, the option name (including the --) followed by its value (if any). For example: # set the ToC to be three-level --toc_entry H1=1 --toc_entry H2=2 --toc_entry H3=3 --toc_end H1=/H1 --toc_end H2=/H2 --toc_end H3=/H3 Option files can be nested, by giving an --argfile filename argument inside the option file, it will go and get that referred file as well. See Getopt::ArgvFile for more information. DETAILSSignificant ElementsHere are some examples of defining the significant elements for your Table of Contents.Example of Default The following reflects the default setting if nothing is explicitly specified: --toc_entry "H1=1" --toc_end "H1=/H1" --toc_entry "H2=2" --toc_end "H2=/H2" Or, if it was defined in one of the possible "Options Files": # default settings --toc_entry H1=1 --toc_end H1=/H1 --toc_entry H2=2 --toc_end H2=/H2 Example of before/after The following options make use of the before/after options: # An options file that adds some formatting # make level 1 ToC entries <strong> --toc_entry H1=1 --toc_end H1=/H1 --toc_before H1=<strong> --toc_after H1=</strong> # make level 2 ToC entries <em> --toc_entry H2=2 --toc_end H2=/H2 --toc_before H2=<em> --toc_after H2=</em> # Make level 3 entries as is --toc_entry H3=3 --toc_end H3=/H3 Example of custom end The following options try to index definition terms: # An options file that can work for Glossary type documents --toc_entry H1=1 --toc_end H1=/H1 --toc_entry H2=2 --toc_end H2=/H2 # Assumes document has a DD for each DT, otherwise ToC # will get entries with alot of text. --toc_entry DT=3 --toc_end DT=DD --toc_before DT=<em> --toc_after DT=</em> Formatting the ToCThe --toc_entry etc. options give you control on how the ToC entries may look, but there are other options to affect the final appearance of the ToC file created.With the --header option, the contents of the given file will be prepended before the generated ToC. This allows you to have introductory text, or any other text, before the ToC.
With the --toc_label option, the contents of the given string will be prepended before the generated ToC (but after any text taken from a --header file). With the --footer option, the contents of the file will be appended after the generated ToC.
If the --header option is not specified, the appropriate starting HTML markup will be added, unless the --toc_only option is specified. If the --footer option is not specified, the appropriate closing HTML markup will be added, unless the --toc_only option is specified. If you do not want/need to deal with header, and footer, files, then you are alloed to specify the title, --title option, of the ToC file; and it allows you to specify a heading, or label, to put before ToC entries' list, the --toc_label option. Both options have default values, see "OPTIONS" for more information on each option. If you do not want HTML page tags to be supplied, and just want the ToC itself, then specify the --toc_only option. If there are no --header or --footer files, then this will simply output the contents of --toc_label and the ToC itself. Inlining the ToCThe ability to incorporate the ToC directly into an HTML document is supported via the --inline option.Inlining will be done on the first file in the list of files processed, and will only be done if that file contains an opening tag matching the --toc_tag value. If --overwrite is true, then the first file in the list will be overwritten, with the generated ToC inserted at the appropriate spot. Otherwise a modified version of the first file is output to either STDOUT or to the output file defined by the --outfile option. The options --toc_tag and --toc_tag_replace are used to determine where and how the ToC is inserted into the output. Example 1 # this is the default --toc_tag BODY --notoc_tag_replace This will put the generated ToC after the BODY tag of the first file. If the --header option is specified, then the contents of the specified file are inserted after the BODY tag. If the --toc_label option is not empty, then the text specified by the --toc_label option is inserted. Then the ToC is inserted, and finally, if the --footer option is specified, it inserts the footer. Then the rest of the input file follows as it was before. Example 2 --toc_tag '!--toc--' --toc_tag_replace This will put the generated ToC after the first comment of the form <!--toc-->, and that comment will be replaced by the ToC (in the order --header --toc_label ToC --footer) followed by the rest of the input file.
EXAMPLESCreate an inline ToC for one filehypertoc --inline --make_anchors --overwrite --make_toc index.html This will create anchors in "index.html", create a ToC with a heading of "Table of Contents" and place it after the BODY tag of "index.html". The file index.html.org will contain the original index.html file, without ToC or anchors. Create a ToC file from multiple filesFirst, create the anchors.hypertoc --make_anchors --overwrite index.html fred.html george.html Then create the ToC hypertoc --make_toc --outfile table.html index.html fred.html george.html Create an inline ToC after the first heading of the first filehypertoc --make_anchors --inline --overwrite --make_toc --toc_tag /H1 \ --notoc_tag_replace --toc_label "" index.html fred.html george.html This will create anchors in the "index.html", "fred.html" and "george.html" files, create a ToC with no header and place it after the first H1 header in "index.html" and back up the original files to "index.html.org", "fred.html.org" and "george.html.org" Create an inline ToC with custom elementshypertoc --quiet --make_anchors --bak "" --overwrite \ --make_toc --inline --toc_label "" --toc_tag '!--toc--' \ --toc_tag_replace \ --toc_entry H2=1 --toc_entry H3=2 \ --toc_end H2=/H2 --toc_end H3=/H3 myfile.html This will create an inline ToC overwriting the original file, and replacing a <!--toc--> comment, and which takes H2 headers as level 1 and H3 headers as level 2. This can be useful where the .html file is generated by some other process, and you can then create the ToC as the last step. Create a ToC with custom elementshypertoc --quiet --make_anchors --bak "" --overwrite \ --toc_entry TITLE=1 --toc_end TITLE=/TITLE --toc_entry H2=2 --toc_entry H3=3 \ --toc_end H2=/H2 --toc_end H3=/H3 \ --make_toc --outfile index.html \ mary.html fred.html george.html This creates anchors at the H2 and H3 elements, and creates a ToC file called index.html, indexing on the TITLE, and the H2 and H3 elements. Create a ToC with custom elements and options fileGiven an options file called 'custom.opt' as follows:# Title, H2 and H3 --toc_entry TITLE=1 --toc_end TITLE=/TITLE --toc_entry H2=2 --toc_end H2=/H2 --toc_entry H3=3 --toc_end H3=/H3 then the previous example can have shorter command lines as follows: hypertoc --quiet --make_anchors --bak "" --overwrite \ --argfile custom.opt --make_toc --outfile index.html mary.html fred.html george.html NOTES
CAVEATS
BUGSTell me about them.REQUIRESGetopt::Long Getopt::ArgvFile File::Basename Pod::Usage HTML::LinkList HTML::Entities HTML::GenToc SCRIPT CATEGORIESWebENVIRONMENT
FILES
SEE ALSOperl(1) htmltoc(1) HTML::GenToc Getopt::ArgvFile Getopt::LongAUTHORKathryn Andersen http://www.katspace.org/tools/hypertoc/Based on htmltoc by Earl Hood ehood AT medusa.acs.uci.edu Contributions from Dan Dascalescu, <http://dandascalescu.com> COPYRIGHTCopyright (C) 1994-1997 Earl Hood, ehood AT medusa.acs.uci.edu Copyright (C) 2002-2008 Kathryn AndersenThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Visit the GSP FreeBSD Man Page Interface. |