#---------------------------------------------------------------------- # TITLE: # manrules.tcl # # AUTHOR: # Will Duquette # # DESCRIPTION: # Rules for creating a manpage HTML file from an EHTML file. # This is a simple set of rules, intended as much as an example as a # usable set of rules. # # This rule file is expected to be used with the following # command line: # # expand -rules manrules.tcl -out name.html name.ehtml # # EHTML files processed with this rule set can contain the # following special commands: # # pageheader title # Writes an HTML header with the title of the man page. # # section title # Defines the beginning of a manpage section # # hsection title # Indicates a link to a manpage section # # hrule # Writes a horizontal rule with space around it. At # present, this is an HTML
tag, but it could as easily # format a graphic image instead. # # link url ?text? # Writes a hyperlink with the given URL. If # text is specified, it is used as the # displayed text of the link; otherwise, the URL is used. # # commanddef name args # Marks the definition of a command. # # command name # Marks a reference to a command. # # mailto address # Writes a "mailto" link, with the address as the displayed # text. # # copyright year # Writes copyright notice for the specified year. # # The HTML output is automatically closed by the end_hook. # # LICENSE: # Copyright (C) 2000 by William H. Duquette. See license.txt, # distributed with this file, for license information. # # CHANGE: # 06/27/98: Released Expand 1.0 on web # 06/28/98: Improved the handling of section anchors. Added the # hsection command and the titleToName utility. # 06/28/98: Released Expand 1.1 on web. # 06/29/98: Added "commanddef" and "command" commands, to automate # links to Expand command names. # 07/02/98: Removed titleToName; the standard textToID function # does the same thing. # 05/07/00: Revised for Expand 2.0. #---------------------------------------------------------------------- # Hooks # The init_hook is called before any processing is done. proc init_hook {} { expand::webRuleSet } # The end_hook is called automatically after the file has been processed. proc end_hook {} { return "\n\n\n" } #---------------------------------------------------------------------- # Rules # Format the HTML header and document title proc pageheader {title} { set head "\n" append head " $title\n" append head "\n\n" append head "\n\n" append head "

$title

" return $head } # Start a man page section proc section {title} { set tagName [expand::textToID $title] set title [string toupper $title] return "

$title

" } # Format a horizontal rule proc hrule {} { return "\n


\n" } # Format a link to another section in the manpage. proc hsection {title} { set tagName [expand::textToID $title] set title [string toupper $title] return [link "#$tagName" $title] } # Marks a command definition proc commanddef {name args} { set val "$name" if {$args != ""} { append val " $args" } append val "" return $val } # Marks a command reference proc command {name} { return "$name" } # Format the copyright notice proc copyright {year name} { set notice [hrule] append notice "Copyright © $year, by $name." append notice " All rights reserved.

\n" return $notice } #---------------------------------------------------------------------- # Utility functions