Fix #338: re.sub() flag argument at wrong position.
[docutils.git] / sandbox / aahz / Effective / EffTransformer.py
bloba88e41cd755c1cfae58d457df156d910164e965f
1 from docutils import nodes
2 from docutils import transforms
4 #class index_entry(nodes.Inline, nodes.TextElement): pass
6 class Index(transforms.Transform):
7 default_priority = 250
9 def apply(self):
10 pending = self.startnode
11 curr_index = pending.parent.index(pending)
12 if curr_index == 0:
13 error = self.document.reporter.error(
14 'Index directive must follow a text node',
15 nodes.literal_block(pending.rawsource, pending.rawsource),
16 line=pending.line)
17 pending.parent.replace(pending, error)
18 return
19 entries = []
20 for entry in pending.details['entries']:
21 entries.append(entry)
22 sibling = pending.parent[curr_index-1]
23 sibling.children[0:0] = entries
24 pending.parent.remove(pending)