source: tol/tolsh/tolsh.vfs/lib/tcllib1.10/doctools/mpformats/toc.text @ 8597867d

1941-docker-image-to-testdevel
Last change on this file since 8597867d was 8597867d, checked in by Jorge Pérez <josp.jorge@…>, 16 years ago

closes #976, se incluye tcllib1.10, base64 debe eliminarse del raiz de lib ya que esta incluido en tcllib

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@2556 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 2.3 KB
Line 
1# -*- tcl -*-
2#
3# $Id: toc.text,v 1.7 2005/09/28 04:51:19 andreas_kupries Exp $
4#
5# Engine to convert a doctoc document into plain text.
6#
7# Copyright (c) 2003 Andreas Kupries <andreas_kupries@sourceforge.net>
8# Freely redistributable.
9#
10######################################################################
11
12dt_source _toc_common.tcl
13dt_source _text.tcl
14
15######################################################################
16# Conversion specification.
17# One-pass processing.
18
19rename toc_postprocess {}
20rename text_postprocess toc_postprocess
21
22proc fmt_plain_text {text} {return {}}
23
24################################################################
25## Backend for TMML markup
26
27global seclist ; set seclist {}
28global max     ; set max 0
29
30proc fmt_comment       {text}        {return}
31proc fmt_toc_end       {}            {return}
32proc fmt_toc_begin     {label title} {
33    TextInitialize
34
35    set     title "$label -- $title"
36    set     hdr ""
37    append  hdr "Table of contents [textutil::uncap [c_provenance]]\n"
38    append  hdr \n
39    append  hdr $title \n
40    append  hdr [textutil::strRepeat = [string length $title]]
41    Text   $hdr
42    CloseParagraph [Verbatim]
43}
44proc fmt_division_start {title symfile} {
45    global lmarginIncrement currentEnv
46    global seclist ; set seclist {}
47    global max     ; set max 0
48
49    Text $title\n
50    Text [textutil::strRepeat - [string length $title]]
51    CloseParagraph [Verbatim]
52    SaveContext
53    NewEnv Division {
54        incr currentEnv(lmargin) $lmarginIncrement
55    }
56    return
57}
58proc fmt_division_end   {}      {
59    global seclist max
60
61    if {[llength $seclist] > 0} {
62        set break 0
63        incr max 2
64        set  rmargin [expr {80 - $max}]
65        if {$rmargin < 20} {set rmargin 20}
66        set pfx [textutil::blank $max]
67        incr max -1
68        set fpfx "[textutil::strRepeat . $max] "
69
70        foreach {file desc} $seclist {
71            set   opfx "$file [string range $fpfx [string length $file] end]"
72            Text $opfx[textutil::indent [textutil::adjust $desc -length $rmargin] $pfx 1]
73            CloseParagraph [Verbatim]
74        }
75        set seclist {}
76    }
77
78    RestoreContext
79    return
80}
81proc fmt_item {file label desc} {
82    global seclist max
83    lappend seclist $file $desc
84    if {[string length $file] > $max} {set max [string length $file]}
85    return
86}
87
88################################################################
Note: See TracBrowser for help on using the repository browser.