MCPcopy Index your code
hub / github.com/aitjcize/cppman / gen

Method gen

cppman/formatter/tableparser.py:127–170  ·  view source on GitHub ↗
(self, fd, index=0, last=False, rowspan=None)

Source from the content-addressed store, hash-verified

125 return format_str
126
127 def gen(self, fd, index=0, last=False, rowspan=None):
128 if rowspan is None:
129 rowspan = {}
130
131 if self.name == 'table':
132 fd.write('.TS\n')
133 fd.write('allbox tab(|);\n')
134 fd.write(self.scan_format())
135 elif self.name in ['th', 'td']:
136 fd.write('T{\n%s' % self.text)
137 if 'rowspan' in self.attr and int(self.attr['rowspan']) > 1:
138 rowspan[index] = int(self.attr['rowspan']) - 1
139 else:
140 fd.write(self.text)
141
142 if self.name == 'tr' and len(rowspan) > 0:
143 total = len(rowspan) + len(self.children)
144 ci = 0
145 for i in range(total):
146 if i in rowspan:
147 fd.write(r'\^%s' % ('|' if i < total - 1 else ''))
148 if rowspan[i] == 1:
149 del rowspan[i]
150 else:
151 rowspan[i] -= 1
152 else:
153 # There is a row span, but the current number of column is
154 # not enough. Pad empty node when this happens.
155 if ci >= len(self.children):
156 self.children.append(Node(self, 'td', '', ''))
157
158 self.children[ci].gen(fd, i, i == total - 1, rowspan)
159 ci += 1
160 else:
161 for i, c in enumerate(self.children):
162 c.gen(fd, i, i == len(self.children) - 1, rowspan)
163
164 if self.name == 'table':
165 fd.write('.TE\n')
166 fd.write('.sp\n.sp\n')
167 elif self.name == 'tr':
168 fd.write('\n')
169 elif self.name in ['th', 'td']:
170 fd.write('\nT}%s' % ('|' if not last else ''))
171
172
173def parse_table(html):

Callers 1

parse_tableFunction · 0.95

Calls 2

scan_formatMethod · 0.95
NodeClass · 0.85

Tested by

no test coverage detected