Fix docbook formatter crashing, see MoinMoinPatch/IncludeMacroWithDocBookFormatter
If a page has a Include macro call with editlink argument, the formatter
crashes. This patch removes the editlink arg before processing it.
1.1 --- a/MoinMoin/formatter/text_docbook.py Mon Mar 08 14:20:37 2010 +0100
1.2 +++ b/MoinMoin/formatter/text_docbook.py Sat Mar 13 22:45:07 2010 +0100
1.3 @@ -9,7 +9,7 @@
1.4 @license: GNU GPL, see COPYING for details.
1.5 """
1.6
1.7 -import os
1.8 +import os,re
1.9
1.10 from xml.dom import getDOMImplementation
1.11 from xml.dom.ext.reader import Sax
1.12 @@ -612,7 +612,12 @@
1.13 was_in_para = self.cur.nodeName == "para"
1.14 if was_in_para:
1.15 self.paragraph(0)
1.16 - text = FormatterBase.macro(self, macro_obj, name, args)
1.17 +
1.18 + # Regular Expression to match editlink arg, remove it because it causes trouble.
1.19 + _arg_editlink = r'(,\s*(?P<editlink>editlink))?'
1.20 + macro_args = re.sub(_arg_editlink, '', args)
1.21 +
1.22 + text = FormatterBase.macro(self, macro_obj, name, macro_args)
1.23 if text.strip():
1.24 self._copyExternalNodes(Sax.FromXml(text).documentElement.childNodes, exclude=excludes)
1.25 if was_in_para: