File: toc.text

package info (click to toggle)
tcllib 1.10-dfsg-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 17,708 kB
  • ctags: 6,122
  • sloc: tcl: 106,354; ansic: 9,205; sh: 8,707; xml: 1,766; yacc: 753; makefile: 115; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (88 lines) | stat: -rw-r--r-- 2,316 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# -*- tcl -*-
#
# $Id: toc.text,v 1.7 2005/09/28 04:51:19 andreas_kupries Exp $
#
# Engine to convert a doctoc document into plain text.
#
# Copyright (c) 2003 Andreas Kupries <andreas_kupries@sourceforge.net>
# Freely redistributable.
#
######################################################################

dt_source _toc_common.tcl
dt_source _text.tcl

######################################################################
# Conversion specification.
# One-pass processing.

rename toc_postprocess {}
rename text_postprocess toc_postprocess

proc fmt_plain_text {text} {return {}}

################################################################
## Backend for TMML markup

global seclist ; set seclist {}
global max     ; set max 0

proc fmt_comment       {text}        {return}
proc fmt_toc_end       {}            {return}
proc fmt_toc_begin     {label title} {
    TextInitialize

    set     title "$label -- $title"
    set     hdr ""
    append  hdr "Table of contents [textutil::uncap [c_provenance]]\n"
    append  hdr \n
    append  hdr $title \n
    append  hdr [textutil::strRepeat = [string length $title]]
    Text   $hdr
    CloseParagraph [Verbatim]
}
proc fmt_division_start {title symfile} {
    global lmarginIncrement currentEnv
    global seclist ; set seclist {}
    global max     ; set max 0

    Text $title\n
    Text [textutil::strRepeat - [string length $title]]
    CloseParagraph [Verbatim]
    SaveContext
    NewEnv Division {
	incr currentEnv(lmargin) $lmarginIncrement
    }
    return
}
proc fmt_division_end   {}      {
    global seclist max

    if {[llength $seclist] > 0} {
	set break 0
	incr max 2
	set  rmargin [expr {80 - $max}]
	if {$rmargin < 20} {set rmargin 20}
	set pfx [textutil::blank $max]
	incr max -1
	set fpfx "[textutil::strRepeat . $max] "

	foreach {file desc} $seclist {
	    set   opfx "$file [string range $fpfx [string length $file] end]"
	    Text $opfx[textutil::indent [textutil::adjust $desc -length $rmargin] $pfx 1]
	    CloseParagraph [Verbatim]
	}
	set seclist {}
    }

    RestoreContext
    return
}
proc fmt_item {file label desc} {
    global seclist max
    lappend seclist $file $desc
    if {[string length $file] > $max} {set max [string length $file]}
    return
}

################################################################