# -*- tcl -*- # # $Id: toc.html,v 1.1 2003/03/05 06:50:34 andreas_kupries Exp $ # # Engine to convert a doctoc document into HTML. # # Copyright (c) 2003 Andreas Kupries # Freely redistributable. # ###################################################################### dt_source _toc_common.tcl dt_source _html.tcl ###################################################################### # Conversion specification. # # One-pass processing. rename toc_postprocess {} rename fmt_postprocess toc_postprocess proc fmt_plain_text {text} {return {}} ################################################################ ## Backend for TMML markup global firstitem ; set firstitem 1 global maintable ; set maintable 1 global even ; set even 1 proc fmt_toc_begin {label title} { set hdr "" append hdr "[markup
]\n" append hdr "[markup ]\n" # Engine parameter - insert 'meta' if {[set meta [Get meta]] != {}} {append hdr [markup $meta]\n} append hdr "[markup ]\n" append hdr [ht_comment [c_provenance]]\n append hdr [ht_comment "CVS: \$Id\$ $label"]\n append hdr \n append hdr [markup
]\n # Engine parameter - insert 'header' if {[set header [Get header]] != {}} {append hdr [markup $header]\n} append hdr "[markup

### ] $label [markup

]\n" append hdr "[markup

## ] $title [markup

  ]\n" return $hdr } proc fmt_toc_end {} { global maintable set text "\n" if {$maintable} {append text [tag/ table]\n} # Engine parameter - insert 'footer' set footer [Get footer] if {$footer != {}} {set footer \n[markup ${footer}]\n} return $text[tag /dl][tag hr]${footer}[tag/ body][tag/ html]\n } proc fmt_division_start {title} { global maintable ; set maintable 0 return \n[markup

  ]$title[markup
    ] } proc fmt_division_end {} { global firstitem ; set firstitem 1 global even ; set even 1 return [markup
  ] } proc fmt_item {file label desc} { global firstitem even set text "" if {$firstitem} { set firstitem 0 append text \n[markup "

  "]\n } if {$even} { append text [markup "
  "]\n } else { append text [markup "
  "]\n } set even [expr {1-$even}] append text [markup ""][markup ""]$label[tag/ a][tag/ td]\n append text [markup " | "]${desc}[tag /td]\n append text [tag/ tr]\n return $text } proc fmt_comment {text} {ht_comment $text} ################################################################ global __var array set __var { meta {} header {} footer {} } proc Get {varname} {global __var ; return $__var($varname)} proc toc_listvariables {} {global __var ; return [array names __var]} proc toc_varset {varname text} { global __var if {![info exists __var($varname)]} {return -code error "Unknown engine variable \"$varname\""} set __var($varname) $text return } ################################################################