@@ -23,7 +23,6 @@ def __init__(self, textile, tatts, rows, summary):
23
23
self .input = rows
24
24
self .caption = ''
25
25
self .colgroup = ''
26
- self .rows = []
27
26
self .content = []
28
27
29
28
def process (self ):
@@ -73,6 +72,8 @@ def process(self):
73
72
74
73
grptypes = {'^' : Thead , '~' : Tfoot , '-' : Tbody }
75
74
if grpmatch .group ('part' ):
75
+ # we're about to start a new group, so process the current one
76
+ # and add it to the output
76
77
if rgrp :
77
78
groups .append ('\n \t {0}' .format (rgrp .process ()))
78
79
rgrp = grptypes [grpmatch .group ('part' )](grpmatch .group (
@@ -87,12 +88,13 @@ def process(self):
87
88
else :
88
89
row_atts = {}
89
90
90
- cells = []
91
+ # create a row to hold the cells.
91
92
r = Row (row_atts , row )
92
93
for cellctr , cell in enumerate (row .split ('|' )[1 :]):
93
94
ctag = 'td'
94
95
if cell .startswith ('_' ):
95
96
ctag = 'th'
97
+
96
98
cmtch = re .search (r'^(?P<catts>_?{0}{1}{2}\. )'
97
99
'(?P<cell>.*)' .format (table_span_re_s , align_re_s ,
98
100
cls_re_s ), cell , flags = re .S )
@@ -111,23 +113,20 @@ def process(self):
111
113
cell = self .textile .textileLists (cell )
112
114
cell = '{0}{1}' .format (a .group ('space' ), cell )
113
115
114
- # row.split() gives us ['', 'cell 1 contents', '...']
115
- # so we ignore the first cell.
116
+ # create a cell
116
117
c = Cell (ctag , cell , cell_atts )
117
118
cline_tag = '\n \t \t \t {0}' .format (c .process ())
119
+ # add the cell to the row
118
120
r .cells .append (self .textile .doTagBr (ctag , cline_tag ))
119
121
122
+ # if we're in a group, add it to the group's rows, else add it
123
+ # directly to the content
120
124
if rgrp :
121
125
rgrp .rows .append (r .process ())
122
126
else :
123
127
self .content .append (r .process ())
124
128
125
- # if no group was specified, just join the rows
126
- if not rgrp :
127
- groups .append ('{0}' .format ('\n \t ' .join (self .rows )))
128
- cells = []
129
- self .rows = []
130
-
129
+ # if there's still an rgrp, process it and add it to the output
131
130
if rgrp :
132
131
groups .append ('\n \t {0}' .format (rgrp .process ()))
133
132
0 commit comments