1.1 --- a/wikiparser.py Sun Apr 14 00:42:30 2013 +0200
1.2 +++ b/wikiparser.py Sun Apr 14 21:47:21 2013 +0200
1.3 @@ -510,9 +510,16 @@
1.4 mointype = sectiontypes[sectiontype]
1.5
1.6 parts.append("{{{%s" % (mointype or ""))
1.7 + text = text.strip()
1.8 +
1.9 + # Sections containing newlines must have a separate header line.
1.10 +
1.11 + if options or text.find("\n") != -1:
1.12 + parts.append("\n")
1.13 +
1.14 if options:
1.15 parts.append("## %s\n" % options)
1.16 - parts.append(translate_content(text.strip(), sectiontype))
1.17 + parts.append(translate_content(text, sectiontype))
1.18 parts.append("%s}}}\n" % (mointype and "\n" or ""))
1.19
1.20 preceded_by_block = True
1.21 @@ -527,6 +534,12 @@
1.22
1.23 else:
1.24 parts.append("{{{")
1.25 +
1.26 + # Sections containing newlines must have a separate header line.
1.27 +
1.28 + if text.find("\n") != -1 and not text.startswith("\n"):
1.29 + parts.append("\n")
1.30 +
1.31 parts.append(translate_content(text, sectiontype))
1.32 parts.append("}}}")
1.33 preceded_by_block = False
1.34 @@ -540,7 +553,7 @@
1.35 out.write(parse_text(s))
1.36
1.37 if __name__ == "__main__":
1.38 - s = sys.stdin.read()
1.39 + s = codecs.getreader("utf-8")(sys.stdin).read()
1.40 out = codecs.getwriter("utf-8")(sys.stdout)
1.41 parse(s, out)
1.42