Skip to content

Commit 15bda67

Browse files
committed
cleanup and documentating.
1 parent 5980431 commit 15bda67

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

textile/objects/table.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def __init__(self, textile, tatts, rows, summary):
2323
self.input = rows
2424
self.caption = ''
2525
self.colgroup = ''
26-
self.rows = []
2726
self.content = []
2827

2928
def process(self):
@@ -73,6 +72,8 @@ def process(self):
7372

7473
grptypes = {'^': Thead, '~': Tfoot, '-': Tbody}
7574
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
7677
if rgrp:
7778
groups.append('\n\t{0}'.format(rgrp.process()))
7879
rgrp = grptypes[grpmatch.group('part')](grpmatch.group(
@@ -87,12 +88,13 @@ def process(self):
8788
else:
8889
row_atts = {}
8990

90-
cells = []
91+
# create a row to hold the cells.
9192
r = Row(row_atts, row)
9293
for cellctr, cell in enumerate(row.split('|')[1:]):
9394
ctag = 'td'
9495
if cell.startswith('_'):
9596
ctag = 'th'
97+
9698
cmtch = re.search(r'^(?P<catts>_?{0}{1}{2}\. )'
9799
'(?P<cell>.*)'.format(table_span_re_s, align_re_s,
98100
cls_re_s), cell, flags=re.S)
@@ -111,23 +113,20 @@ def process(self):
111113
cell = self.textile.textileLists(cell)
112114
cell = '{0}{1}'.format(a.group('space'), cell)
113115

114-
# row.split() gives us ['', 'cell 1 contents', '...']
115-
# so we ignore the first cell.
116+
# create a cell
116117
c = Cell(ctag, cell, cell_atts)
117118
cline_tag = '\n\t\t\t{0}'.format(c.process())
119+
# add the cell to the row
118120
r.cells.append(self.textile.doTagBr(ctag, cline_tag))
119121

122+
# if we're in a group, add it to the group's rows, else add it
123+
# directly to the content
120124
if rgrp:
121125
rgrp.rows.append(r.process())
122126
else:
123127
self.content.append(r.process())
124128

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
131130
if rgrp:
132131
groups.append('\n\t{0}'.format(rgrp.process()))
133132

0 commit comments

Comments
 (0)