292 | | if value[1]: |
293 | | return '%s<li>%s\n%s<ul>\n%s\n%s</ul>\n%s</li>' % (indent, value[0], indent, |
294 | | '\n'.join([_helper(v, tabs+1) for v in value[1]]), indent, indent) |
| 292 | if type(value) != type([]): |
| 293 | value = [value] |
| 294 | l = len(value) |
| 295 | if l == 0: |
| 296 | return '' |
| 297 | if l == 1: |
| 298 | if type(value[0]) is type([]): |
| 299 | return _helper(['', value[0]], tabs) |
| 300 | else: |
| 301 | return _helper([value[0], []], tabs) |
| 302 | if l == 2 and type(value[1]) is type([]): |
| 303 | if value[1]: |
| 304 | return '%s<li>%s\n%s<ul>\n%s\n%s</ul>\n%s</li>' % (indent, value[0], indent, |
| 305 | '\n'.join([_helper(v, tabs+1) for v in value[1]]), indent, indent) |
| 306 | else: |
| 307 | return '%s<li>%s</li>' % (indent, value[0]) |
296 | | return '%s<li>%s</li>' % (indent, value[0]) |
| 309 | html = [] |
| 310 | i = 0 |
| 311 | while i < l: |
| 312 | if i < l-1: |
| 313 | if type(value[i]) is type([]): |
| 314 | html.append(_helper(['', value[i]], tabs)) |
| 315 | i += 1 |
| 316 | continue |
| 317 | elif type(value[i+1]) is type([]): |
| 318 | html.append(_helper([value[i], value[i+1]], tabs)) |
| 319 | i += 2 |
| 320 | continue |
| 321 | html.append(_helper([value[i], []], tabs)) |
| 322 | i += 1 |
| 323 | return '\n'.join(html) |
| 324 | |