changeset 1356:0120ccfbaaa1

wiki parser: whitespace and comments changes only
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 20 Aug 2006 21:06:49 +0200
parents a796d366f176
children 43a3a1ec471c
files MoinMoin/parser/text_moin_wiki.py
diffstat 1 files changed, 40 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/parser/text_moin_wiki.py	Sun Aug 20 20:58:49 2006 +0200
+++ b/MoinMoin/parser/text_moin_wiki.py	Sun Aug 20 21:06:49 2006 +0200
@@ -2,7 +2,8 @@
 """
     MoinMoin - MoinMoin Wiki Markup Parser
 
-    @copyright: 2000, 2001, 2002 by Jürgen Hermann <jh@web.de>
+    @copyright: 2000, 2001, 2002 by Jürgen Hermann <jh@web.de>,
+                2006 by MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
@@ -143,7 +144,7 @@
         # holds the nesting level (in chars) of open lists
         self.list_indents = []
         self.list_types = []
-        
+
         self.formatting_rules = self.formatting_rules % {'macronames': u'|'.join(macro.getNames(self.cfg))}
 
     def _close_item(self, result):
@@ -182,7 +183,7 @@
             #self.request.log("interwiki: join_wiki -> %s.%s.%s" % (wikiurl,pagename,href))
             return self.formatter.image(src=href)
 
-        return (self.formatter.interwikilink(1, wikiname, pagename) + 
+        return (self.formatter.interwikilink(1, wikiname, pagename) +
                 self.formatter.text(text) +
                 self.formatter.interwikilink(0, wikiname, pagename))
 
@@ -200,7 +201,7 @@
         # check for image, and possibly return IMG tag (images are always inlined)
         if not kw.get('pretty_url', 0) and wikiutil.isPicture(fname):
             return self.formatter.attachment_image(fname)
-                
+
         # inline the attachment
         if scheme == 'inline':
             return self.formatter.attachment_inlined(fname, text)
@@ -325,7 +326,7 @@
         # handle anchors
         parts = word.split("#", 1)
         anchor = ""
-        if len(parts)==2:
+        if len(parts) == 2:
             word, anchor = parts
 
         return (self.formatter.pagelink(1, word, anchor=anchor) +
@@ -388,7 +389,7 @@
     def _url_bracket_repl(self, word):
         """Handle bracketed URLs."""
         word = word[1:-1] # strip brackets
-        
+
         # Local extended link? [:page name:link text] XXX DEPRECATED
         if word[0] == ':':
             words = word[1:].split(':', 1)
@@ -414,7 +415,7 @@
                 return self.interwiki(word, pretty_url=1)
             if scheme in self.attachment_schemas:
                 return self.attachment(word, pretty_url=1)
-            
+
             words = word.split(None, 1)
             if len(words) == 1:
                 words = words * 2
@@ -450,7 +451,7 @@
     def _ent_symbolic_repl(self, word):
         """Handle symbolic SGML entities."""
         return self.formatter.rawHTML(word)
-    
+
     def _indent_repl(self, match):
         """Handle pure indentation (no - * 1. markup)."""
         result = []
@@ -516,7 +517,7 @@
         if self._indent_level() != new_level and self.in_table:
             close.append(self.formatter.table(0))
             self.in_table = 0
-        
+
         while self._indent_level() > new_level:
             self._close_item(close)
             if self.list_types[-1] == 'ol':
@@ -529,13 +530,13 @@
 
             del self.list_indents[-1]
             del self.list_types[-1]
-            
+
             if self.list_types: # we are still in a list
                 if self.list_types[-1] == 'dl':
                     self.in_dd = 1
                 else:
                     self.in_li = 1
-                
+
         # Open new list, if necessary
         if self._indent_level() < new_level:
             self.list_indents.append(new_level)
@@ -543,7 +544,7 @@
 
             if self.formatter.in_p:
                 close.append(self.formatter.paragraph(0))
-            
+
             if list_type == 'ol':
                 tag = self.formatter.number_list(1, numtype, numstart)
             elif list_type == 'dl':
@@ -551,16 +552,16 @@
             else:
                 tag = self.formatter.bullet_list(1)
             open.append(tag)
-            
+
             self.first_list_item = 1
             self.in_li = 0
             self.in_dd = 0
-            
+
         # If list level changes, close an open table
         if self.in_table and (open or close):
             close[0:0] = [self.formatter.table(0)]
             self.in_table = 0
-        
+
         self.in_list = self.list_types != []
         return ''.join(close) + ''.join(open)
 
@@ -725,9 +726,9 @@
                     attrs['colspan'] = '"%d"' % (word.count("|")/2)
 
             # return the complete cell markup
-            result.append(self.formatter.table_cell(1, attrs) + attrerr)         
+            result.append(self.formatter.table_cell(1, attrs) + attrerr)
             result.append(self._line_anchordef())
-            return ''.join(result) 
+            return ''.join(result)
         else:
             return self.formatter.text(word)
 
@@ -740,7 +741,7 @@
         level = 1
         while h[level:level+1] == '=':
             level += 1
-        depth = min(5,level)
+        depth = min(5, level)
 
         # this is needed for Included pages
         # TODO but it might still result in unpredictable results
@@ -755,10 +756,10 @@
             unique_id = '-%d' % self.titles[pntt]
         result = self._closeP()
         result += self.formatter.heading(1, depth, id="head-"+sha.new(pntt.encode(config.charset)).hexdigest()+unique_id)
-                                     
+
         return (result + self.formatter.text(title_text) +
                 self.formatter.heading(0, depth))
-    
+
     def _parser_repl(self, word):
         """Handle parsed code displays."""
         if word.startswith('{{{'):
@@ -823,7 +824,7 @@
         if self.formatter.in_p:
             return self.formatter.paragraph(0)
         return ''
-        
+
     def _macro_repl(self, word):
         """Handle macros ([[macroname]])."""
         macro_name = word[2:-2]
@@ -849,26 +850,26 @@
         lastpos = 0
 
         ###result.append(u'<span class="info">[scan: <tt>"%s"</tt>]</span>' % line)
-      
+
         for match in scan_re.finditer(line):
             # Add text before the match
             if lastpos < match.start():
-                
+
                 ###result.append(u'<span class="info">[add text before match: <tt>"%s"</tt>]</span>' % line[lastpos:match.start()])
-                
+
                 if not (self.inhibit_p or self.in_pre or self.formatter.in_p):
                     result.append(self.formatter.paragraph(1, css_class="line862"))
                 result.append(self.formatter.text(line[lastpos:match.start()]))
-            
+
             # Replace match with markup
             if not (self.inhibit_p or self.in_pre or self.formatter.in_p or
                     self.in_table or self.in_list):
                 result.append(self.formatter.paragraph(1, css_class="line867"))
             result.append(self.replace(match))
             lastpos = match.end()
-        
+
         ###result.append('<span class="info">[no match, add rest: <tt>"%s"<tt>]</span>' % line[lastpos:])
-        
+
         # Add paragraph with the remainder of the line
         if not (self.in_pre or self.in_li or self.in_dd or self.inhibit_p or
                 self.formatter.in_p) and lastpos < len(line):
@@ -881,17 +882,17 @@
         result = []
         for type, hit in match.groupdict().items():
             if hit is not None and not type in ["hmarker", ]:
-                
+
                 ###result.append(u'<span class="info">[replace: %s: "%s"]</span>' % (type, hit))
                 if self.in_pre and type not in ['pre', 'ent']:
-                    return self.formatter.text(hit) 
+                    return self.formatter.text(hit)
                 else:
                     # Open p for certain types
                     if not (self.inhibit_p or self.formatter.in_p
                             or self.in_pre or (type in self.no_new_p_before)):
                         result.append(self.formatter.paragraph(1, css_class="line891"))
-                    
-                    # Get replace method and replece hit
+
+                    # Get replace method and replace hit
                     replace = getattr(self, '_' + type + '_repl')
                     result.append(replace(hit))
                     return ''.join(result)
@@ -925,13 +926,13 @@
                 'word_rule': self.word_rule,
                 'rules': rules,
             }
-        self.request.clock.start('compile_huge_and_ugly')        
+        self.request.clock.start('compile_huge_and_ugly')
         scan_re = re.compile(rules, re.UNICODE)
         number_re = re.compile(self.ol_rule, re.UNICODE)
         term_re = re.compile(self.dl_rule, re.UNICODE)
         indent_re = re.compile("^\s*", re.UNICODE)
         eol_re = re.compile(r'\r?\n', re.UNICODE)
-        self.request.clock.stop('compile_huge_and_ugly')        
+        self.request.clock.stop('compile_huge_and_ugly')
 
         # get text and replace TABs
         rawtext = self.raw.expandtabs()
@@ -996,7 +997,7 @@
                         continue
                     if line[:endpos]:
                         self.parser_lines.append(line[:endpos])
-                    
+
                     # Close p before calling parser
                     # TODO: do we really need this?
                     self.request.write(self._closeP())
@@ -1014,7 +1015,7 @@
                 # we don't have \n as whitespace any more
                 # This is the space between lines we join to one paragraph
                 line += ' '
-                
+
                 # Paragraph break on empty lines
                 if not line.strip():
                     if self.in_table:
@@ -1064,7 +1065,7 @@
                         ## CHANGE: no automatic p on li
                         ##self.request.write(self.formatter.paragraph(1))
                         self.in_li = 1
-                        
+
                     # CHANGE: removed check for self.in_li
                     # paragraph should end before table, always!
                     if self.formatter.in_p:
@@ -1078,12 +1079,12 @@
                        line[indlen:indlen + 2] == "||" and
                        line.endswith("|| ") and
                        len(line) >= 5 + indlen)):
-                    
+
                     # Close table
                     self.request.write(self.formatter.table(0))
                     self.request.write(self._line_anchordef())
                     self.in_table = 0
-                                            
+
             # Scan line, format and write
             formatted_line = self.scan(scan_re, line)
             self.request.write(formatted_line)
@@ -1098,7 +1099,7 @@
         if self.in_table: self.request.write(self.formatter.table(0))
 
     # Private helpers ------------------------------------------------------------
-    
+
     def setParser(self, name):
         """ Set parser to parser named 'name' """
         mt = wikiutil.MimeType(name)