1.1 --- a/convert.py Fri Jun 16 17:06:10 2017 +0200
1.2 +++ b/convert.py Fri Jun 16 17:07:06 2017 +0200
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Confluence XML dump conversion to a MoinMoin-compatible representation.
1.6
1.7 -Copyright (C) 2012, 2013 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2012, 2013, 2017 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This software is free software; you can redistribute it and/or
1.11 modify it under the terms of the GNU General Public License as
1.12 @@ -130,7 +130,7 @@
1.13 content["version"],
1.14 versionfile,
1.15 title, # comment titles will incorporate the comment's position
1.16 - content["lastModifierName"],
1.17 + content.get("lastModifierName") or content.get("lastModifier"),
1.18 content["versionComment"],
1.19 date_to_seconds(content["lastModificationDate"])
1.20 ))
1.21 @@ -185,8 +185,8 @@
1.22 # Handle attachments.
1.23
1.24 elif objecttype == "Attachment":
1.25 - pageid = content["content"]
1.26 - version = content["attachmentVersion"]
1.27 + pageid = content.get("content") or content.get("containerContent")
1.28 + version = content.get("attachmentVersion") or content.get("version") or 0
1.29
1.30 if content.has_key("originalVersion"):
1.31 attachid = content["originalVersion"]
1.32 @@ -199,10 +199,10 @@
1.33 # Have to "taint" archive filenames, although Moin will
1.34 # probably handle package script filename tainting.
1.35 wikiutil.taintfilename(join("attachments", pageid, attachid, version)),
1.36 - wikiutil.taintfilename(content["fileName"]),
1.37 + wikiutil.taintfilename(content.get("fileName") or content.get("title")),
1.38 "", # pagename is substituted later
1.39 - content["lastModifierName"],
1.40 - content["comment"],
1.41 + content.get("lastModifierName") or content.get("lastModifier"),
1.42 + content.get("comment") or content.get("versionComment"),
1.43 date_to_seconds(content["lastModificationDate"])
1.44 ))
1.45
2.1 --- a/xmlparser.py Fri Jun 16 17:06:10 2017 +0200
2.2 +++ b/xmlparser.py Fri Jun 16 17:07:06 2017 +0200
2.3 @@ -3,7 +3,7 @@
2.4 """
2.5 Confluence Wiki XML/XHTML syntax parsing.
2.6
2.7 -Copyright (C) 2012, 2013, 2015 Paul Boddie <paul@boddie.org.uk>
2.8 +Copyright (C) 2012, 2013, 2015, 2017 Paul Boddie <paul@boddie.org.uk>
2.9
2.10 This software is free software; you can redistribute it and/or
2.11 modify it under the terms of the GNU General Public License as
2.12 @@ -206,7 +206,7 @@
2.13
2.14 # Remember macro information for use within the element.
2.15
2.16 - if name == "ac:macro":
2.17 + if name in ("ac:macro", "ac:structured-macro"):
2.18 self.macros.append(self.attributes[-1].get("ac:name"))
2.19 self.macro_parameters.append({})
2.20
2.21 @@ -233,7 +233,7 @@
2.22
2.23 # Discard macro state.
2.24
2.25 - if name == "ac:macro":
2.26 + if name in ("ac:macro", "ac:structured-macro"):
2.27 self.macros.pop()
2.28 self.macro_parameters.pop()
2.29
2.30 @@ -401,8 +401,11 @@
2.31 # Some macros affect the formatting of their contents, whereas other
2.32 # simpler macros are handled here.
2.33
2.34 - elif name == "ac:macro":
2.35 + elif name in ("ac:macro", "ac:structured-macro"):
2.36 conversion = macrotypes.get(self.macros[-1])
2.37 +
2.38 + # Produce the converted macro.
2.39 +
2.40 if conversion:
2.41 parameters = {"content" : text}
2.42 parameters.update(self.macro_parameters[-1])
2.43 @@ -410,11 +413,21 @@
2.44 if argnames:
2.45 confargname, moinargname = argnames
2.46 parameters["args"] = quote_macro_argument("%s=%s" % (moinargname, self.macro_parameters[-1][confargname]))
2.47 +
2.48 + # Obtain the Moin macro with parameters substituted.
2.49 +
2.50 text = conversion % parameters
2.51 if self.macros[-1] == "anchor" and self.forbids_macros():
2.52 self.held_anchors.append(text)
2.53 text = ""
2.54
2.55 + # Warn about macros that are not converted.
2.56 +
2.57 + elif not macro_rich_text_styles.has_key(self.macros[-1]):
2.58 + print >>sys.stderr, "No conversion possible for macro", self.macros[-1]
2.59 + print >>sys.stderr, "Macro has arguments", self.macro_parameters[-1]
2.60 + print >>sys.stderr
2.61 +
2.62 # Handle the common cases for parameterised and unparameterised
2.63 # substitutions.
2.64