I've just added a longer version of this post at the end of
#334. I wanted to reference those remarks here as an acknowledgement of Tom F's contribution.
Tom's
importer proposal was the first to suggest that the importers be organized as a pipeline. At first, I dismissed that suggestion. In fact Tom's suggestions have been marinating in the back of my mind ever since. Thank you, Tom! Leo's great new importers owe a lot to you...
The new Importer class now clearly is a pipeline:
Stage 1: i.run calls the first stage: i.v2_gen_lines. It generates, in a single, non-recursive pass, all the output nodes.
Stage 2: i.run then calls the second stage, i.post_pass, which runs a
series of other passes:
def post_pass(self, parent):
'''Clean up parent and all its descendants.'''
self.clean_all_headlines(parent)
self.clean_all_nodes(parent)
self.unindent_all_nodes(parent)
# These passes must follow unindent_all_nodes.
self.promote_trailing_underindented_lines(parent)
# This probably should be the last pass.
self.delete_all_empty_nodes(parent)
This organization solves a number of technical problems, and makes it much easier to create custom importers.
Edward