1.1 --- a/convert.py Sat Jan 10 15:11:34 2015 +0100
1.2 +++ b/convert.py Mon Feb 02 15:18:19 2015 +0100
1.3 @@ -164,17 +164,19 @@
1.4 if not body:
1.5 body = "## Empty page."
1.6
1.7 + is_comment_page = content.get("content:class") == "Comment"
1.8 +
1.9 # NOTE: Very simple technique employed for guessing the format.
1.10
1.11 if no_translate:
1.12 - fn = write
1.13 + fn = notranslate
1.14 elif body.startswith("<"):
1.15 fn = xmltranslate
1.16 else:
1.17 fn = translate
1.18
1.19 try:
1.20 - fn(join(versions_dir, content["content"]), body)
1.21 + fn(join(versions_dir, content["content"]), body, is_comment_page)
1.22 except:
1.23 err = codecs.getwriter("utf-8")(sys.stderr)
1.24 print >>err, "Error parsing", content["content"]
1.25 @@ -210,7 +212,12 @@
1.26
1.27 "Record properties in the current content dictionary."
1.28
1.29 - self.content[attributes[-1]["name"]] = text.strip()
1.30 + property_name = attributes[-1]["name"]
1.31 + self.content[property_name] = text.strip()
1.32 +
1.33 + property_class = attributes[-1].get("class")
1.34 + if property_class:
1.35 + self.content["%s:%s" % (property_name, "class")] = property_class.strip()
1.36
1.37 def handle_id(self, name, elements, attributes, all_text, text):
1.38
1.39 @@ -272,7 +279,7 @@
1.40 finally:
1.41 f.close()
1.42
1.43 -def translate(filename, body, fn=None):
1.44 +def translate(filename, body, is_comment_page, fn=None):
1.45
1.46 """
1.47 Write to the file with the given 'filename' a translation of the given
1.48 @@ -284,12 +291,15 @@
1.49 out = codecs.open(filename, "w", encoding="utf-8")
1.50 try:
1.51 print >>out, "#pragma page-filename", filename
1.52 - fn(body, out)
1.53 + fn(body, out, is_comment_page)
1.54 finally:
1.55 out.close()
1.56
1.57 -def xmltranslate(filename, body):
1.58 - translate(filename, body, xmlparser.parse)
1.59 +def xmltranslate(filename, body, is_comment_page):
1.60 + translate(filename, body, is_comment_page, xmlparser.parse)
1.61 +
1.62 +def notranslate(filename, body, is_comment_page):
1.63 + write(filename, body)
1.64
1.65 def sort_comments(pages_dir, pageid):
1.66