1.1 --- a/common.py Mon Jun 10 01:54:44 2013 +0200
1.2 +++ b/common.py Mon Jun 10 13:20:27 2013 +0200
1.3 @@ -21,6 +21,8 @@
1.4 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
1.5 """
1.6
1.7 +MAX_TITLE_LENGTH = 120
1.8 +
1.9 URL_SCHEMES = ("http", "https", "ftp", "mailto")
1.10
1.11 # Translation helpers.
1.12 @@ -37,6 +39,9 @@
1.13
1.14 headings = blocktypes.keys(); headings.remove("bq")
1.15
1.16 +def get_page_title(title):
1.17 + return title[:MAX_TITLE_LENGTH].strip()
1.18 +
1.19 def quote_macro_argument(arg):
1.20 if arg.find('"') != -1:
1.21 return '"%s"' % arg.replace('"', '""')
2.1 --- a/convert.py Mon Jun 10 01:54:44 2013 +0200
2.2 +++ b/convert.py Mon Jun 10 13:20:27 2013 +0200
2.3 @@ -31,7 +31,7 @@
2.4 import wikiparser, xmlparser
2.5 import sys
2.6
2.7 -MAX_TITLE_LENGTH = 120
2.8 +from common import get_page_title
2.9
2.10 class ConfluenceHandler:
2.11
2.12 @@ -109,7 +109,7 @@
2.13 # Limit the title to a "safe" number of characters in order to avoid
2.14 # filesystem issues.
2.15
2.16 - title = title[:MAX_TITLE_LENGTH].strip()
2.17 + title = get_page_title(title)
2.18
2.19 if title:
2.20 title = "%s/%s" % (self.space, title)
3.1 --- a/xmlparser.py Mon Jun 10 01:54:44 2013 +0200
3.2 +++ b/xmlparser.py Mon Jun 10 13:20:27 2013 +0200
3.3 @@ -56,8 +56,8 @@
3.4 "p" : "%s",
3.5 "ol" : "%s",
3.6 "ul" : "%s",
3.7 - "ac:link" : "[[%s%s|%s]]",
3.8 - "ac:image" : "{{%s%s|%s}}",
3.9 + "ac:link" : "[[%s%s%s|%s]]",
3.10 + "ac:image" : "{{%s%s%s|%s}}",
3.11 "a" : "[[%s|%s]]",
3.12 }
3.13
3.14 @@ -109,7 +109,6 @@
3.15 # Confluence element MoinMoin link prefix
3.16 "ri:attachment" : "attachment:",
3.17 "ri:user" : "",
3.18 - "ac:link-body" : "#",
3.19 }
3.20
3.21 macro_rich_text_styles = {
3.22 @@ -299,8 +298,6 @@
3.23 # For anchor links, just use the raw text and let Moin do the formatting.
3.24
3.25 elif name == "ac:link-body":
3.26 - if not self.target_type:
3.27 - self.target_type = name
3.28 self.label = text.strip()
3.29 text = ""
3.30
3.31 @@ -371,8 +368,9 @@
3.32
3.33 if name in ("ac:link", "ac:image"):
3.34 prefix = link_target_types.get(self.target_type, "")
3.35 - anchor = self.attributes[-1].get("ac:anchor")
3.36 - text = conversion % (prefix, anchor or self.target, self.label or text.strip() or self.target)
3.37 + anchor = self.attributes[-1].get("ac:anchor") or ""
3.38 + label = self.label or text.strip() or self.target
3.39 + text = conversion % (prefix, self.target, anchor and ("#%s" % anchor) or "", label)
3.40 self.target = self.target_type = self.label = None
3.41
3.42 elif name == "a":