[Zope-Checkins] CVS: Zope2 - DocumentClass.py:1.22.2.1
chrism@serenade.digicool.com
chrism@serenade.digicool.com
Mon, 25 Jun 2001 16:28:29 -0400
Update of /cvs-repository/Zope2/lib/python/StructuredText
In directory serenade:/home/chrism/sandboxes/Zope24Branch/lib/python/StructuredText
Modified Files:
Tag: Zope-2_4-branch
DocumentClass.py
Log Message:
Merging changes from trunk.
--- Updated File DocumentClass.py in package Zope2 --
--- DocumentClass.py 2001/06/19 03:32:12 1.22
+++ DocumentClass.py 2001/06/25 20:28:28 1.22.2.1
@@ -85,9 +85,9 @@
import re, ST, STDOM
from string import split, join, replace, expandtabs, strip, find, rstrip
-from STletters import *
+from STletters import letters, digits, literal_punc, under_punc,\
+ strongem_punc, phrase_delimiters
-
StringType=type('')
ListType=type([])
@@ -365,7 +365,7 @@
#'doc_inner_link',
#'doc_named_link',
- #'doc_underline',
+ #'doc_underline'
text_types = [
'doc_sgml',
'doc_href',
@@ -791,7 +791,7 @@
def doc_numbered(
self, paragraph,
- expr = re.compile(r'(\s*[%s]+\.)|(\s*[0-9]+\.)|(\s*[0-9]+\s+)' % letters).match):
+ expr = re.compile(r'(\s*[%s]\.)|(\s*[0-9]+\.)|(\s*[0-9]+\s+)' % letters).match):
# This is the old expression. It had a nasty habit
# of grabbing paragraphs that began with a single
@@ -839,9 +839,7 @@
indent=paragraph.indent,
delim=d)
- def doc_header(self, paragraph,
- expr = re.compile(r'[ %s0-9.:/,-_*<>\?\'\"]+' % letters).match
- ):
+ def doc_header(self, paragraph):
subs=paragraph.getSubparagraphs()
if not subs: return None
top=paragraph.getColorizableTexts()[0]
@@ -860,11 +858,14 @@
def doc_literal(
self, s,
- expr=re.compile(
- r"(?:\s|^)'" # open
- r"([^ \t\n\r\f\v']|[^ \t\n\r\f\v'][^\n']*[^ \t\n\r\f\v'])" # contents
- r"'(?:\s|[,.;:!?]|$)" # close
- ).search):
+ expr = re.compile(r"'([%s%s%s\s]+)'[%s]+" % (letters, digits, literal_punc, phrase_delimiters)).search):
+
+ # old expr... failed to cross newlines.
+ # expr=re.compile(
+ # r"(?:\s|^)'" # open
+ # r"([^ \t\n\r\f\v']|[^ \t\n\r\f\v'][^\n\r']*[^ \t\n\r\f\v'])" # contents
+ # r"'(?:\s|[,.;:!?]|$)" # close
+ # ).search):
r=expr(s)
if r:
@@ -875,7 +876,8 @@
def doc_emphasize(
self, s,
- expr = re.compile(r'\s*\*([ \n%s0-9]+)\*(?!\*|-)' % lettpunc).search
+ expr = re.compile(r'\*([%s%s%s\s]+?)\*' % (letters, digits, strongem_punc)).search
+ #expr = re.compile(r'\s*\*([ \n\r%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search # old expr, inconsistent punctuation
):
r=expr(s)
@@ -888,7 +890,7 @@
def doc_inner_link(self,
s,
expr1 = re.compile(r"\.\.\s*").search,
- expr2 = re.compile(r"\[[%s0-9]+\]" % letters ).search):
+ expr2 = re.compile(r"\[[%s%s]+\]" % (letters, digits) ).search):
# make sure we dont grab a named link
if expr2(s) and expr1(s):
@@ -922,19 +924,22 @@
def doc_underline(self,
s,
- expr=re.compile(r"\s+\_([%s0-9\s]+)\_" % lettpunc).search):
-
+ #expr=re.compile(r"\_([a-zA-Z0-9\s\.,\?]+)\_").search, # old expr, inconsistent punc, failed to cross newlines
+ expr=re.compile(r'_([%s%s%s\s]+)_' % (letters, digits, under_punc)).search):
result = expr(s)
if result:
+ if result.group(1)[:1] == '_':
+ return None # no double unders
start,end = result.span(1)
st,e = result.span()
return (StructuredTextUnderline(s[start:end]),st,e)
else:
return None
- def doc_strong(self,
+ def doc_strong(self,
s,
- expr = re.compile(r'\s*\*\*([ \n%s0-9]+)\*\*' % lettpunc).search
+ expr = re.compile(r'\*\*([%s%s%s\s]+?)\*\*' % (letters, digits, strongem_punc)).search
+ #expr = re.compile(r'\s*\*\*([ \n\r%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*\*(?!\*|-)' % letters).search, # old expr, inconsistent punc, failed to cross newlines.
):
r=expr(s)
@@ -945,8 +950,8 @@
return None
## Some constants to make the doc_href() regex easier to read.
- _DQUOTEDTEXT = r'("[%s0-9\n%s]+")' % (letters,punctuations) ## double quoted text
- _URL_AND_PUNC = r'([%s0-9_\@%s]+)' % (letters,punctuations)
+ _DQUOTEDTEXT = r'("[ %s0-9\n\r\-\.\,\;\(\)\/\:\/\*\']+")' % letters ## double quoted text
+ _URL_AND_PUNC = r'((http|https|ftp|mailto|file|about)[:/]+?[%s0-9_\@\.\,\?\!\/\:\;\-\#\~]+)' % letters
_SPACES = r'(\s*)'
def doc_href(self, s,
@@ -992,7 +997,7 @@
def doc_xref(self, s,
- expr = re.compile('\[([%s0-9\-.:/;,\n\~]+)\]' % letters).search
+ expr = re.compile('\[([%s0-9\-.:/;,\n\r\~]+)\]' % letters).search
):
r = expr(s)
if r: