def make_node(self): parser = self.parser index = parser.caret + 1 char = parser.text[index] if parser.text[index - 1] != '\n' or char not in '*+^': return None if char == '^': index += 1 char = parser.text[index] if char not in '*+': return None flag = 'close' total = 0 while parser.text[index] == char: index += 1 total += 1 else: flag = None total = 0 while parser.text[index] == char: index += 1 total += 1 node = Element('list_item') if flag is not None: node['flag'] = flag node['level'] = total if char == '*': node['type'] = 'ul' else: node['type'] = 'ol' node.pos = parser.copy_pos() parser.update(index) total = node.attlen parser['ElementNP'].get_attribute_list(parser, node, '[', ']') for num in xrange(total, node.attlen): node.rename(num, '__' + node.attribute(num)) total = node.attlen parser['ElementNP'].get_attribute_list(parser, node) for num in xrange(total, node.attlen): node.rename(num, '_' + node.attribute(num)) if parser.text[parser.caret] == ' ': parser.update(parser.caret + 1) return node
def make_node(self): parser = self.parser index = parser.caret + 1 char = parser.text[index] if parser.text[index-1] != '\n' or char not in '*+^': return None if char == '^': index += 1 char = parser.text[index] if char not in '*+': return None flag = 'close' total = 0 while parser.text[index] == char: index += 1 total += 1 else: flag = None total = 0 while parser.text[index] == char: index += 1 total += 1 node = Element('list_item') if flag is not None: node['flag'] = flag node['level'] = total if char == '*': node['type'] = 'ul' else: node['type'] = 'ol' node.pos = parser.copy_pos() parser.update(index) total = node.attlen parser['ElementNP'].get_attribute_list(parser, node, '[', ']') for num in xrange(total, node.attlen): node.rename(num, '__'+node.attribute(num)) total = node.attlen parser['ElementNP'].get_attribute_list(parser, node) for num in xrange(total, node.attlen): node.rename(num, '_'+node.attribute(num)) if parser.text[parser.caret] == ' ': parser.update(parser.caret+1) return node