1.1 --- a/xmlparser.py Sat Jun 08 18:44:37 2013 +0200
1.2 +++ b/xmlparser.py Sun Jun 09 01:43:09 2013 +0200
1.3 @@ -152,6 +152,7 @@
1.4
1.5 self.macro = None
1.6 self.macro_parameters = {}
1.7 + self.held_anchors = []
1.8
1.9 # Indentation and element nesting states.
1.10
1.11 @@ -196,6 +197,9 @@
1.12
1.13 self.indents.append(0)
1.14
1.15 + if name in headings:
1.16 + self.held_anchors = []
1.17 +
1.18 Parser.startElement(self, name, attrs)
1.19
1.20 # Remember macro information for use within the element.
1.21 @@ -379,7 +383,7 @@
1.22 # Some macros affect the formatting of their contents, whereas other
1.23 # simpler macros are handled here.
1.24
1.25 - elif name == "ac:macro" and not self.forbids_macros():
1.26 + elif name == "ac:macro":
1.27 conversion = macrotypes.get(self.macro)
1.28 if conversion:
1.29 parameters = {"content" : text}
1.30 @@ -389,6 +393,9 @@
1.31 confargname, moinargname = argnames
1.32 parameters["args"] = quote_macro_argument("%s=%s" % (moinargname, self.macro_parameters[confargname]))
1.33 text = conversion % parameters
1.34 + if self.macro == "anchor" and self.forbids_macros():
1.35 + self.held_anchors.append(text)
1.36 + text = ""
1.37
1.38 # Handle the common cases for parameterised and unparameterised
1.39 # substitutions.
1.40 @@ -413,6 +420,11 @@
1.41 text = "\n==\n%s" % text
1.42 self.table_rows += 1
1.43
1.44 + # Postprocess held anchor tags in headings.
1.45 +
1.46 + elif name in headings and self.held_anchors:
1.47 + text = "%s\n%s" % ("".join(self.held_anchors), text)
1.48 +
1.49
1.50
1.51 # Normalise leading whitespace and indent the text if appropriate.