[Moin-devel] CVS: MoinMoin/parser wiki.py,1.69,1.70

J?rgen Hermann jhermann at users.sourceforge.net
Thu Jan 24 14:31:20 EST 2002


Update of /cvsroot/moin/MoinMoin/parser
In directory usw-pr-cvs1:/tmp/cvs-serv18114

Modified Files:
	wiki.py 
Log Message:
Refactored some common regex strings to their own variables


Index: wiki.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/parser/wiki.py,v
retrieving revision 1.69
retrieving revision 1.70
diff -C2 -r1.69 -r1.70
*** wiki.py	2002/01/24 22:14:55	1.69
--- wiki.py	2002/01/24 22:30:44	1.70
***************
*** 29,35 ****
      """
  
!     ol_rule = r"^\s+[0-9aAiI]\.(?:#\d+)?\s"
!     dl_rule = r"^\s+.*?::\s"
  
      word_rule = r'(?:%(subpages)s[%(u)s][%(l)s]+){2,}' % {
          'u': config.upperletters,
--- 29,39 ----
      """
  
!     # some common strings
!     punct_pattern = re.escape('''"'}]|:,.)?!''')
!     url_pattern = ('http|https|ftp|nntp|news|mailto|telnet|wiki|file' +
!             '|attachment' + 
!             (config.url_schemas and '|' + string.join(config.url_schemas, '|') or ''))
  
+     # some common rules
      word_rule = r'(?:%(subpages)s[%(u)s][%(l)s]+){2,}' % {
          'u': config.upperletters,
***************
*** 37,41 ****
--- 41,54 ----
          'subpages': config.allow_subpages and '/?' or '',
      }
+     url_rule = r'%(url_guard)s(%(url)s)\:([^\s\<%(punct)s]|([%(punct)s][^\s\<%(punct)s]))+' % {
+         'url_guard': ('(^|(?<!\w))', '')[sys.version < "2"],
+         'url': url_pattern,
+         'punct': punct_pattern,
+     }
  
+     ol_rule = r"^\s+[0-9aAiI]\.(?:#\d+)?\s"
+     dl_rule = r"^\s+.*?::\s"
+ 
+     # the big, fat, ugly one ;)
      formatting_rules = r"""(?:(?P<emph_ibb>'''''(?=[^']+'''))
  (?P<emph_ibi>'''''(?=[^']+''))
***************
*** 57,73 ****
  (?P<word>%(word_rule)s)
  (?P<url_bracket>\[(%(url)s)\:[^\s\]]+(\s[^\]]+)?\])
! (?P<url>%(url_guard)s(%(url)s)\:([^\s\<%(punct)s]|([%(punct)s][^\s\<%(punct)s]))+)
  (?P<email>[-\w._+]+\@[\w-]+\.[\w.-]+)
  (?P<smiley>\s(%(smiley)s)\s)
  (?P<smileyA>^(%(smiley)s)\s)
  (?P<ent>[<>&])"""  % {
!         'url': 'http|https|ftp|nntp|news|mailto|telnet|wiki|file' +
!             '|attachment' + 
!             (config.url_schemas and '|' + string.join(config.url_schemas, '|') or ''),
!         'url_guard': ('(^|(?<!\w))', '')[sys.version < "2"],
!         'punct': re.escape('''"'}]|:,.)?!'''),
          'macronames': string.join(wikimacro.names, '|'),
          'ol_rule': ol_rule,
          'dl_rule': dl_rule,
          'word_rule': word_rule,
          'smiley': string.join(map(re.escape, wikiutil.smileys.keys()), '|')}
--- 70,84 ----
  (?P<word>%(word_rule)s)
  (?P<url_bracket>\[(%(url)s)\:[^\s\]]+(\s[^\]]+)?\])
! (?P<url>%(url_rule)s)
  (?P<email>[-\w._+]+\@[\w-]+\.[\w.-]+)
  (?P<smiley>\s(%(smiley)s)\s)
  (?P<smileyA>^(%(smiley)s)\s)
  (?P<ent>[<>&])"""  % {
!         'url': url_pattern,
!         'punct': punct_pattern,
          'macronames': string.join(wikimacro.names, '|'),
          'ol_rule': ol_rule,
          'dl_rule': dl_rule,
+         'url_rule': url_rule,
          'word_rule': word_rule,
          'smiley': string.join(map(re.escape, wikiutil.smileys.keys()), '|')}





More information about the Moin-devel mailing list