changeset 2724:3ce812c19af7

wiki parser: using images (transcluded objs) as link description
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 12 Aug 2007 20:18:28 +0200
parents a3056075eaaa
children 388204baf00f
files MoinMoin/parser/text_moin_wiki.py
diffstat 1 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/parser/text_moin_wiki.py	Sun Aug 12 19:25:55 2007 +0200
+++ b/MoinMoin/parser/text_moin_wiki.py	Sun Aug 12 20:18:28 2007 +0200
@@ -653,6 +653,14 @@
             if ma.group('simple_text'):
                 desc = ma.group('simple_text')
                 desc = wikiutil.escape(desc)
+                desc = self.formatter.text(desc)
+            elif ma.group('transclude'):
+                groupdict = ma.groupdict()
+                if groupdict.get('transclude_args') is None:
+                    # if transcluded obj (image) has no description, use target for it
+                    groupdict['transclude_args'] = target
+                desc = ma.group('transclude')
+                desc = self._transclude_repl(desc, groupdict)
         if m:
             if m.group('page_name'):
                 page_name = m.group('page_name')
@@ -667,18 +675,18 @@
                 if not page_name:
                     page_name = self.formatter.page.page_name
                 if not desc:
-                    desc = page_name
+                    desc = self.formatter.text(page_name)
                 return (self.formatter.pagelink(1, page_name, anchor=anchor) +
-                        self.formatter.text(desc) +
+                        desc +
                         self.formatter.pagelink(0, page_name))
 
             elif m.group('extern_addr'):
                 scheme = m.group('extern_scheme')
                 target = m.group('extern_addr')
                 if not desc:
-                    desc = target
+                    desc = self.formatter.text(target)
                 return (self.formatter.url(1, target, css=scheme) +
-                        self.formatter.text(desc) +
+                        desc +
                         self.formatter.url(0))
 
             elif m.group('inter_wiki'):
@@ -687,17 +695,16 @@
                 word = '%s:%s' % (wiki_name, page_name)
                 wikitag_bad = wikiutil.resolve_wiki(self.request, word)[3]
                 if not desc:
-                    desc = page_name
+                    desc = self.formatter.text(page_name)
                 return (self.formatter.interwikilink(1, wiki_name, page_name) +
-                        self.formatter.text(desc) +
+                        desc +
                         self.formatter.interwikilink(0, wiki_name, page_name))
 
             elif m.group('attach_scheme'):
                 scheme = m.group('attach_scheme')
                 url = wikiutil.url_unquote(m.group('attach_addr'), want_unicode=True)
                 if not desc:
-                    desc = url
-                    desc = wikiutil.escape(desc)
+                    desc = self.formatter.text(url)
                 if scheme == 'attachment':
                     return self.formatter.attachment_link(url, desc, title=desc)
                 elif scheme == 'drawing':