[Zope-Checkins] CVS: Zope/lib/python/StructuredText - ClassicDocumentClass.py:1.14.4.1 DocumentClass.py:1.28.2.1 HTMLClass.py:1.11.8.1 STletters.py:1.3.4.1 StructuredText.py:1.40.8.1

Shane Hathaway shane@digicool.com
Thu, 9 Aug 2001 13:34:13 -0400


Update of /cvs-repository/Zope/lib/python/StructuredText
In directory cvs.zope.org:/tmp/cvs-serv29115/lib/python/StructuredText

Modified Files:
      Tag: NR-branch
	ClassicDocumentClass.py DocumentClass.py HTMLClass.py 
	STletters.py StructuredText.py 
Log Message:
Sync NR-branch with trunk.  Sorry about so many checkin messages...


=== Zope/lib/python/StructuredText/ClassicDocumentClass.py 1.14 => 1.14.4.1 ===
     def doc_named_link(self,
                        s,
-                       expr=re.compile("(\.\.\s)(\[[%s0-9]+\])" % letters).search):
+                       expr=re.compile(r"(\.\.\s)(\[[%s0-9]+\])" % letters).search):
         
         result = expr(s)
         if result:
             start,end   = result.span(2)
-            a,b         = result.span(1)
-            str         = strip(s[a:b]) + s[start:end]
-            str         = s[start+1:end-1]
+            str = s[start+1:end-1]
             st,en       = result.span()
             return (StructuredTextNamedLink(str),st,en)
-            #return (StructuredTextNamedLink(s[st:en]),st,en)
         return None
     
     def doc_underline(self,
                       s,
-                      expr=re.compile("\_([%s0-9\s\.,\?\/]+)\_" % letters).search):
+                      expr=re.compile("_([%s0-9\s\.,\?\/]+)_" % letters).search):
+
         
         result = expr(s)
         if result:


=== Zope/lib/python/StructuredText/DocumentClass.py 1.28 => 1.28.2.1 ===
 from string import split, join, replace, expandtabs, strip, find, rstrip
 from STletters import letters, digits, literal_punc, under_punc,\
-     strongem_punc, phrase_delimiters
+     strongem_punc, phrase_delimiters,dbl_quoted_punc
 
 StringType=type('')
 ListType=type([])
@@ -371,6 +371,7 @@
         'doc_href',
         'doc_strong',
         'doc_emphasize',
+        'doc_underline',
         'doc_literal',
         'doc_sgml',
         'doc_xref',
@@ -915,17 +916,16 @@
         result = expr(s)
         if result:
             start,end   = result.span(2)
-            a,b = result.span(1)
-            str = strip(s[a:b]) + s[start:end]
+            str = s[start+1:end-1]
             st,en       = result.span()
             return (StructuredTextNamedLink(str),st,en)
-            #return (StructuredTextNamedLink(s[st:en]),st,en)
         return None
     
     def doc_underline(self,
                       s,
                       #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] == '_':
@@ -950,9 +950,10 @@
            return None
 
     ## Some constants to make the doc_href() regex easier to read.
-    _DQUOTEDTEXT = r'("[ %s0-9\n\r\-\.\,\;\(\)\/\:\/\*\']+")' % letters ## double quoted text
-    _ABSOLUTE_URL=r'((http|https|ftp|mailto|file|about)[:/]+?[%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\?]+)' % letters
-    _ABS_AND_RELATIVE_URL=r'([%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\?]+)' % letters
+    _DQUOTEDTEXT = r'("[ %s0-9\n\r%s]+")' % (letters,dbl_quoted_punc) ## double quoted text
+    _ABSOLUTE_URL=r'((http|https|ftp|mailto|file|about)[:/]+?[%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%]+)' % letters
+    _ABS_AND_RELATIVE_URL=r'([%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%]+)' % letters
+
     _SPACES = r'(\s*)'
     
     def doc_href(self, s,


=== Zope/lib/python/StructuredText/HTMLClass.py 1.11 => 1.11.8.1 ===
         }
 
+
     def dispatch(self, doc, level, output):
         getattr(self, self.element_types[doc.getNodeName()])(doc, level, output)
         
-    def __call__(self, doc, level=1):
+    def __call__(self, doc, level=1, header=1):
         r=[]
+        self.header = header
         self.dispatch(doc, level-1, r.append)
         return join(r,'')
 
@@ -125,17 +127,22 @@
         output(doc.getNodeValue())
 
     def document(self, doc, level, output):
-        output('<html>\n')
         children=doc.getChildNodes()
-        if (children and
-             children[0].getNodeName() == 'StructuredTextSection'):
-            output('<head>\n<title>%s</title>\n</head>\n' %
-                     children[0].getChildNodes()[0].getNodeValue())
-        output('<body>\n')
+
+        if self.header==1:
+            output('<html>\n')
+            if (children and
+                 children[0].getNodeName() == 'StructuredTextSection'):
+                output('<head>\n<title>%s</title>\n</head>\n' %
+                         children[0].getChildNodes()[0].getNodeValue())
+            output('<body>\n')
+
         for c in children:
             getattr(self, self.element_types[c.getNodeName()])(c, level, output)
-        output('</body>\n')
-        output('</html>\n')
+
+        if self.header==1:
+            output('</body>\n')
+            output('</html>\n')
 
     def section(self, doc, level, output):
         children=doc.getChildNodes()


=== Zope/lib/python/StructuredText/STletters.py 1.3 => 1.3.4.1 ===
 letters     = string.letters
 literal_punc = punc_func("'")
+dbl_quoted_punc = punc_func("\"")
 strongem_punc = punc_func('*')
 under_punc = punc_func('_')
 phrase_delimiters = r'\s\.\,\?\/\!\&\(\)'
+


=== Zope/lib/python/StructuredText/StructuredText.py 1.40 => 1.40.8.1 ===
 HTMLNG = HTMLClass.HTMLClass()
 
-def HTML(aStructuredString, level=0):
+def HTML(aStructuredString, level=0, header=1):
     st = Basic(aStructuredString)
     doc = Document(st)
-    return HTMLNG(doc)
+    return HTMLNG(doc,header=header)
 
 def StructuredText(aStructuredString, level=0):
     return HTML(aStructuredString,level)
 
-def html_with_references(text, level=1):
+def html_with_references(text, level=1, header=1):
     text = re.sub(
         r'[\000\n]\.\. \[([0-9_%s-]+)\]' % letters,
         r'\n  <a name="\1">[\1]</a>',
@@ -120,7 +120,7 @@
         r'\1<a href="\2.html">[\2]</a>\3',
         text)
 
-    return HTML(text,level=level)
+    return HTML(text,level=level,header=header)
 
 def html_quote(v,
                character_entities=(
@@ -146,3 +146,4 @@
 
     for f in args:
         print HTML(open(f).read())
+