1.1 --- a/wikiparser.py Mon Jun 10 01:18:49 2013 +0200
1.2 +++ b/wikiparser.py Mon Jun 10 01:46:51 2013 +0200
1.3 @@ -559,7 +559,7 @@
1.4 # Translate headings and blockquotes.
1.5
1.6 if blocktypes.has_key(blocktype):
1.7 - text = self.translate_content(self.parse_text(blocktext))
1.8 + text = self.parse_text(blocktext)
1.9 for anchor in self.held_anchors:
1.10 parts.append(anchor)
1.11 parts.append(blocktypes[blocktype] % text)
1.12 @@ -568,7 +568,7 @@
1.13
1.14 elif blocktype == "list":
1.15 for listmarker, listitem in get_list_items(blocktext):
1.16 - parts.append("%s %s" % (self.translate_marker(listmarker), self.translate_content(self.parse_text(listitem))))
1.17 + parts.append("%s %s" % (self.translate_marker(listmarker), self.parse_text(listitem)))
1.18
1.19 # Translate table items.
1.20
1.21 @@ -604,7 +604,7 @@
1.22 # Handle anonymous blocks.
1.23
1.24 else:
1.25 - parts.append(self.translate_content(self.parse_text(blocktext)))
1.26 + parts.append(self.parse_text(blocktext))
1.27
1.28 if blocktype in headings:
1.29 self.in_heading = False
1.30 @@ -664,7 +664,7 @@
1.31
1.32 # General parsing.
1.33
1.34 - def parse_text(self, s):
1.35 + def parse_text(self, s, top=False):
1.36
1.37 "Parse the content in the string 's', returning the translation."
1.38
1.39 @@ -684,8 +684,8 @@
1.40 # immediately. This is the base case of the recursive parsing
1.41 # process.
1.42
1.43 - if text == s:
1.44 - return text
1.45 + if text == s and not top:
1.46 + return self.translate_content(text)
1.47
1.48 # Otherwise, obtain and translate the blocks.
1.49
1.50 @@ -757,7 +757,7 @@
1.51 "Parse the content in the string 's', writing a translation to 'out'."
1.52
1.53 parser = ConfluenceParser()
1.54 - out.write(parser.parse_text(s))
1.55 + out.write(parser.parse_text(s, top=True))
1.56
1.57 if __name__ == "__main__":
1.58 s = codecs.getreader("utf-8")(sys.stdin).read()