Attachment 'TableOfContents-startdepth.diff'
Download 1 --- TableOfContents.py 2002-12-03 22:15:28.000000000 +0100
2 +++ NewTableOfContents.py 2003-12-04 16:27:13.000000000 +0100
3 @@ -6,6 +6,8 @@
4
5 Optional integer argument: maximal depth of listing.
6
7 + DN: Optional second integer argument: start listing at this depth
8 +
9 $Id: TableOfContents.py,v 1.6 2002/12/03 22:15:28 jhermann Exp $
10 """
11
12 @@ -21,16 +23,27 @@
13 lineno = 0
14 titles = {}
15
16 + # parse args
17 + if args:
18 + arglist = args.split(',')
19 + else:
20 + arglist = ''
21 +
22 try:
23 mindepth = int(macro.request.getPragma('section-numbers', 1))
24 except (ValueError, TypeError):
25 mindepth = 1
26
27 try:
28 - maxdepth = max(int(args), 1)
29 - except (ValueError, TypeError):
30 + maxdepth = max(int(arglist[0]), 1)
31 + except (IndexError, ValueError, TypeError):
32 maxdepth = 99
33
34 + try:
35 + startdepth = min(int(arglist[1]),maxdepth)
36 + except (IndexError, ValueError, TypeError):
37 + startdepth = 1
38 +
39 for line in macro.parser.lines:
40 # Filter out the headings
41 lineno = lineno + 1
42 @@ -43,6 +56,7 @@
43 # Get new indent level
44 newindent = len(match.group(1))
45 if newindent > maxdepth: continue
46 + if newindent < startdepth: continue
47 if newindent < mindepth: continue
48 if not indent:
49 baseindent = newindent - 1
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.