Attachment 'TableOfContents-1.9beta2.py.patch'
Download 1 --- TableOfContents.py.old 2009-03-14 14:22:44.000000000 +0100
2 +++ TableOfContents.py 2009-03-27 03:19:59.000000000 +0100
3 @@ -162,7 +162,7 @@
4 _ = macro.request.getText
5
6 result = [
7 - macro.formatter.div(1, css_class="table-of-contents"),
8 + macro.formatter.div(1, css_class="table-of-contents", id="toc"),
9 macro.formatter.paragraph(1, css_class="table-of-contents-heading"),
10 macro.formatter.text(_('Contents')),
11 macro.formatter.paragraph(0),
12 @@ -184,6 +184,13 @@
13 # headings are 1-based, lastlvl needs to be one less so that one is closed
14 lastlvl -= 1
15
16 + # variables needed to provide with nice, leveled prefixes
17 + # (part of the hierarhical TOC prefix code)
18 + levelnumbers = None
19 + levelnumbers = {}
20 + counter = 1
21 + lowest_lvl = None
22 +
23 for lvl, id, txt in macro.request._tocfm_collected_headings:
24 if txt is None:
25 incl_id = id
26 @@ -191,6 +198,27 @@
27 if lvl > maxdepth or id is None:
28 continue
29
30 + # determine the lowest level available
31 + # (part of the hierarhical TOC prefix)
32 + if lowest_lvl is None or lowest_lvl > lvl:
33 + lowest_lvl = lvl
34 +
35 + # determine number prefix for the TOC line
36 + # (part of the hierarhical TOC prefix)
37 + if lvl > lastlvl:
38 + levelnumbers[lastlvl] = counter
39 + counter = 0
40 + elif lvl < lastlvl:
41 + counter = levelnumbers[lvl]
42 + counter = counter + 1
43 + levelnumbers[lvl] = counter
44 +
45 + line_number = ""
46 + for i in range(lowest_lvl, lvl):
47 + line_number = line_number + str(levelnumbers[i]) + "."
48 + line_number = line_number + str(counter) + "."
49 +
50 +
51 # will be reset by pop_unique_ids below
52 macro.request.include_id = incl_id
53
54 @@ -198,12 +226,12 @@
55 while lastlvl > lvl:
56 result.extend([
57 macro.formatter.listitem(0),
58 - macro.formatter.number_list(0),
59 + macro.formatter.bullet_list(0),
60 ])
61 lastlvl -= 1
62 while lastlvl < lvl:
63 result.extend([
64 - macro.formatter.number_list(1),
65 + macro.formatter.bullet_list(1, type="none"),
66 macro.formatter.listitem(1),
67 ])
68 lastlvl += 1
69 @@ -215,13 +243,13 @@
70 result.extend([
71 '\n',
72 macro.formatter.anchorlink(1, id),
73 - macro.formatter.text(txt),
74 + macro.formatter.text(line_number + " " + txt),
75 macro.formatter.anchorlink(0),
76 ])
77
78 while lastlvl > 0:
79 result.append(macro.formatter.listitem(0))
80 - result.append(macro.formatter.number_list(0))
81 + result.append(macro.formatter.bullet_list(0))
82 lastlvl -= 1
83
84 macro.request.uid_generator.pop()
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.