blob: 35540d856988950b21fc0adb19eeee39c46c2e78 (
plain)
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
|
# -*- tcl -*-
#
# $Id: idx.text,v 1.4 2010/06/08 19:32:36 andreas_kupries Exp $
#
# Engine to convert a docidx document into plain text.
#
# Copyright (c) 2003 Andreas Kupries <andreas_kupries@sourceforge.net>
# Freely redistributable.
#
######################################################################
dt_source _idx_common.tcl
dt_source _text.tcl
proc c_copyrightsymbol {} {return "(c)"}
######################################################################
# Conversion specification.
# One-pass processing.
rename idx_postprocess {}
rename text_postprocess idx_postprocess
proc fmt_plain_text {text} {return {}}
################################################################
## Backend for plain text markup
global map ; array set map {}
global key ; set key {}
global max ; set max 0
proc fmt_index_begin {label title} {
TextInitialize
global map ; unset map ; array set map {}
global key ; set key {}
global max ; set max 0
set hdr ""
append hdr "Index [textutil::string::uncap [c_provenance]]\n\n"
if {($label != {}) && ($title != {})} {
set title "$label -- $title"
} elseif {$label != {}} {
set title $label
} elseif {$title != {}} {
# title is set
}
append hdr $title \n
append hdr [textutil::repeat::strRepeat = [string length $title]]
Text $hdr
CloseParagraph [Verbatim]
return
}
proc fmt_index_end {} {
global map max
set break 0
set rmargin [expr {80 - $max}]
if {$rmargin < 20} {set rmargin 20}
incr max
set pfx [textutil::repeat::blank $max]
foreach key [lsort [array names map]] {
set opfx $key[string range $pfx [string length $key] end]
Text $opfx[textutil::adjust::indent [textutil::adjust::adjust [join $map($key) ", "] -length $rmargin] $pfx 1]
CloseParagraph [Verbatim]
}
return
}
proc fmt_key {text} {
global key max ; set key $text
if {[string length $text] > $max} {set max [string length $text]}
return
}
proc fmt_manpage {file label} {global map key ; lappend map($key) $file ; return}
proc fmt_url {url label} {global map key ; lappend map($key) $url ; return}
proc fmt_comment {text} {return}
################################################################
|