Exemplo n.º 1
0
def section(ast):
    sections = [ast]
    for n in children(ast):
        if n.t == u'Heading':
            doc = Node('Document', [[1, 1], [0, 0]])

            n.parent = doc
            doc.first_child = n
            doc.last_child = ast.last_child

            if n == ast.first_child:
                sections = []

            ast.last_child = n.prv
            if n.prv:
                n.prv.nxt = None
            else:
                ast.first_child = None
            n.prv = None

            sections.append(doc)

    return sections
Exemplo n.º 2
0
def section(ast):
	sections = [ast]
	for n in children(ast):
		if n.t == u'Heading':
			doc = Node('Document', [[1, 1], [0, 0]])


			n.parent = doc
			doc.first_child = n
			doc.last_child = ast.last_child

			if n == ast.first_child:
				sections = []

			ast.last_child = n.prv
			if n.prv:
				n.prv.nxt = None
			else:
				ast.first_child = None
			n.prv = None

			sections.append(doc)

	return sections