annotate Doc/partparse.py @ 6719:faebc1940432 legacy-trunk

Understand -Xlinker option.
author Guido van Rossum <guido@python.org>
date Tue, 02 Dec 1997 20:38:11 +0000
parents 20589ed3e8bd
children 139ad31ff8fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 #
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 # partparse.py: parse a by-Guido-written-and-by-Jan-Hein-edited LaTeX file,
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 # and generate texinfo source.
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 #
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 # This is *not* a good example of good programming practices. In fact, this
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 # file could use a complete rewrite, in order to become faster, more
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
7 # easily extensible and maintainable.
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 #
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 # However, I added some comments on a few places for the pityful person who
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 # would ever need to take a look into this file.
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 #
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 # Have I been clear enough??
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 #
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 # -jh
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
15 #
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
16 # Yup. I made some performance improvements and hope this lasts a while;
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
17 # I don't want to be the schmuck who ends up re-writting it!
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
18 #
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
19 # -fld
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20
1401
cd5989a58bcf * ext.tex: documentation for extending, reference counts, and embedding
Guido van Rossum <guido@python.org>
parents: 1292
diff changeset
21 import sys, string, regex, getopt, os
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
23 from types import IntType, ListType, StringType, TupleType
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
24
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 # Different parse modes for phase 1
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 MODE_REGULAR = 0
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 MODE_VERBATIM = 1
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 MODE_CS_SCAN = 2
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 MODE_COMMENT = 3
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 MODE_MATH = 4
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 MODE_DMATH = 5
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 MODE_GOBBLEWHITE = 6
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
33
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
34 the_modes = (MODE_REGULAR, MODE_VERBATIM, MODE_CS_SCAN, MODE_COMMENT,
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
35 MODE_MATH, MODE_DMATH, MODE_GOBBLEWHITE)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
36
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 # Show the neighbourhood of the scanned buffer
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 def epsilon(buf, where):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
39 wmt, wpt = where - 10, where + 10
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
40 if wmt < 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
41 wmt = 0
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
42 if wpt > len(buf):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
43 wpt = len(buf)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
44 return ' Context ' + `buf[wmt:where]` + '.' + `buf[where:wpt]` + '.'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
45
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 # Should return the line number. never worked
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 def lin():
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
48 global lineno
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
49 return ' Line ' + `lineno` + '.'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 # Displays the recursion level.
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 def lv(lvl):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
53 return ' Level ' + `lvl` + '.'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
54
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 # Combine the three previous functions. Used often.
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 def lle(lvl, buf, where):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
57 return lv(lvl) + lin() + epsilon(buf, where)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
58
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
59
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 # This class is only needed for _symbolic_ representation of the parse mode.
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 class Mode:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
62 def __init__(self, arg):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
63 if arg not in the_modes:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
64 raise ValueError, 'mode not in the_modes'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
65 self.mode = arg
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
66
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
67 def __cmp__(self, other):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
68 if type(self) != type(other):
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
69 other = mode[other]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
70 return cmp(self.mode, other.mode)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
71
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
72 def __repr__(self):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
73 if self.mode == MODE_REGULAR:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
74 return 'MODE_REGULAR'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
75 elif self.mode == MODE_VERBATIM:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
76 return 'MODE_VERBATIM'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
77 elif self.mode == MODE_CS_SCAN:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
78 return 'MODE_CS_SCAN'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
79 elif self.mode == MODE_COMMENT:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
80 return 'MODE_COMMENT'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
81 elif self.mode == MODE_MATH:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
82 return 'MODE_MATH'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
83 elif self.mode == MODE_DMATH:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
84 return 'MODE_DMATH'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
85 elif self.mode == MODE_GOBBLEWHITE:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
86 return 'MODE_GOBBLEWHITE'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
87 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
88 raise ValueError, 'mode not in the_modes'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
89
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 # just a wrapper around a class initialisation
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
91 mode = {}
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
92 for t in the_modes:
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
93 mode[t] = Mode(t)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
94
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
95
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 # After phase 1, the text consists of chunks, with a certain type
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
97 # this type will be assigned to the chtype member of the chunk
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
98 # the where-field contains the file position where this is found
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
99 # and the data field contains (1): a tuple describing start- end end
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 # positions of the substring (can be used as slice for the buf-variable),
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
101 # (2) just a string, mostly generated by the changeit routine,
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
102 # or (3) a list, describing a (recursive) subgroup of chunks
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
103 PLAIN = 0 # ASSUME PLAINTEXT, data = the text
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
104 GROUP = 1 # GROUP ({}), data = [chunk, chunk,..]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
105 CSNAME = 2 # CONTROL SEQ TOKEN, data = the command
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 COMMENT = 3 # data is the actual comment
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 DMATH = 4 # DISPLAYMATH, data = [chunk, chunk,..]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
108 MATH = 5 # MATH, see DISPLAYMATH
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
109 OTHER = 6 # CHAR WITH CATCODE OTHER, data = char
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
110 ACTIVE = 7 # ACTIVE CHAR
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
111 GOBBLEDWHITE = 8 # Gobbled LWSP, after CSNAME
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
112 ENDLINE = 9 # END-OF-LINE, data = '\n'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
113 DENDLINE = 10 # DOUBLE EOL, data='\n', indicates \par
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
114 ENV = 11 # LaTeX-environment
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
115 # data =(envname,[ch,ch,ch,.])
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
116 CSLINE = 12 # for texi: next chunk will be one group
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
117 # of args. Will be set all on 1 line
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
118 IGNORE = 13 # IGNORE this data
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
119 ENDENV = 14 # TEMP END OF GROUP INDICATOR
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
120 IF = 15 # IF-directive
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
121 # data = (flag,negate,[ch, ch, ch,...])
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
122
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
123 the_types = (PLAIN, GROUP, CSNAME, COMMENT, DMATH, MATH, OTHER, ACTIVE,
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
124 GOBBLEDWHITE, ENDLINE, DENDLINE, ENV, CSLINE, IGNORE, ENDENV, IF)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
125
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
126 # class, just to display symbolic name
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
127 class ChunkType:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
128 def __init__(self, chunk_type):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
129 if chunk_type not in the_types:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
130 raise ValueError, 'chunk_type not in the_types'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
131 self.chunk_type = chunk_type
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
132
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
133 def __cmp__(self, other):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
134 if type(self) != type(other):
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
135 other = chunk_type[other]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
136 return cmp(self.chunk_type, other.chunk_type)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
137
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
138 def __repr__(self):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
139 if self.chunk_type == PLAIN:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
140 return 'PLAIN'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
141 elif self.chunk_type == GROUP:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
142 return 'GROUP'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
143 elif self.chunk_type == CSNAME:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
144 return 'CSNAME'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
145 elif self.chunk_type == COMMENT:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
146 return 'COMMENT'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
147 elif self.chunk_type == DMATH:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
148 return 'DMATH'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
149 elif self.chunk_type == MATH:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
150 return 'MATH'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
151 elif self.chunk_type == OTHER:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
152 return 'OTHER'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
153 elif self.chunk_type == ACTIVE:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
154 return 'ACTIVE'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
155 elif self.chunk_type == GOBBLEDWHITE:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
156 return 'GOBBLEDWHITE'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
157 elif self.chunk_type == DENDLINE:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
158 return 'DENDLINE'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
159 elif self.chunk_type == ENDLINE:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
160 return 'ENDLINE'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
161 elif self.chunk_type == ENV:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
162 return 'ENV'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
163 elif self.chunk_type == CSLINE:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
164 return 'CSLINE'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
165 elif self.chunk_type == IGNORE:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
166 return 'IGNORE'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
167 elif self.chunk_type == ENDENV:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
168 return 'ENDENV'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
169 elif self.chunk_type == IF:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
170 return 'IF'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
171 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
172 raise ValueError, 'chunk_type not in the_types'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
173
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
174 # ...and the wrapper
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
175 chunk_type = {}
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
176 for t in the_types:
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
177 chunk_type[t] = ChunkType(t)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
178
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
179 # store a type object of the ChunkType-class-instance...
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
180 chunk_type_type = type(chunk_type[PLAIN])
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
181
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
182 # this class contains a part of the parsed buffer
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
183 class Chunk:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
184 def __init__(self, chtype, where, data):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
185 if type(chtype) != chunk_type_type:
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
186 chtype = chunk_type[chtype]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
187 self.chtype = chtype
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
188 self.where = where
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
189 self.data = data
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
190
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
191 def __repr__(self):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
192 return 'chunk' + `self.chtype, self.where, self.data`
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
193
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
194 # and the wrapper
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
195 chunk = Chunk
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
196
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
197
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
198 error = 'partparse.error'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
199
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
200 #
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
201 # TeX's catcodes...
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
202 #
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
203 CC_ESCAPE = 0
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
204 CC_LBRACE = 1
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
205 CC_RBRACE = 2
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
206 CC_MATHSHIFT = 3
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
207 CC_ALIGNMENT = 4
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
208 CC_ENDLINE = 5
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
209 CC_PARAMETER = 6
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
210 CC_SUPERSCRIPT = 7
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
211 CC_SUBSCRIPT = 8
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
212 CC_IGNORE = 9
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
213 CC_WHITE = 10
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
214 CC_LETTER = 11
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
215 CC_OTHER = 12
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
216 CC_ACTIVE = 13
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
217 CC_COMMENT = 14
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
218 CC_INVALID = 15
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
219
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
220 # and the names
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
221 cc_names = [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
222 'CC_ESCAPE',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
223 'CC_LBRACE',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
224 'CC_RBRACE',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
225 'CC_MATHSHIFT',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
226 'CC_ALIGNMENT',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
227 'CC_ENDLINE',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
228 'CC_PARAMETER',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
229 'CC_SUPERSCRIPT',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
230 'CC_SUBSCRIPT',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
231 'CC_IGNORE',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
232 'CC_WHITE',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
233 'CC_LETTER',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
234 'CC_OTHER',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
235 'CC_ACTIVE',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
236 'CC_COMMENT',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
237 'CC_INVALID',
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
238 ]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
239
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
240 # Show a list of catcode-name-symbols
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
241 def pcl(codelist):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
242 result = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
243 for i in codelist:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
244 result = result + cc_names[i] + ', '
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
245 return '[' + result[:-2] + ']'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
246
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
247 # the name of the catcode (ACTIVE, OTHER, etc.)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
248 def pc(code):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
249 return cc_names[code]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
250
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
251
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
252 # Which catcodes make the parser stop parsing regular plaintext
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
253 regular_stopcodes = [CC_ESCAPE, CC_LBRACE, CC_RBRACE, CC_MATHSHIFT,
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
254 CC_ALIGNMENT, CC_PARAMETER, CC_SUPERSCRIPT, CC_SUBSCRIPT,
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
255 CC_IGNORE, CC_ACTIVE, CC_COMMENT, CC_INVALID, CC_ENDLINE]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
256
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
257 # same for scanning a control sequence name
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
258 csname_scancodes = [CC_LETTER]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
259
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
260 # same for gobbling LWSP
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
261 white_scancodes = [CC_WHITE]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
262 ##white_scancodes = [CC_WHITE, CC_ENDLINE]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
263
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
264 # make a list of all catcode id's, except for catcode ``other''
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
265 all_but_other_codes = range(16)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
266 del all_but_other_codes[CC_OTHER]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
267 ##print all_but_other_codes
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
268
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
269 # when does a comment end
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
270 comment_stopcodes = [CC_ENDLINE]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
271
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
272 # gather all characters together, specified by a list of catcodes
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
273 def code2string(cc, codelist):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
274 ##print 'code2string: codelist = ' + pcl(codelist),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
275 result = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
276 for category in codelist:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
277 if cc[category]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
278 result = result + cc[category]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
279 ##print 'result = ' + `result`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
280 return result
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
281
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
282 # automatically generate all characters of catcode other, being the
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
283 # complement set in the ASCII range (128 characters)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
284 def make_other_codes(cc):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
285 otherchars = range(256) # could be made 256, no problem
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
286 for category in all_but_other_codes:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
287 if cc[category]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
288 for c in cc[category]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
289 otherchars[ord(c)] = None
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
290 result = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
291 for i in otherchars:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
292 if i != None:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
293 result = result + chr(i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
294 return result
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
295
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
296 # catcode dump (which characters have which catcodes).
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
297 def dump_cc(name, cc):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
298 ##print '\t' + name
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
299 ##print '=' * (8+len(name))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
300 if len(cc) != 16:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
301 raise TypeError, 'cc not good cat class'
1401
cd5989a58bcf * ext.tex: documentation for extending, reference counts, and embedding
Guido van Rossum <guido@python.org>
parents: 1292
diff changeset
302 ## for i in range(16):
cd5989a58bcf * ext.tex: documentation for extending, reference counts, and embedding
Guido van Rossum <guido@python.org>
parents: 1292
diff changeset
303 ## print pc(i) + '\t' + `cc[i]`
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
304
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
305
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
306 # In the beginning,....
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
307 epoch_cc = [None] * 16
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
308 ##dump_cc('epoch_cc', epoch_cc)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
309
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
310
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
311 # INITEX
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
312 initex_cc = epoch_cc[:]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
313 initex_cc[CC_ESCAPE] = '\\'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
314 initex_cc[CC_ENDLINE], initex_cc[CC_IGNORE], initex_cc[CC_WHITE] = \
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
315 '\n', '\0', ' '
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
316 initex_cc[CC_LETTER] = string.uppercase + string.lowercase
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
317 initex_cc[CC_COMMENT], initex_cc[CC_INVALID] = '%', '\x7F'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
318 #initex_cc[CC_OTHER] = make_other_codes(initex_cc) I don't need them, anyway
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
319 ##dump_cc('initex_cc', initex_cc)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
320
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
321
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
322 # LPLAIN: LaTeX catcode setting (see lplain.tex)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
323 lplain_cc = initex_cc[:]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
324 lplain_cc[CC_LBRACE], lplain_cc[CC_RBRACE] = '{', '}'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
325 lplain_cc[CC_MATHSHIFT] = '$'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
326 lplain_cc[CC_ALIGNMENT] = '&'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
327 lplain_cc[CC_PARAMETER] = '#'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
328 lplain_cc[CC_SUPERSCRIPT] = '^\x0B' # '^' and C-k
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
329 lplain_cc[CC_SUBSCRIPT] = '_\x01' # '_' and C-a
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
330 lplain_cc[CC_WHITE] = lplain_cc[CC_WHITE] + '\t'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
331 lplain_cc[CC_ACTIVE] = '~\x0C' # '~' and C-l
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
332 lplain_cc[CC_OTHER] = make_other_codes(lplain_cc)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
333 ##dump_cc('lplain_cc', lplain_cc)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
334
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
335
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
336 # Guido's LaTeX environment catcoded '_' as ``other''
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
337 # my own purpose catlist
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
338 my_cc = lplain_cc[:]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
339 my_cc[CC_SUBSCRIPT] = my_cc[CC_SUBSCRIPT][1:] # remove '_' here
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
340 my_cc[CC_OTHER] = my_cc[CC_OTHER] + '_' # add it to OTHER list
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
341 dump_cc('my_cc', my_cc)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
342
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
343
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
344
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
345 # needed for un_re, my equivalent for regexp-quote in Emacs
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
346 re_meaning = '\\[]^$'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
347
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
348 def un_re(str):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
349 result = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
350 for i in str:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
351 if i in re_meaning:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
352 result = result + '\\'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
353 result = result + i
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
354 return result
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
355
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
356 # NOTE the negate ('^') operator in *some* of the regexps below
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
357 def make_rc_regular(cc):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
358 # problems here if '[]' are included!!
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
359 return regex.compile('[' + code2string(cc, regular_stopcodes) + ']')
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
360
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
361 def make_rc_cs_scan(cc):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
362 return regex.compile('[^' + code2string(cc, csname_scancodes) + ']')
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
363
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
364 def make_rc_comment(cc):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
365 return regex.compile('[' + code2string(cc, comment_stopcodes) + ']')
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
366
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
367 def make_rc_endwhite(cc):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
368 return regex.compile('[^' + code2string(cc, white_scancodes) + ']')
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
369
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
370
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
371
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
372 # regular: normal mode:
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
373 rc_regular = make_rc_regular(my_cc)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
374
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
375 # scan: scan a command sequence e.g. `newlength' or `mbox' or `;', `,' or `$'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
376 rc_cs_scan = make_rc_cs_scan(my_cc)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
377 rc_comment = make_rc_comment(my_cc)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
378 rc_endwhite = make_rc_endwhite(my_cc)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
379
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
380
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
381 # parseit (BUF, PARSEMODE=mode[MODE_REGULAR], START=0, RECURSION-LEVEL=0)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
382 # RECURSION-LEVEL will is incremented on entry.
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
383 # result contains the list of chunks returned
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
384 # together with this list, the buffer position is returned
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
385
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
386 # RECURSION-LEVEL will be set to zero *again*, when recursively a
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
387 # {,D}MATH-mode scan has been enetered.
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
388 # This has been done in order to better check for environment-mismatches
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
389
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
390 def parseit(buf, parsemode=mode[MODE_REGULAR], start=0, lvl=0):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
391 global lineno
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
392
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
393 result = []
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
394 end = len(buf)
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
395 if lvl == 0 and parsemode == mode[MODE_REGULAR]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
396 lineno = 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
397 lvl = lvl + 1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
398
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
399 ##print 'parseit(' + epsilon(buf, start) + ', ' + `parsemode` + ', ' + `start` + ', ' + `lvl` + ')'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
400
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
401 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
402 # some of the more regular modes...
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
403 #
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
404
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
405 if parsemode in (mode[MODE_REGULAR], mode[MODE_DMATH], mode[MODE_MATH]):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
406 cstate = []
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
407 newpos = start
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
408 curpmode = parsemode
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
409 while 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
410 where = newpos
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
411 #print '\tnew round: ' + epsilon(buf, where)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
412 if where == end:
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
413 if lvl > 1 or curpmode != mode[MODE_REGULAR]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
414 # not the way we started...
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
415 raise EOFError, 'premature end of file.' + lle(lvl, buf, where)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
416 # the real ending of lvl-1 parse
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
417 return end, result
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
418
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
419 pos = rc_regular.search(buf, where)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
420
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
421 if pos < 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
422 pos = end
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
423
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
424 if pos != where:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
425 newpos, c = pos, chunk(PLAIN, where, (where, pos))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
426 result.append(c)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
427 continue
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
428
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
429
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
430 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
431 # ok, pos == where and pos != end
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
432 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
433 foundchar = buf[where]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
434 if foundchar in my_cc[CC_LBRACE]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
435 # recursive subgroup parse...
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
436 newpos, data = parseit(buf, curpmode, where+1, lvl)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
437 result.append(chunk(GROUP, where, data))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
438
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
439 elif foundchar in my_cc[CC_RBRACE]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
440 if lvl <= 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
441 raise error, 'ENDGROUP while in base level.' + lle(lvl, buf, where)
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
442 if lvl == 1 and mode != mode[MODE_REGULAR]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
443 raise error, 'endgroup while in math mode. +lin() + epsilon(buf, where)'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
444 return where + 1, result
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
445
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
446 elif foundchar in my_cc[CC_ESCAPE]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
447 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
448 # call the routine that actually deals with
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
449 # this problem. If do_ret is None, than
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
450 # return the value of do_ret
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
451 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
452 # Note that handle_cs might call this routine
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
453 # recursively again...
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
454 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
455 do_ret, newpos = handlecs(buf, where,
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
456 curpmode, lvl, result, end)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
457 if do_ret != None:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
458 return do_ret
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
459
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
460 elif foundchar in my_cc[CC_COMMENT]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
461 newpos, data = parseit(buf,
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
462 mode[MODE_COMMENT], where+1, lvl)
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
463 result.append(chunk(COMMENT, where, data))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
464
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
465 elif foundchar in my_cc[CC_MATHSHIFT]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
466 # note that recursive calls to math-mode
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
467 # scanning are called with recursion-level 0
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
468 # again, in order to check for bad mathend
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
469 #
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
470 if where + 1 != end and buf[where + 1] in my_cc[CC_MATHSHIFT]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
471 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
472 # double mathshift, e.g. '$$'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
473 #
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
474 if curpmode == mode[MODE_REGULAR]:
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
475 newpos, data = parseit(buf, mode[MODE_DMATH],
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
476 where + 2, 0)
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
477 result.append(chunk(DMATH, where, data))
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
478 elif curpmode == mode[MODE_MATH]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
479 raise error, 'wrong math delimiiter' + lin() + epsilon(buf, where)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
480 elif lvl != 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
481 raise error, 'bad mathend.' + lle(lvl, buf, where)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
482 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
483 return where + 2, result
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
484 else:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
485 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
486 # single math shift, e.g. '$'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
487 #
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
488 if curpmode == mode[MODE_REGULAR]:
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
489 newpos, data = parseit(buf, mode[MODE_MATH],
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
490 where + 1, 0)
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
491 result.append(chunk(MATH, where, data))
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
492 elif curpmode == mode[MODE_DMATH]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
493 raise error, 'wrong math delimiiter' + lin() + epsilon(buf, where)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
494 elif lvl != 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
495 raise error, 'bad mathend.' + lv(lvl, buf, where)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
496 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
497 return where + 1, result
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
498
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
499 elif foundchar in my_cc[CC_IGNORE]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
500 print 'warning: ignored char', `foundchar`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
501 newpos = where + 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
502
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
503 elif foundchar in my_cc[CC_ACTIVE]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
504 result.append(chunk(ACTIVE, where, foundchar))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
505 newpos = where + 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
506
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
507 elif foundchar in my_cc[CC_INVALID]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
508 raise error, 'invalid char ' + `foundchar`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
509 newpos = where + 1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
510
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
511 elif foundchar in my_cc[CC_ENDLINE]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
512 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
513 # after an end of line, eat the rest of
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
514 # whitespace on the beginning of the next line
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
515 # this is what LaTeX more or less does
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
516 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
517 # also, try to indicate double newlines (\par)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
518 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
519 lineno = lineno + 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
520 savedwhere = where
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
521 newpos, dummy = parseit(buf, mode[MODE_GOBBLEWHITE], where + 1, lvl)
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
522 if newpos != end and buf[newpos] in my_cc[CC_ENDLINE]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
523 result.append(chunk(DENDLINE, savedwhere, foundchar))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
524 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
525 result.append(chunk(ENDLINE, savedwhere, foundchar))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
526 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
527 result.append(chunk(OTHER, where, foundchar))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
528 newpos = where + 1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
529
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
530 elif parsemode == mode[MODE_CS_SCAN]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
531 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
532 # scan for a control sequence token. `\ape', `\nut' or `\%'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
533 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
534 if start == end:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
535 raise EOFError, 'can\'t find end of csname'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
536 pos = rc_cs_scan.search(buf, start)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
537 if pos < 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
538 pos = end
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
539 if pos == start:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
540 # first non-letter right where we started the search
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
541 # ---> the control sequence name consists of one single
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
542 # character. Also: don't eat white space...
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
543 if buf[pos] in my_cc[CC_ENDLINE]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
544 lineno = lineno + 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
545 pos = pos + 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
546 return pos, (start, pos)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
547 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
548 spos = pos
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
549 if buf[pos] == '\n':
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
550 lineno = lineno + 1
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
551 spos = pos + 1
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
552 pos2, dummy = parseit(buf, mode[MODE_GOBBLEWHITE], spos, lvl)
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
553 return pos2, (start, pos)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
554
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
555 elif parsemode == mode[MODE_GOBBLEWHITE]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
556 if start == end:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
557 return start, ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
558 pos = rc_endwhite.search(buf, start)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
559 if pos < 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
560 pos = start
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
561 return pos, (start, pos)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
562
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
563 elif parsemode == mode[MODE_COMMENT]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
564 pos = rc_comment.search(buf, start)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
565 lineno = lineno + 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
566 if pos < 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
567 print 'no newline perhaps?'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
568 raise EOFError, 'can\'t find end of comment'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
569 pos = pos + 1
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
570 pos2, dummy = parseit(buf, mode[MODE_GOBBLEWHITE], pos, lvl)
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
571 return pos2, (start, pos)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
572
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
573 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
574 raise error, 'Unknown mode (' + `parsemode` + ')'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
575
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
576
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
577 #moreresult = cswitch(buf[x1:x2], buf, newpos, parsemode, lvl)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
578
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
579 #boxcommands = 'mbox', 'fbox'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
580 #defcommands = 'def', 'newcommand'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
581
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
582 endverbstr = '\\end{verbatim}'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
583
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
584 re_endverb = regex.compile(un_re(endverbstr))
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
585
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
586 #
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
587 # handlecs: helper function for parseit, for the special thing we might
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
588 # wanna do after certain command control sequences
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
589 # returns: None or return_data, newpos
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
590 #
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
591 # in the latter case, the calling function is instructed to immediately
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
592 # return with the data in return_data
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
593 #
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
594 def handlecs(buf, where, curpmode, lvl, result, end):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
595 global lineno
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
596
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
597 # get the control sequence name...
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
598 newpos, data = parseit(buf, mode[MODE_CS_SCAN], where+1, lvl)
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
599 saveddata = data
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
600 s_buf_data = s(buf, data)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
601
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
602 if s_buf_data in ('begin', 'end'):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
603 # skip the expected '{' and get the LaTeX-envname '}'
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
604 newpos, data = parseit(buf, mode[MODE_REGULAR], newpos+1, lvl)
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
605 if len(data) != 1:
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
606 raise error, 'expected 1 chunk of data.' + lle(lvl, buf, where)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
607
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
608 # yucky, we've got an environment
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
609 envname = s(buf, data[0].data)
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
610 s_buf_saveddata = s(buf, saveddata)
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
611 ##print 'FOUND ' + s(buf, saveddata) + '. Name ' + `envname` + '.' + lv(lvl)
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
612 if s_buf_saveddata == 'begin' and envname == 'verbatim':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
613 # verbatim deserves special treatment
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
614 pos = re_endverb.search(buf, newpos)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
615 if pos < 0:
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
616 raise error, "%s not found.%s" \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
617 % (`endverbstr`, lle(lvl, buf, where))
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
618 result.append(chunk(ENV, where, (envname, [chunk(PLAIN, newpos, (newpos, pos))])))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
619 newpos = pos + len(endverbstr)
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
620
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
621 elif s_buf_saveddata == 'begin':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
622 # start parsing recursively... If that parse returns
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
623 # from an '\end{...}', then should the last item of
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
624 # the returned data be a string containing the ended
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
625 # environment
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
626 newpos, data = parseit(buf, curpmode, newpos, lvl)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
627 if not data or type(data[-1]) is not StringType:
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
628 raise error, "missing 'end'" + lle(lvl, buf, where) \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
629 + epsilon(buf, newpos)
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
630 retenv = data[-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
631 del data[-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
632 if retenv != envname:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
633 #[`retenv`, `envname`]
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
634 raise error, 'environments do not match.%s%s' \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
635 % (lle(lvl, buf, where), epsilon(buf, newpos))
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
636 result.append(chunk(ENV, where, (retenv, data)))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
637 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
638 # 'end'... append the environment name, as just
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
639 # pointed out, and order parsit to return...
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
640 result.append(envname)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
641 ##print 'POINT of return: ' + epsilon(buf, newpos)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
642 # the tuple will be returned by parseit
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
643 return (newpos, result), newpos
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
644
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
645 # end of \begin ... \end handling
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
646
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
647 elif s_buf_data[0:2] == 'if':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
648 # another scary monster: the 'if' directive
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
649 flag = s_buf_data[2:]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
650
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
651 # recursively call parseit, just like environment above..
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
652 # the last item of data should contain the if-termination
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
653 # e.g., 'else' of 'fi'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
654 newpos, data = parseit(buf, curpmode, newpos, lvl)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
655 if not data or data[-1] not in ('else', 'fi'):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
656 raise error, 'wrong if... termination' + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
657 lle(lvl, buf, where) + epsilon(buf, newpos)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
658
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
659 ifterm = data[-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
660 del data[-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
661 # 0 means dont_negate flag
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
662 result.append(chunk(IF, where, (flag, 0, data)))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
663 if ifterm == 'else':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
664 # do the whole thing again, there is only one way
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
665 # to end this one, by 'fi'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
666 newpos, data = parseit(buf, curpmode, newpos, lvl)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
667 if not data or data[-1] not in ('fi', ):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
668 raise error, 'wrong if...else... termination' \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
669 + lle(lvl, buf, where) \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
670 + epsilon(buf, newpos)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
671
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
672 ifterm = data[-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
673 del data[-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
674 result.append(chunk(IF, where, (flag, 1, data)))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
675 #done implicitely: return None, newpos
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
676
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
677 elif s_buf_data in ('else', 'fi'):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
678 result.append(s(buf, data))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
679 # order calling party to return tuple
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
680 return (newpos, result), newpos
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
681
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
682 # end of \if, \else, ... \fi handling
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
683
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
684 elif s(buf, saveddata) == 'verb':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
685 x2 = saveddata[1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
686 result.append(chunk(CSNAME, where, data))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
687 if x2 == end:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
688 raise error, 'premature end of command.' + lle(lvl, buf, where)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
689 delimchar = buf[x2]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
690 ##print 'VERB: delimchar ' + `delimchar`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
691 pos = regex.compile(un_re(delimchar)).search(buf, x2 + 1)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
692 if pos < 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
693 raise error, 'end of \'verb\' argument (' + \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
694 `delimchar` + ') not found.' + \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
695 lle(lvl, buf, where)
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
696 result.append(chunk(GROUP, x2, [chunk(PLAIN, x2+1, (x2+1, pos))]))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
697 newpos = pos + 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
698 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
699 result.append(chunk(CSNAME, where, data))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
700 return None, newpos
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
701
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
702 # this is just a function to get the string value if the possible data-tuple
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
703 def s(buf, data):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
704 if type(data) is StringType:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
705 return data
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
706 if len(data) != 2 or not (type(data[0]) is type(data[1]) is IntType):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
707 raise TypeError, 'expected tuple of 2 integers'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
708 x1, x2 = data
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
709 return buf[x1:x2]
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
710
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
711
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
712 ##length, data1, i = getnextarg(length, buf, pp, i + 1)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
713
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
714 # make a deep-copy of some chunks
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
715 def crcopy(r):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
716 return map(chunkcopy, r)
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
717
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
718
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
719 # copy a chunk, would better be a method of class Chunk...
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
720 def chunkcopy(ch):
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
721 if ch.chtype == chunk_type[GROUP]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
722 return chunk(GROUP, ch.where, map(chunkcopy, ch.data))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
723 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
724 return chunk(ch.chtype, ch.where, ch.data)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
725
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
726
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
727 # get next argument for TeX-macro, flatten a group (insert between)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
728 # or return Command Sequence token, or give back one character
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
729 def getnextarg(length, buf, pp, item):
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
730
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
731 ##wobj = Wobj()
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
732 ##dumpit(buf, wobj.write, pp[item:min(length, item + 5)])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
733 ##print 'GETNEXTARG, (len, item) =', `length, item` + ' ---> ' + wobj.data + ' <---'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
734
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
735 while item < length and pp[item].chtype == chunk_type[ENDLINE]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
736 del pp[item]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
737 length = length - 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
738 if item >= length:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
739 raise error, 'no next arg.' + epsilon(buf, pp[-1].where)
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
740 if pp[item].chtype == chunk_type[GROUP]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
741 newpp = pp[item].data
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
742 del pp[item]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
743 length = length - 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
744 changeit(buf, newpp)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
745 length = length + len(newpp)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
746 pp[item:item] = newpp
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
747 item = item + len(newpp)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
748 if len(newpp) < 10:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
749 wobj = Wobj()
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
750 dumpit(buf, wobj.write, newpp)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
751 ##print 'GETNEXTARG: inserted ' + `wobj.data`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
752 return length, item
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
753 elif pp[item].chtype == chunk_type[PLAIN]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
754 #grab one char
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
755 print 'WARNING: grabbing one char'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
756 if len(s(buf, pp[item].data)) > 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
757 pp.insert(item, chunk(PLAIN, pp[item].where, s(buf, pp[item].data)[:1]))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
758 item, length = item+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
759 pp[item].data = s(buf, pp[item].data)[1:]
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
760 else:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
761 item = item+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
762 return length, item
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
763 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
764 ch = pp[item]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
765 try:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
766 str = `s(buf, ch.data)`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
767 except TypeError:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
768 str = `ch.data`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
769 if len(str) > 400:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
770 str = str[:400] + '...'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
771 print 'GETNEXTARG:', ch.chtype, 'not handled, data ' + str
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
772 return length, item
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
773
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
774
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
775 # this one is needed to find the end of LaTeX's optional argument, like
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
776 # item[...]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
777 re_endopt = regex.compile(']')
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
778
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
779 # get a LaTeX-optional argument, you know, the square braces '[' and ']'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
780 def getoptarg(length, buf, pp, item):
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
781
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
782 wobj = Wobj()
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
783 dumpit(buf, wobj.write, pp[item:min(length, item + 5)])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
784 ##print 'GETOPTARG, (len, item) =', `length, item` + ' ---> ' + wobj.data + ' <---'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
785
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
786 if item >= length or \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
787 pp[item].chtype != chunk_type[PLAIN] or \
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
788 s(buf, pp[item].data)[0] != '[':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
789 return length, item
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
790
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
791 pp[item].data = s(buf, pp[item].data)[1:]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
792 if len(pp[item].data) == 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
793 del pp[item]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
794 length = length-1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
795
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
796 while 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
797 if item == length:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
798 raise error, 'No end of optional arg found'
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
799 if pp[item].chtype == chunk_type[PLAIN]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
800 text = s(buf, pp[item].data)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
801 pos = re_endopt.search(text)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
802 if pos >= 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
803 pp[item].data = text[:pos]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
804 if pos == 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
805 del pp[item]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
806 length = length-1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
807 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
808 item=item+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
809 text = text[pos+1:]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
810
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
811 while text and text[0] in ' \t':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
812 text = text[1:]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
813
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
814 if text:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
815 pp.insert(item, chunk(PLAIN, 0, text))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
816 length = length + 1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
817 return length, item
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
818
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
819 item = item+1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
820
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
821
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
822 # Wobj just add write-requests to the ``data'' attribute
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
823 class Wobj:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
824 data = ''
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
825
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
826 def write(self, data):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
827 self.data = self.data + data
2552
7d70209f355d handle a few new things
Guido van Rossum <guido@python.org>
parents: 2038
diff changeset
828
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
829 # ignore these commands
6649
20589ed3e8bd Added the "italic correction" command ("\/") to the list of ignored commands.
Fred Drake <fdrake@acm.org>
parents: 4728
diff changeset
830 ignoredcommands = ('bcode', 'ecode', 'hline', 'fulllineitems', 'small', '/')
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
831 # map commands like these to themselves as plaintext
2575
9677eb105fae recognize more latex commands; add obindex
Guido van Rossum <guido@python.org>
parents: 2552
diff changeset
832 wordsselves = ('UNIX', 'ABC', 'C', 'ASCII', 'EOF', 'LaTeX')
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
833 # \{ --> {, \} --> }, etc
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
834 themselves = ('{', '}', ',', '.', '@', ' ', '\n') + wordsselves
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
835 # these ones also themselves (see argargs macro in myformat.sty)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
836 inargsselves = (',', '[', ']', '(', ')')
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
837 # this is how *I* would show the difference between emph and strong
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
838 # code 1 means: fold to uppercase
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
839 markcmds = {'code': ('', ''), 'var': 1, 'emph': ('_', '_'),
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
840 'strong': ('*', '*')}
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
841
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
842 # recognise patter {\FONTCHANGE-CMD TEXT} to \MAPPED-FC-CMD{TEXT}
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
843 fontchanges = {'rm': 'r', 'it': 'i', 'em': 'emph', 'bf': 'b', 'tt': 't'}
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
844
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
845 # transparent for these commands
2575
9677eb105fae recognize more latex commands; add obindex
Guido van Rossum <guido@python.org>
parents: 2552
diff changeset
846 for_texi = ('emph', 'var', 'strong', 'code', 'kbd', 'key', 'dfn', 'samp',
9677eb105fae recognize more latex commands; add obindex
Guido van Rossum <guido@python.org>
parents: 2552
diff changeset
847 'file', 'r', 'i', 't')
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
848
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
849
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
850 # try to remove macros and return flat text
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
851 def flattext(buf, pp):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
852 pp = crcopy(pp)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
853 ##print '---> FLATTEXT ' + `pp`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
854 wobj = Wobj()
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
855
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
856 i, length = 0, len(pp)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
857 while 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
858 if len(pp) != length:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
859 raise 'FATAL', 'inconsistent length'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
860 if i >= length:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
861 break
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
862 ch = pp[i]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
863 i = i+1
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
864 if ch.chtype == chunk_type[PLAIN]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
865 pass
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
866 elif ch.chtype == chunk_type[CSNAME]:
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
867 s_buf_data = s(buf, ch.data)
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
868 if s_buf_data in themselves or hist.inargs and s_buf_data in inargsselves:
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
869 ch.chtype = chunk_type[PLAIN]
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
870 elif s_buf_data == 'e':
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
871 ch.chtype = chunk_type[PLAIN]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
872 ch.data = '\\'
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
873 elif len(s_buf_data) == 1 \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
874 and s_buf_data in onlylatexspecial:
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
875 ch.chtype = chunk_type[PLAIN]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
876 # if it is followed by an empty group,
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
877 # remove that group, it was needed for
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
878 # a true space
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
879 if i < length \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
880 and pp[i].chtype==chunk_type[GROUP] \
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
881 and len(pp[i].data) == 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
882 del pp[i]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
883 length = length-1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
884
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
885 elif s_buf_data in markcmds.keys():
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
886 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
887 str = flattext(buf, pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
888 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
889 length = length - (newi - i)
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
890 ch.chtype = chunk_type[PLAIN]
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
891 markcmd = s_buf_data
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
892 x = markcmds[markcmd]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
893 if type(x) == TupleType:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
894 pre, after = x
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
895 str = pre+str+after
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
896 elif x == 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
897 str = string.upper(str)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
898 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
899 raise 'FATAL', 'corrupt markcmds'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
900 ch.data = str
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
901 else:
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
902 if s_buf_data not in ignoredcommands:
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
903 print 'WARNING: deleting command ' + s_buf_data
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
904 print 'PP' + `pp[i-1]`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
905 del pp[i-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
906 i, length = i-1, length-1
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
907 elif ch.chtype == chunk_type[GROUP]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
908 length, newi = getnextarg(length, buf, pp, i-1)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
909 i = i-1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
910 ## str = flattext(buf, crcopy(pp[i-1:newi]))
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
911 ## del pp[i:newi]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
912 ## length = length - (newi - i)
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
913 ## ch.chtype = chunk_type[PLAIN]
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
914 ## ch.data = str
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
915 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
916 pass
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
917
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
918 dumpit(buf, wobj.write, pp)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
919 ##print 'FLATTEXT: RETURNING ' + `wobj.data`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
920 return wobj.data
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
921
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
922 # try to generate node names (a bit shorter than the chapter title)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
923 # note that the \nodename command (see elsewhere) overules these efforts
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
924 def invent_node_names(text):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
925 words = string.split(text)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
926
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
927 ##print 'WORDS ' + `words`
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
928
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
929 if len(words) == 2 \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
930 and string.lower(words[0]) == 'built-in' \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
931 and string.lower(words[1]) not in ('modules', 'functions'):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
932 return words[1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
933 if len(words) == 3 and string.lower(words[1]) == 'module':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
934 return words[2]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
935 if len(words) == 3 and string.lower(words[1]) == 'object':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
936 return string.join(words[0:2])
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
937 if len(words) > 4 \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
938 and (string.lower(string.join(words[-4:])) \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
939 == 'methods and data attributes'):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
940 return string.join(words[:2])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
941 return text
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
942
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
943 re_commas_etc = regex.compile('[,`\'@{}]')
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
944
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
945 re_whitespace = regex.compile('[ \t]*')
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
946
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
947
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
948 ##nodenamecmd = next_command_p(length, buf, pp, newi, 'nodename')
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
949
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
950 # look if the next non-white stuff is also a command, resulting in skipping
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
951 # double endlines (DENDLINE) too, and thus omitting \par's
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
952 # Sometimes this is too much, maybe consider DENDLINE's as stop
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
953 def next_command_p(length, buf, pp, i, cmdname):
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
954
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
955 while 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
956 if i >= len(pp):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
957 break
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
958 ch = pp[i]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
959 i = i+1
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
960 if ch.chtype == chunk_type[ENDLINE]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
961 continue
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
962 if ch.chtype == chunk_type[DENDLINE]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
963 continue
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
964 if ch.chtype == chunk_type[PLAIN]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
965 if re_whitespace.search(s(buf, ch.data)) == 0 and \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
966 re_whitespace.match(s(buf, ch.data)) == len(s(buf, ch.data)):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
967 continue
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
968 return -1
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
969 if ch.chtype == chunk_type[CSNAME]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
970 if s(buf, ch.data) == cmdname:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
971 return i # _after_ the command
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
972 return -1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
973 return -1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
974
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
975
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
976 # things that are special to LaTeX, but not to texi..
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
977 onlylatexspecial = '_~^$#&%'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
978
1292
57b80b98b8e5 * lib1.tex: documented dict.items() and dict.values()
Guido van Rossum <guido@python.org>
parents: 1100
diff changeset
979 class Struct: pass
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
980
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
981 hist = Struct()
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
982 out = Struct()
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
983
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
984 def startchange():
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
985 global hist, out
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
986
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
987 hist.inenv = []
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
988 hist.nodenames = []
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
989 hist.cindex = []
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
990 hist.inargs = 0
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
991 hist.enumeratenesting, hist.itemizenesting = 0, 0
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
992
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
993 out.doublenodes = []
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
994 out.doublecindeces = []
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
995
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
996
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
997 spacech = [chunk(PLAIN, 0, ' ')]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
998 commach = [chunk(PLAIN, 0, ', ')]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
999 cindexch = [chunk(CSLINE, 0, 'cindex')]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1000
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1001 # the standard variation in symbols for itemize
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1002 itemizesymbols = ['bullet', 'minus', 'dots']
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1003
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1004 # same for enumerate
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1005 enumeratesymbols = ['1', 'A', 'a']
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1006
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1007 ##
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1008 ## \begin{ {func,data,exc}desc }{name}...
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1009 ## the resulting texi-code is dependent on the contents of indexsubitem
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1010 ##
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1011
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1012 # indexsubitem: `['XXX', 'function']
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1013 # funcdesc:
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1014 # deffn {`idxsi`} NAME (FUNCARGS)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1015
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1016 # indexsubitem: `['XXX', 'method']`
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1017 # funcdesc:
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1018 # defmethod {`idxsi[0]`} NAME (FUNCARGS)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1019
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1020 # indexsubitem: `['in', 'module', 'MODNAME']'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1021 # datadesc:
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1022 # defcv data {`idxsi[1:]`} NAME
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1023 # excdesc:
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1024 # defcv exception {`idxsi[1:]`} NAME
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1025 # funcdesc:
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1026 # deffn {function of `idxsi[1:]`} NAME (FUNCARGS)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1027
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1028 # indexsubitem: `['OBJECT', 'attribute']'
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1029 # datadesc
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1030 # defcv attribute {`OBJECT`} NAME
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1031
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1032
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1033 ## this routine will be called on \begin{funcdesc}{NAME}{ARGS}
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1034 ## or \funcline{NAME}{ARGS}
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1035 ##
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1036 def do_funcdesc(length, buf, pp, i):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1037 startpoint = i-1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1038 ch = pp[startpoint]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1039 wh = ch.where
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1040 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1041 funcname = chunk(GROUP, wh, pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1042 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1043 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1044 save = hist.inargs
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1045 hist.inargs = 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1046 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1047 hist.inargs = save
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1048 del save
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1049 the_args = [chunk(PLAIN, wh, '()'[0])] + pp[i:newi] + \
4389
adbe63317ccb (partparse.py): Rationalize some behavior around unexpected conditions.
Fred Drake <fdrake@acm.org>
parents: 4285
diff changeset
1050 [chunk(PLAIN, wh, '()'[1])]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1051 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1052 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1053
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1054 idxsi = hist.indexsubitem # words
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1055 command = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1056 cat_class = ''
4409
a98011f0f9ca (partparse.py): Small change by Sjoerd to improve handle of X11 extension
Fred Drake <fdrake@acm.org>
parents: 4397
diff changeset
1057 if idxsi and idxsi[-1] in ('method', 'protocol', 'attribute'):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1058 command = 'defmethod'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1059 cat_class = string.join(idxsi[:-1])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1060 elif len(idxsi) == 2 and idxsi[1] == 'function':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1061 command = 'deffn'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1062 cat_class = string.join(idxsi)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1063 elif len(idxsi) == 3 and idxsi[:2] == ['in', 'module']:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1064 command = 'deffn'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1065 cat_class = 'function of ' + string.join(idxsi[1:])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1066
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1067 if not command:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1068 raise error, 'don\'t know what to do with indexsubitem ' + `idxsi`
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1069
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1070 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1071 ch.data = command
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1072
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1073 cslinearg = [chunk(GROUP, wh, [chunk(PLAIN, wh, cat_class)])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1074 cslinearg.append(chunk(PLAIN, wh, ' '))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1075 cslinearg.append(funcname)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1076 cslinearg.append(chunk(PLAIN, wh, ' '))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1077 l = len(cslinearg)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1078 cslinearg[l:l] = the_args
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1079
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1080 pp.insert(i, chunk(GROUP, wh, cslinearg))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1081 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1082 hist.command = command
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1083 return length, i
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1084
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1085
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1086 ## this routine will be called on \begin{excdesc}{NAME}
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1087 ## or \excline{NAME}
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1088 ##
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1089 def do_excdesc(length, buf, pp, i):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1090 startpoint = i-1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1091 ch = pp[startpoint]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1092 wh = ch.where
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1093 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1094 excname = chunk(GROUP, wh, pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1095 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1096 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1097
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1098 idxsi = hist.indexsubitem # words
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1099 command = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1100 cat_class = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1101 class_class = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1102 if len(idxsi) == 2 and idxsi[1] == 'exception':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1103 command = 'defvr'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1104 cat_class = string.join(idxsi)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1105 elif len(idxsi) == 3 and idxsi[:2] == ['in', 'module']:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1106 command = 'defcv'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1107 cat_class = 'exception'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1108 class_class = string.join(idxsi[1:])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1109 elif len(idxsi) == 4 and idxsi[:3] == ['exception', 'in', 'module']:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1110 command = 'defcv'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1111 cat_class = 'exception'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1112 class_class = string.join(idxsi[2:])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1113
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1114
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1115 if not command:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1116 raise error, 'don\'t know what to do with indexsubitem ' + `idxsi`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1117
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1118 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1119 ch.data = command
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1120
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1121 cslinearg = [chunk(GROUP, wh, [chunk(PLAIN, wh, cat_class)])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1122 cslinearg.append(chunk(PLAIN, wh, ' '))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1123 if class_class:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1124 cslinearg.append(chunk(GROUP, wh, [chunk(PLAIN, wh, class_class)]))
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1125 cslinearg.append(chunk(PLAIN, wh, ' '))
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1126 cslinearg.append(excname)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1127
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1128 pp.insert(i, chunk(GROUP, wh, cslinearg))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1129 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1130 hist.command = command
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1131 return length, i
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1132
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1133 ## same for datadesc or dataline...
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1134 def do_datadesc(length, buf, pp, i):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1135 startpoint = i-1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1136 ch = pp[startpoint]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1137 wh = ch.where
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1138 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1139 dataname = chunk(GROUP, wh, pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1140 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1141 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1142
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1143 idxsi = hist.indexsubitem # words
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1144 command = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1145 cat_class = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1146 class_class = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1147 if idxsi[-1] in ('attribute', 'option'):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1148 command = 'defcv'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1149 cat_class = idxsi[-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1150 class_class = string.join(idxsi[:-1])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1151 elif len(idxsi) == 3 and idxsi[:2] == ['in', 'module']:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1152 command = 'defcv'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1153 cat_class = 'data'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1154 class_class = string.join(idxsi[1:])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1155 elif len(idxsi) == 4 and idxsi[:3] == ['data', 'in', 'module']:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1156 command = 'defcv'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1157 cat_class = 'data'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1158 class_class = string.join(idxsi[2:])
4397
890434d5bec2 (partparse.py): Small fix to do_datadesc(): in some odd cases the name of
Fred Drake <fdrake@acm.org>
parents: 4389
diff changeset
1159 else:
890434d5bec2 (partparse.py): Small fix to do_datadesc(): in some odd cases the name of
Fred Drake <fdrake@acm.org>
parents: 4389
diff changeset
1160 command = 'defcv'
890434d5bec2 (partparse.py): Small fix to do_datadesc(): in some odd cases the name of
Fred Drake <fdrake@acm.org>
parents: 4389
diff changeset
1161 cat_class = 'data'
890434d5bec2 (partparse.py): Small fix to do_datadesc(): in some odd cases the name of
Fred Drake <fdrake@acm.org>
parents: 4389
diff changeset
1162 class_class = string.join(idxsi)
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1163
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1164 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1165 ch.data = command
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1166
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1167 cslinearg = [chunk(GROUP, wh, [chunk(PLAIN, wh, cat_class)])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1168 cslinearg.append(chunk(PLAIN, wh, ' '))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1169 if class_class:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1170 cslinearg.append(chunk(GROUP, wh, [chunk(PLAIN, wh, class_class)]))
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1171 cslinearg.append(chunk(PLAIN, wh, ' '))
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1172 cslinearg.append(dataname)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1173
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1174 pp.insert(i, chunk(GROUP, wh, cslinearg))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1175 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1176 hist.command = command
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1177 return length, i
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1178
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1179
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1180 # regular indices: those that are not set in tt font by default....
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1181 regindices = ('cindex', )
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1182
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1183 # remove illegal characters from node names
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1184 def rm_commas_etc(text):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1185 result = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1186 changed = 0
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1187 while 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1188 pos = re_commas_etc.search(text)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1189 if pos >= 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1190 changed = 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1191 result = result + text[:pos]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1192 text = text[pos+1:]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1193 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1194 result = result + text
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1195 break
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1196 if changed:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1197 print 'Warning: nodename changhed to ' + `result`
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1198
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1199 return result
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1200
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1201 # boolean flags
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1202 flags = {'texi': 1}
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1203
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1204
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1205 ##
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1206 ## changeit: the actual routine, that changes the contents of the parsed
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1207 ## chunks
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1208 ##
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1209
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1210 def changeit(buf, pp):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1211 global onlylatexspecial, hist, out
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1212
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1213 i, length = 0, len(pp)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1214 while 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1215 # sanity check: length should always equal len(pp)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1216 if len(pp) != length:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1217 raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1218 if i >= length:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1219 break
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1220 ch = pp[i]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1221 i = i + 1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1222
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1223 if type(ch) is StringType:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1224 #normally, only chunks are present in pp,
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1225 # but in some cases, some extra info
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1226 # has been inserted, e.g., the \end{...} clauses
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1227 raise 'FATAL', 'got string, probably too many ' + `end`
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1228
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1229 if ch.chtype == chunk_type[GROUP]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1230 # check for {\em ...} constructs
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1231 if ch.data and \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1232 ch.data[0].chtype == chunk_type[CSNAME] and \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1233 s(buf, ch.data[0].data) in fontchanges.keys():
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1234 k = s(buf, ch.data[0].data)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1235 del ch.data[0]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1236 pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k]))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1237 length, i = length+1, i+1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1238
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1239 # recursively parse the contents of the group
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1240 changeit(buf, ch.data)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1241
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1242 elif ch.chtype == chunk_type[IF]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1243 # \if...
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1244 flag, negate, data = ch.data
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1245 ##print 'IF: flag, negate = ' + `flag, negate`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1246 if flag not in flags.keys():
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1247 raise error, 'unknown flag ' + `flag`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1248
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1249 value = flags[flag]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1250 if negate:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1251 value = (not value)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1252 del pp[i-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1253 length, i = length-1, i-1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1254 if value:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1255 pp[i:i] = data
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1256 length = length + len(data)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1257
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1258
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1259 elif ch.chtype == chunk_type[ENV]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1260 # \begin{...} ....
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1261 envname, data = ch.data
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1262
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1263 #push this environment name on stack
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1264 hist.inenv.insert(0, envname)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1265
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1266 #append an endenv chunk after grouped data
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1267 data.append(chunk(ENDENV, ch.where, envname))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1268 ##[`data`]
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1269
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1270 #delete this object
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1271 del pp[i-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1272 i, length = i-1, length-1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1273
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1274 #insert found data
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1275 pp[i:i] = data
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1276 length = length + len(data)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1277
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1278 if envname == 'verbatim':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1279 pp[i:i] = [chunk(CSLINE, ch.where, 'example'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1280 chunk(GROUP, ch.where, [])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1281 length, i = length+2, i+2
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1282
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1283 elif envname == 'itemize':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1284 if hist.itemizenesting > len(itemizesymbols):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1285 raise error, 'too deep itemize nesting'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1286 ingroupch = [chunk(CSNAME, ch.where,
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1287 itemizesymbols[hist.itemizenesting])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1288 hist.itemizenesting = hist.itemizenesting + 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1289 pp[i:i] = [chunk(CSLINE, ch.where, 'itemize'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1290 chunk(GROUP, ch.where, ingroupch)]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1291 length, i = length+2, i+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1292
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1293 elif envname == 'enumerate':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1294 if hist.enumeratenesting > len(enumeratesymbols):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1295 raise error, 'too deep enumerate nesting'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1296 ingroupch = [chunk(PLAIN, ch.where,
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1297 enumeratesymbols[hist.enumeratenesting])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1298 hist.enumeratenesting = hist.enumeratenesting + 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1299 pp[i:i] = [chunk(CSLINE, ch.where, 'enumerate'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1300 chunk(GROUP, ch.where, ingroupch)]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1301 length, i = length+2, i+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1302
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1303 elif envname == 'description':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1304 ingroupch = [chunk(CSNAME, ch.where, 'b')]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1305 pp[i:i] = [chunk(CSLINE, ch.where, 'table'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1306 chunk(GROUP, ch.where, ingroupch)]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1307 length, i = length+2, i+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1308
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1309 elif (envname == 'tableiii') or (envname == 'tableii'):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1310 if (envname == 'tableii'):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1311 ltable = 2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1312 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1313 ltable = 3
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1314 wh = ch.where
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1315 newcode = []
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1316
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1317 #delete tabular format description
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1318 # e.g., {|l|c|l|}
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1319 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1320 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1321 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1322
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1323 newcode.append(chunk(CSLINE, wh, 'table'))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1324 ingroupch = [chunk(CSNAME, wh, 'asis')]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1325 newcode.append(chunk(GROUP, wh, ingroupch))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1326 newcode.append(chunk(CSLINE, wh, 'item'))
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1327
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1328 #get the name of macro for @item
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1329 # e.g., {code}
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1330 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1331
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1332 if newi-i != 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1333 raise error, 'Sorry, expected 1 chunk argument'
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1334 if pp[i].chtype != chunk_type[PLAIN]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1335 raise error, 'Sorry, expected plain text argument'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1336 hist.itemargmacro = s(buf, pp[i].data)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1337 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1338 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1339
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1340 itembody = []
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1341 for count in range(ltable):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1342 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1343 emphgroup = [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1344 chunk(CSNAME, wh, 'emph'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1345 chunk(GROUP, 0, pp[i:newi])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1346 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1347 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1348 if count == 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1349 itemarg = emphgroup
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1350 elif count == ltable-1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1351 itembody = itembody + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1352 [chunk(PLAIN, wh, ' --- ')] + emphgroup
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1353 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1354 itembody = emphgroup
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1355 newcode.append(chunk(GROUP, wh, itemarg))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1356 newcode = newcode + itembody + [chunk(DENDLINE, wh, '\n')]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1357 pp[i:i] = newcode
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1358 l = len(newcode)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1359 length, i = length+l, i+l
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1360 del newcode, l
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1361
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1362 if length != len(pp):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1363 raise 'STILL, SOMETHING wrong', `i`
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1364
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1365
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1366 elif envname == 'funcdesc':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1367 pp.insert(i, chunk(PLAIN, ch.where, ''))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1368 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1369 length, i = do_funcdesc(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1370
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1371 elif envname == 'excdesc':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1372 pp.insert(i, chunk(PLAIN, ch.where, ''))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1373 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1374 length, i = do_excdesc(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1375
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1376 elif envname == 'datadesc':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1377 pp.insert(i, chunk(PLAIN, ch.where, ''))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1378 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1379 length, i = do_datadesc(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1380
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1381 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1382 print 'WARNING: don\'t know what to do with env ' + `envname`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1383
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1384 elif ch.chtype == chunk_type[ENDENV]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1385 envname = ch.data
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1386 if envname != hist.inenv[0]:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1387 raise error, '\'end\' does not match. Name ' + `envname` + ', expected ' + `hist.inenv[0]`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1388 del hist.inenv[0]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1389 del pp[i-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1390 i, length = i-1, length-1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1391
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1392 if envname == 'verbatim':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1393 pp[i:i] = [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1394 chunk(CSLINE, ch.where, 'end'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1395 chunk(GROUP, ch.where, [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1396 chunk(PLAIN, ch.where, 'example')])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1397 i, length = i+2, length+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1398 elif envname == 'itemize':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1399 hist.itemizenesting = hist.itemizenesting - 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1400 pp[i:i] = [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1401 chunk(CSLINE, ch.where, 'end'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1402 chunk(GROUP, ch.where, [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1403 chunk(PLAIN, ch.where, 'itemize')])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1404 i, length = i+2, length+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1405 elif envname == 'enumerate':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1406 hist.enumeratenesting = hist.enumeratenesting-1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1407 pp[i:i] = [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1408 chunk(CSLINE, ch.where, 'end'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1409 chunk(GROUP, ch.where, [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1410 chunk(PLAIN, ch.where, 'enumerate')])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1411 i, length = i+2, length+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1412 elif envname == 'description':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1413 pp[i:i] = [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1414 chunk(CSLINE, ch.where, 'end'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1415 chunk(GROUP, ch.where, [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1416 chunk(PLAIN, ch.where, 'table')])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1417 i, length = i+2, length+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1418 elif (envname == 'tableiii') or (envname == 'tableii'):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1419 pp[i:i] = [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1420 chunk(CSLINE, ch.where, 'end'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1421 chunk(GROUP, ch.where, [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1422 chunk(PLAIN, ch.where, 'table')])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1423 i, length = i+2, length + 2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1424 pp.insert(i, chunk(DENDLINE, ch.where, '\n'))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1425 i, length = i+1, length+1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1426
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1427 elif envname in ('funcdesc', 'excdesc', 'datadesc'):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1428 pp[i:i] = [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1429 chunk(CSLINE, ch.where, 'end'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1430 chunk(GROUP, ch.where, [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1431 chunk(PLAIN, ch.where, hist.command)])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1432 i, length = i+2, length+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1433 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1434 print 'WARNING: ending env ' + `envname` + 'has no actions'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1435
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1436 elif ch.chtype == chunk_type[CSNAME]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1437 # control name transformations
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1438 s_buf_data = s(buf, ch.data)
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1439 if s_buf_data == 'optional':
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1440 pp[i-1].chtype = chunk_type[PLAIN]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1441 pp[i-1].data = '['
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1442 if (i < length) and \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1443 (pp[i].chtype == chunk_type[GROUP]):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1444 cp=pp[i].data
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1445 pp[i:i+1]=cp + [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1446 chunk(PLAIN, ch.where, ']')]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1447 length = length+len(cp)
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1448 elif s_buf_data in ignoredcommands:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1449 del pp[i-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1450 i, length = i-1, length-1
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1451 elif s_buf_data == '@' and \
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1452 i != length and \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1453 pp[i].chtype == chunk_type[PLAIN] and \
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1454 s(buf, pp[i].data)[0] == '.':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1455 # \@. --> \. --> @.
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1456 ch.data = '.'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1457 del pp[i]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1458 length = length-1
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1459 elif s_buf_data == '\\':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1460 # \\ --> \* --> @*
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1461 ch.data = '*'
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1462 elif len(s_buf_data) == 1 and \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1463 s_buf_data in onlylatexspecial:
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1464 ch.chtype = chunk_type[PLAIN]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1465 # check if such a command is followed by
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1466 # an empty group: e.g., `\%{}'. If so, remove
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1467 # this empty group too
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1468 if i < length and \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1469 pp[i].chtype == chunk_type[GROUP] \
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1470 and len(pp[i].data) == 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1471 del pp[i]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1472 length = length-1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1473
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1474 elif hist.inargs and s_buf_data in inargsselves:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1475 # This is the special processing of the
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1476 # arguments of the \begin{funcdesc}... or
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1477 # \funcline... arguments
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1478 # \, --> , \[ --> [, \] --> ]
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1479 ch.chtype = chunk_type[PLAIN]
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1480
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1481 elif s_buf_data == 'renewcommand':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1482 # \renewcommand{\indexsubitem}....
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1483 i, length = i-1, length-1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1484 del pp[i]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1485 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1486 if newi-i == 1 \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1487 and i < length \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1488 and pp[i].chtype == chunk_type[CSNAME] \
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1489 and s(buf, pp[i].data) == 'indexsubitem':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1490 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1491 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1492 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1493 text = flattext(buf, pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1494 if text[:1] != '(' or text[-1:] != ')':
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1495 raise error, \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1496 'expected indexsubitem enclosed in parenteses'
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1497 words = string.split(text[1:-1])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1498 hist.indexsubitem = words
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1499 ## print 'set hist.indexsubitem =', words
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1500 del text, words
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1501 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1502 print 'WARNING: renewcommand with unsupported arg removed'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1503 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1504 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1505
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1506 elif s_buf_data == 'item':
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1507 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1508 length, newi = getoptarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1509 ingroupch = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1510 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1511 length = length - (newi-i)
4506
2b21ea2f39b4 (partparse.py): Fix nasty bug where \e got translated to @e only within
Fred Drake <fdrake@acm.org>
parents: 4409
diff changeset
1512 changeit(buf, ingroupch) # catch stuff inside the optional arg
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1513 pp.insert(i, chunk(GROUP, ch.where, ingroupch))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1514 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1515
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1516 elif s_buf_data == 'ttindex':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1517 idxsi = hist.indexsubitem
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1518
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1519 cat_class = ''
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1520 if len(idxsi) >= 2 and idxsi[1] in \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1521 ('method', 'function', 'protocol'):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1522 command = 'findex'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1523 elif len(idxsi) >= 2 and idxsi[1] in \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1524 ('exception', 'object'):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1525 command = 'vindex'
4389
adbe63317ccb (partparse.py): Rationalize some behavior around unexpected conditions.
Fred Drake <fdrake@acm.org>
parents: 4285
diff changeset
1526 elif len(idxsi) == 3 and idxsi[:2] == ['in', 'module']:
adbe63317ccb (partparse.py): Rationalize some behavior around unexpected conditions.
Fred Drake <fdrake@acm.org>
parents: 4285
diff changeset
1527 command = 'cindex'
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1528 else:
4389
adbe63317ccb (partparse.py): Rationalize some behavior around unexpected conditions.
Fred Drake <fdrake@acm.org>
parents: 4285
diff changeset
1529 print 'WARNING: can\'t categorize ' + `idxsi` \
adbe63317ccb (partparse.py): Rationalize some behavior around unexpected conditions.
Fred Drake <fdrake@acm.org>
parents: 4285
diff changeset
1530 + ' for \'ttindex\' command'
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1531 command = 'cindex'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1532
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1533 if not cat_class:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1534 cat_class = '('+string.join(idxsi)+')'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1535
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1536 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1537 ch.data = command
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1538
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1539 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1540 arg = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1541 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1542 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1543
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1544 cat_arg = [chunk(PLAIN, ch.where, cat_class)]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1545
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1546 # determine what should be set in roman, and
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1547 # what in tt-font
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1548 if command in regindices:
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1549
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1550 arg = [chunk(CSNAME, ch.where, 't'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1551 chunk(GROUP, ch.where, arg)]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1552 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1553 cat_arg = [chunk(CSNAME, ch.where, 'r'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1554 chunk(GROUP, ch.where, cat_arg)]
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1555
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1556 ingroupch = arg + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1557 [chunk(PLAIN, ch.where, ' ')] + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1558 cat_arg
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1559
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1560 pp.insert(i, chunk(GROUP, ch.where, ingroupch))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1561 length, i = length+1, i+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1562
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1563 elif s_buf_data == 'ldots':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1564 # \ldots --> \dots{} --> @dots{}
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1565 ch.data = 'dots'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1566 if i == length \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1567 or pp[i].chtype != chunk_type[GROUP] \
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1568 or pp[i].data != []:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1569 pp.insert(i, chunk(GROUP, ch.where, []))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1570 i, length = i+1, length+1
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1571 elif s_buf_data in themselves:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1572 # \UNIX --> UNIX
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1573 ch.chtype = chunk_type[PLAIN]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1574 if i != length \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1575 and pp[i].chtype == chunk_type[GROUP] \
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1576 and pp[i].data == []:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1577 del pp[i]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1578 length = length-1
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1579 elif s_buf_data in for_texi:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1580 pass
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1581
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1582 elif s_buf_data == 'e':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1583 # "\e" --> "\"
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1584 ch.data = '\\'
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1585 ch.chtype = chunk_type[PLAIN]
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1586 elif s_buf_data in ('lineiii', 'lineii'):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1587 # This is the most tricky one
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1588 # \lineiii{a1}{a2}[{a3}] -->
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1589 # @item @<cts. of itemargmacro>{a1}
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1590 # a2 [ -- a3]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1591 #
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1592 ##print 'LINEIIIIII!!!!!!!'
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
1593 ## wobj = Wobj()
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1594 ## dumpit(buf, wobj.write, pp[i-1:i+5])
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1595 ## print '--->' + wobj.data + '<----'
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1596 if not hist.inenv:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1597 raise error, 'no environment for lineiii'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1598 if (hist.inenv[0] != 'tableiii') and \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1599 (hist.inenv[0] != 'tableii'):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1600 raise error, \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1601 'wrong command (%s) in wrong environment (%s)' \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1602 % (s_buf_data, `hist.inenv[0]`)
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1603 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1604 ch.data = 'item'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1605 length, newi = getnextarg(length, buf, pp, i)
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1606 ingroupch = [chunk(CSNAME, 0, hist.itemargmacro),
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1607 chunk(GROUP, 0, pp[i:newi])]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1608 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1609 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1610 ## print 'ITEM ARG: --->',
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
1611 ## wobj = Wobj()
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1612 ## dumpit(buf, wobj.write, ingroupch)
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1613 ## print wobj.data, '<---'
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1614 pp.insert(i, chunk(GROUP, ch.where, ingroupch))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1615 grouppos = i
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1616 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1617 length, i = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1618 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1619 if newi > i:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1620 # we have a 3rd arg
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1621 pp.insert(i, chunk(PLAIN, ch.where, ' --- '))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1622 i = newi + 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1623 length = length + 1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1624 ## pp[grouppos].data = pp[grouppos].data \
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1625 ## + [chunk(PLAIN, ch.where, ' ')] \
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1626 ## + pp[i:newi]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1627 ## del pp[i:newi]
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1628 ## length = length - (newi-i)
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1629 if length != len(pp):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1630 raise 'IN LINEIII IS THE ERR', `i`
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1631
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1632 elif s_buf_data in ('chapter', 'section', 'subsection', 'subsubsection'):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1633 #\xxxsection{A} ---->
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1634 # @node A, , ,
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1635 # @xxxsection A
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1636 ## also: remove commas and quotes
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1637 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1638 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1639 afternodenamecmd = next_command_p(length, buf, pp, newi, 'nodename')
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1640 if afternodenamecmd < 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1641 cp1 = crcopy(pp[i:newi])
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1642 pp[i:newi] = [chunk(GROUP, ch.where, pp[i:newi])]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1643 length, newi = length - (newi-i) + 1, i+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1644 text = flattext(buf, cp1)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1645 text = invent_node_names(text)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1646 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1647 length, endarg = getnextarg(length, buf, pp, afternodenamecmd)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1648 cp1 = crcopy(pp[afternodenamecmd:endarg])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1649 del pp[newi:endarg]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1650 length = length - (endarg-newi)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1651
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1652 pp[i:newi] = [chunk(GROUP, ch.where, pp[i:newi])]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1653 length, newi = length - (newi-i) + 1, i + 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1654 text = flattext(buf, cp1)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1655 if text[-1] == '.':
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1656 text = text[:-1]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1657 ## print 'FLATTEXT:', `text`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1658 if text in hist.nodenames:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1659 print 'WARNING: node name ' + `text` + ' already used'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1660 out.doublenodes.append(text)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1661 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1662 hist.nodenames.append(text)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1663 text = rm_commas_etc(text)
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1664 pp[i-1:i-1] = [chunk(CSLINE, ch.where, 'node'),
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1665 chunk(GROUP, ch.where, [
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1666 chunk(PLAIN, ch.where, text+', , ,')
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1667 ])]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1668 i, length = newi+2, length+2
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1669
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1670 elif s_buf_data == 'funcline':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1671 # fold it to a very short environment
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1672 pp[i-1:i-1] = [chunk(CSLINE, ch.where, 'end'),
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1673 chunk(GROUP, ch.where, [
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1674 chunk(PLAIN, ch.where, hist.command)])]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1675 i, length = i+2, length+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1676 length, i = do_funcdesc(length, buf, pp, i)
2575
9677eb105fae recognize more latex commands; add obindex
Guido van Rossum <guido@python.org>
parents: 2552
diff changeset
1677
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1678 elif s_buf_data == 'dataline':
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1679 pp[i-1:i-1] = [chunk(CSLINE, ch.where, 'end'),
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1680 chunk(GROUP, ch.where, [
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1681 chunk(PLAIN, ch.where, hist.command)])]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1682 i, length = i+2, length+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1683 length, i = do_datadesc(length, buf, pp, i)
2575
9677eb105fae recognize more latex commands; add obindex
Guido van Rossum <guido@python.org>
parents: 2552
diff changeset
1684
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1685 elif s_buf_data == 'excline':
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1686 pp[i-1:i-1] = [chunk(CSLINE, ch.where, 'end'),
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1687 chunk(GROUP, ch.where, [
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1688 chunk(PLAIN, ch.where, hist.command)])]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1689 i, length = i+2, length+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1690 length, i = do_excdesc(length, buf, pp, i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1691
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1692 elif s_buf_data == 'index':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1693 #\index{A} --->
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1694 # @cindex A
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1695 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1696 ch.data = 'cindex'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1697 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1698
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1699 ingroupch = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1700 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1701 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1702 pp.insert(i, chunk(GROUP, ch.where, ingroupch))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1703 length, i = length+1, i+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1704
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1705 elif s_buf_data == 'bifuncindex':
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1706 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1707 ch.data = 'findex'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1708 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1709 ingroupch = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1710 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1711 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1712
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1713 ingroupch.append(chunk(PLAIN, ch.where, ' '))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1714 ingroupch.append(chunk(CSNAME, ch.where, 'r'))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1715 ingroupch.append(chunk(GROUP, ch.where, [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1716 chunk(PLAIN, ch.where,
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1717 '(built-in function)')]))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1718
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1719 pp.insert(i, chunk(GROUP, ch.where, ingroupch))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1720 length, i = length+1, i+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1721
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1722 elif s_buf_data == 'obindex':
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1723 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1724 ch.data = 'findex'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1725 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1726 ingroupch = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1727 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1728 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1729
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1730 ingroupch.append(chunk(PLAIN, ch.where, ' '))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1731 ingroupch.append(chunk(CSNAME, ch.where, 'r'))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1732 ingroupch.append(chunk(GROUP, ch.where, [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1733 chunk(PLAIN, ch.where,
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1734 '(object)')]))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1735
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1736 pp.insert(i, chunk(GROUP, ch.where, ingroupch))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1737 length, i = length+1, i+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1738
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1739 elif s_buf_data == 'opindex':
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1740 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1741 ch.data = 'findex'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1742 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1743 ingroupch = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1744 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1745 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1746
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1747 ingroupch.append(chunk(PLAIN, ch.where, ' '))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1748 ingroupch.append(chunk(CSNAME, ch.where, 'r'))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1749 ingroupch.append(chunk(GROUP, ch.where, [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1750 chunk(PLAIN, ch.where,
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1751 '(operator)')]))
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1752
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1753 pp.insert(i, chunk(GROUP, ch.where, ingroupch))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1754 length, i = length+1, i+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1755
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1756 elif s_buf_data == 'bimodindex':
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1757 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1758 ch.data = 'pindex'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1759 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1760 ingroupch = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1761 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1762 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1763
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1764 ingroupch.append(chunk(PLAIN, ch.where, ' '))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1765 ingroupch.append(chunk(CSNAME, ch.where, 'r'))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1766 ingroupch.append(chunk(GROUP, ch.where, [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1767 chunk(PLAIN, ch.where,
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1768 '(built-in)')]))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1769
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1770 pp.insert(i, chunk(GROUP, ch.where, ingroupch))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1771 length, i = length+1, i+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1772
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1773 elif s_buf_data == 'sectcode':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1774 ch.data = 'code'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1775
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1776 elif s_buf_data == 'stmodindex':
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1777 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1778 # use the program index as module index
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1779 ch.data = 'pindex'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1780 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1781 ingroupch = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1782 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1783 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1784
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1785 ingroupch.append(chunk(PLAIN, ch.where, ' '))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1786 ingroupch.append(chunk(CSNAME, ch.where, 'r'))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1787 ingroupch.append(chunk(GROUP, ch.where, [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1788 chunk(PLAIN, ch.where,
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1789 '(standard)')]))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1790
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1791 pp.insert(i, chunk(GROUP, ch.where, ingroupch))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1792 length, i = length+1, i+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1793
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1794 elif s_buf_data == 'stindex':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1795 # XXX must actually go to newindex st
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1796 wh = ch.where
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1797 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1798 ch.data = 'cindex'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1799 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1800 ingroupch = [chunk(CSNAME, wh, 'code'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1801 chunk(GROUP, wh, pp[i:newi])]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1802
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1803 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1804 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1805
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1806 t = ingroupch[:]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1807 t.append(chunk(PLAIN, wh, ' statement'))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1808
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1809 pp.insert(i, chunk(GROUP, wh, t))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1810 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1811
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1812 pp.insert(i, chunk(CSLINE, wh, 'cindex'))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1813 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1814
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1815 t = ingroupch[:]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1816 t.insert(0, chunk(PLAIN, wh, 'statement, '))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1817
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1818 pp.insert(i, chunk(GROUP, wh, t))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1819 i, length = i+1, length+1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1820
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1821 elif s_buf_data == 'indexii':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1822 #\indexii{A}{B} --->
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1823 # @cindex A B
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1824 # @cindex B, A
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1825 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1826 cp11 = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1827 cp21 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1828 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1829 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1830 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1831 cp12 = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1832 cp22 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1833 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1834 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1835
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1836 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1837 ch.data = 'cindex'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1838 pp.insert(i, chunk(GROUP, ch.where, cp11 + [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1839 chunk(PLAIN, ch.where, ' ')] + cp12))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1840 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1841 pp[i:i] = [chunk(CSLINE, ch.where, 'cindex'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1842 chunk(GROUP, ch.where, cp22 + [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1843 chunk(PLAIN, ch.where, ', ')]+ cp21)]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1844 i, length = i+2, length+2
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1845
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1846 elif s_buf_data == 'indexiii':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1847 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1848 cp11 = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1849 cp21 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1850 cp31 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1851 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1852 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1853 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1854 cp12 = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1855 cp22 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1856 cp32 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1857 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1858 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1859 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1860 cp13 = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1861 cp23 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1862 cp33 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1863 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1864 length = length - (newi-i)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1865
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1866 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1867 ch.data = 'cindex'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1868 pp.insert(i, chunk(GROUP, ch.where, cp11 + [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1869 chunk(PLAIN, ch.where, ' ')] + cp12
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1870 + [chunk(PLAIN, ch.where, ' ')]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1871 + cp13))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1872 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1873 pp[i:i] = [chunk(CSLINE, ch.where, 'cindex'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1874 chunk(GROUP, ch.where, cp22 + [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1875 chunk(PLAIN, ch.where, ' ')]+ cp23
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1876 + [chunk(PLAIN, ch.where, ', ')] +
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1877 cp21)]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1878 i, length = i+2, length+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1879 pp[i:i] = [chunk(CSLINE, ch.where, 'cindex'),
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1880 chunk(GROUP, ch.where, cp33 + [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1881 chunk(PLAIN, ch.where, ', ')]+ cp31
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1882 + [chunk(PLAIN, ch.where, ' ')] +
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1883 cp32)]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1884 i, length = i+2, length+2
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1885
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1886 elif s_buf_data == 'indexiv':
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1887 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1888 cp11 = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1889 cp21 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1890 cp31 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1891 cp41 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1892 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1893 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1894 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1895 cp12 = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1896 cp22 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1897 cp32 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1898 cp42 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1899 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1900 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1901 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1902 cp13 = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1903 cp23 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1904 cp33 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1905 cp43 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1906 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1907 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1908 length, newi = getnextarg(length, buf, pp, i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1909 cp14 = pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1910 cp24 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1911 cp34 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1912 cp44 = crcopy(pp[i:newi])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1913 del pp[i:newi]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1914 length = length - (newi-i)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1915
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1916 ch.chtype = chunk_type[CSLINE]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1917 ch.data = 'cindex'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1918 ingroupch = cp11 + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1919 spacech + cp12 + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1920 spacech + cp13 + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1921 spacech + cp14
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1922 pp.insert(i, chunk(GROUP, ch.where, ingroupch))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1923 i, length = i+1, length+1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1924 ingroupch = cp22 + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1925 spacech + cp23 + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1926 spacech + cp24 + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1927 commach + cp21
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1928 pp[i:i] = cindexch + [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1929 chunk(GROUP, ch.where, ingroupch)]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1930 i, length = i+2, length+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1931 ingroupch = cp33 + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1932 spacech + cp34 + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1933 commach + cp31 + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1934 spacech + cp32
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1935 pp[i:i] = cindexch + [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1936 chunk(GROUP, ch.where, ingroupch)]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1937 i, length = i+2, length+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1938 ingroupch = cp44 + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1939 commach + cp41 + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1940 spacech + cp42 + \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1941 spacech + cp43
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1942 pp[i:i] = cindexch + [
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1943 chunk(GROUP, ch.where, ingroupch)]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1944 i, length = i+2, length+2
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1945
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1946 ## elif s_buf_data == 'indexsubitem':
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1947 ## ch.data = flattext(buf, [ch])
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1948 ## ch.chtype = chunk_type[PLAIN]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1949
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1950 elif s_buf_data in ('noindent', 'indexsubitem'):
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1951 pass
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1952
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1953 else:
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1954 print "don't know what to do with keyword " + s_buf_data
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1955
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1956
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1957 re_atsign = regex.compile('[@{}]')
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1958 re_newline = regex.compile('\n')
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1959
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1960 def dumpit(buf, wm, pp):
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1961
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1962 global out
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1963
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1964 i, length = 0, len(pp)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1965
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1966 addspace = 0
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1967
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1968 while 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1969 if len(pp) != length:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1970 raise 'FATAL', 'inconsistent length'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1971 if i == length:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1972 break
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1973 ch = pp[i]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1974 i = i + 1
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1975
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1976 dospace = addspace
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1977 addspace = 0
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1978
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1979 if ch.chtype == chunk_type[CSNAME]:
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1980 s_buf_data = s(buf, ch.data)
4728
b218f294b726 (lib<all sorts of stuff>.tex):
Fred Drake <fdrake@acm.org>
parents: 4506
diff changeset
1981 if s_buf_data == 'e':
b218f294b726 (lib<all sorts of stuff>.tex):
Fred Drake <fdrake@acm.org>
parents: 4506
diff changeset
1982 wm('\\')
b218f294b726 (lib<all sorts of stuff>.tex):
Fred Drake <fdrake@acm.org>
parents: 4506
diff changeset
1983 continue
b218f294b726 (lib<all sorts of stuff>.tex):
Fred Drake <fdrake@acm.org>
parents: 4506
diff changeset
1984 if s_buf_data == '$':
b218f294b726 (lib<all sorts of stuff>.tex):
Fred Drake <fdrake@acm.org>
parents: 4506
diff changeset
1985 wm('$')
b218f294b726 (lib<all sorts of stuff>.tex):
Fred Drake <fdrake@acm.org>
parents: 4506
diff changeset
1986 continue
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1987 wm('@' + s_buf_data)
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1988 if s_buf_data == 'node' and \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1989 pp[i].chtype == chunk_type[PLAIN] and \
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1990 s(buf, pp[i].data) in out.doublenodes:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1991 ##XXX doesnt work yet??
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1992 wm(' ZZZ-' + zfill(`i`, 4))
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1993 if s_buf_data[0] in string.letters:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1994 addspace = 1
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
1995 elif ch.chtype == chunk_type[PLAIN]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1996 if dospace and s(buf, ch.data) not in (' ', '\t'):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1997 wm(' ')
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1998 text = s(buf, ch.data)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
1999 while 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2000 pos = re_atsign.search(text)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2001 if pos < 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2002 break
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2003 wm(text[:pos] + '@' + text[pos])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2004 text = text[pos+1:]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2005 wm(text)
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2006 elif ch.chtype == chunk_type[GROUP]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2007 wm('{')
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2008 dumpit(buf, wm, ch.data)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2009 wm('}')
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2010 elif ch.chtype == chunk_type[DENDLINE]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2011 wm('\n\n')
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2012 while i != length and pp[i].chtype in \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2013 (chunk_type[DENDLINE], chunk_type[ENDLINE]):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2014 i = i + 1
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2015 elif ch.chtype == chunk_type[OTHER]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2016 wm(s(buf, ch.data))
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2017 elif ch.chtype == chunk_type[ACTIVE]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2018 wm(s(buf, ch.data))
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2019 elif ch.chtype == chunk_type[ENDLINE]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2020 wm('\n')
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2021 elif ch.chtype == chunk_type[CSLINE]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2022 if i >= 2 and pp[i-2].chtype not in \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2023 (chunk_type[ENDLINE], chunk_type[DENDLINE]) \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2024 and (pp[i-2].chtype != chunk_type[PLAIN]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2025 or s(buf, pp[i-2].data)[-1] != '\n'):
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
2026
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2027 wm('\n')
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2028 wm('@' + s(buf, ch.data))
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2029 if i == length:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2030 raise error, 'CSLINE expected another chunk'
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2031 if pp[i].chtype != chunk_type[GROUP]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2032 raise error, 'CSLINE expected GROUP'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2033 if type(pp[i].data) != ListType:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2034 raise error, 'GROUP chould contain []-data'
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
2035
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2036 wobj = Wobj()
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2037 dumpit(buf, wobj.write, pp[i].data)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2038 i = i + 1
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2039 text = wobj.data
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2040 del wobj
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2041 if text:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2042 wm(' ')
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2043 while 1:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2044 pos = re_newline.search(text)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2045 if pos < 0:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2046 break
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2047 print 'WARNING: found newline in csline arg'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2048 wm(text[:pos] + ' ')
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2049 text = text[pos+1:]
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2050 wm(text)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2051 if i >= length or \
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2052 pp[i].chtype not in (chunk_type[CSLINE],
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2053 chunk_type[ENDLINE], chunk_type[DENDLINE]) \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2054 and (pp[i].chtype != chunk_type[PLAIN]
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2055 or s(buf, pp[i].data)[0] != '\n'):
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2056 wm('\n')
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2057
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2058 elif ch.chtype == chunk_type[COMMENT]:
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2059 ## print 'COMMENT: previous chunk =', pp[i-2]
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2060 ## if pp[i-2].chtype == chunk_type[PLAIN]:
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2061 ## print 'PLAINTEXT =', `s(buf, pp[i-2].data)`
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2062 if s(buf, ch.data) and \
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2063 regex.match('^[ \t]*$', s(buf, ch.data)) < 0:
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2064 if i >= 2 \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2065 and pp[i-2].chtype not in (chunk_type[ENDLINE], chunk_type[DENDLINE]) \
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2066 and not (pp[i-2].chtype == chunk_type[PLAIN]
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2067 and regex.match('\\(.\\|\n\\)*[ \t]*\n$', s(buf, pp[i-2].data)) >= 0):
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2068 wm('\n')
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2069 wm('@c ' + s(buf, ch.data))
4285
b69f4b83892e More performance and layout improvements by Fred
Guido van Rossum <guido@python.org>
parents: 4273
diff changeset
2070 elif ch.chtype == chunk_type[IGNORE]:
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2071 pass
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2072 else:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2073 try:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2074 str = `s(buf, ch.data)`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2075 except TypeError:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2076 str = `ch.data`
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2077 if len(str) > 400:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2078 str = str[:400] + '...'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2079 print 'warning:', ch.chtype, 'not handled, data ' + str
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2080
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2081
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2082
1401
cd5989a58bcf * ext.tex: documentation for extending, reference counts, and embedding
Guido van Rossum <guido@python.org>
parents: 1292
diff changeset
2083 def main():
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2084 outfile = None
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2085 headerfile = 'texipre.dat'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2086 trailerfile = 'texipost.dat'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2087
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2088 try:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2089 opts, args = getopt.getopt(sys.argv[1:], 'o:h:t:')
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2090 except getopt.error:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2091 args = []
1401
cd5989a58bcf * ext.tex: documentation for extending, reference counts, and embedding
Guido van Rossum <guido@python.org>
parents: 1292
diff changeset
2092
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2093 if not args:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2094 print 'usage: partparse [-o outfile] [-h headerfile]',
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2095 print '[-t trailerfile] file ...'
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2096 sys.exit(2)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2097
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2098 for opt, arg in opts:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2099 if opt == '-o': outfile = arg
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2100 if opt == '-h': headerfile = arg
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2101 if opt == '-t': trailerfile = arg
1401
cd5989a58bcf * ext.tex: documentation for extending, reference counts, and embedding
Guido van Rossum <guido@python.org>
parents: 1292
diff changeset
2102
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2103 if not outfile:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2104 root, ext = os.path.splitext(args[0])
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2105 outfile = root + '.texi'
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2106
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2107 if outfile in args:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2108 print 'will not overwrite input file', outfile
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2109 sys.exit(2)
1401
cd5989a58bcf * ext.tex: documentation for extending, reference counts, and embedding
Guido van Rossum <guido@python.org>
parents: 1292
diff changeset
2110
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2111 outf = open(outfile, 'w')
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2112 outf.write(open(headerfile, 'r').read())
1401
cd5989a58bcf * ext.tex: documentation for extending, reference counts, and embedding
Guido van Rossum <guido@python.org>
parents: 1292
diff changeset
2113
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2114 for file in args:
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2115 if len(args) > 1: print '='*20, file, '='*20
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2116 buf = open(file, 'r').read()
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2117 w, pp = parseit(buf)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2118 startchange()
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2119 changeit(buf, pp)
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2120 dumpit(buf, outf.write, pp)
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2121
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2122 outf.write(open(trailerfile, 'r').read())
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2123
4273
c48764bf62d1 Reformatted with 4 spaces indent.
Guido van Rossum <guido@python.org>
parents: 4272
diff changeset
2124 outf.close()
1100
ff1899dcda05 Incorporated Jan-Hein's changes and texinfo conversion.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2125
4272
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
2126 if __name__ == "__main__":
e7890336f107 20% speedup by Fred
Guido van Rossum <guido@python.org>
parents: 2608
diff changeset
2127 main()