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
|
# -*- tcl -*-
# Engine to convert a docidx document into plain text.
#
# Copyright (c) 2003-2019 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} {
global map ; unset map ; array set map {}
global key ; set key {}
global max ; set max 0
if {($label != {}) && ($title != {})} {
set title "$label -- $title"
} elseif {$label != {}} {
set title $label
} elseif {$title != {}} {
# title is set
}
TextInitialize
lappend hdr "Index [Provenance]"
SectTitle hdr $title
Text [Compose hdr]
CloseParagraph [Verbatim]
return
}
proc fmt_index_end {} {
global map max
set rmargin [RMargin $max]
incr max
set blank [Blank $max] ;# indent
foreach key [lsort [array names map]] {
set keys [join $map($key) ", "]
Text [InFlow $keys $rmargin [ReHead $blank $key] $blank]
CloseParagraph [Verbatim]
}
return
}
proc fmt_key {text} {
global key max ; set key $text
MaxLen max $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}
################################################################
|