[Zope-Checkins] CVS: Zope/lib/python/StructuredText - ClassicDocumentClass.py:1.25 ClassicStructuredText.py:1.7 DocBookClass.py:1.6 DocumentClass.py:1.49 DocumentWithImages.py:1.8 HTMLClass.py:1.22 HTMLWithImages.py:1.10 ST.py:1.17 STDOM.py:1.7 STletters.py:1.7 StructuredText.py:1.49 Zwiki.py:1.7 __init__.py:1.9
Martijn Pieters
mj@zope.com
Wed, 14 Aug 2002 17:58:53 -0400
Update of /cvs-repository/Zope/lib/python/StructuredText
In directory cvs.zope.org:/tmp/cvs-serv17840
Modified Files:
ClassicDocumentClass.py ClassicStructuredText.py
DocBookClass.py DocumentClass.py DocumentWithImages.py
HTMLClass.py HTMLWithImages.py ST.py STDOM.py STletters.py
StructuredText.py Zwiki.py __init__.py
Log Message:
Clean up indentation and trailing whitespace.
=== Zope/lib/python/StructuredText/ClassicDocumentClass.py 1.24 => 1.25 === (590/690 lines abridged)
--- Zope/lib/python/StructuredText/ClassicDocumentClass.py:1.24 Mon Mar 11 10:24:40 2002
+++ Zope/lib/python/StructuredText/ClassicDocumentClass.py Wed Aug 14 17:58:22 2002
@@ -21,11 +21,11 @@
"""Represents a section of document with literal text, as for examples"""
def __init__(self, subs, **kw):
- t=[]; a=t.append
- for s in subs: a(s.getNodeValue())
- apply(ST.StructuredTextParagraph.__init__,
- (self, '\n\n'.join(t), ()),
- kw)
+ t=[]; a=t.append
+ for s in subs: a(s.getNodeValue())
+ apply(ST.StructuredTextParagraph.__init__,
+ (self, '\n\n'.join(t), ()),
+ kw)
def getColorizableTexts(self): return ()
def setColorizableTexts(self, src): pass # never color examples
@@ -44,17 +44,17 @@
class StructuredTextDescription(ST.StructuredTextParagraph):
"""Represents a section of a document with a title and a body"""
-
+
def __init__(self, title, src, subs, **kw):
- apply(ST.StructuredTextParagraph.__init__, (self, src, subs), kw)
- self._title=title
+ apply(ST.StructuredTextParagraph.__init__, (self, src, subs), kw)
+ self._title=title
def getColorizableTexts(self): return self._title, self._src
def setColorizableTexts(self, src): self._title, self._src = src
def getChildren(self):
- return (StructuredTextDescriptionTitle(self._title),
- StructuredTextDescriptionBody(self._src, self._subs))
+ return (StructuredTextDescriptionTitle(self._title),
+ StructuredTextDescriptionBody(self._src, self._subs))
class StructuredTextSectionTitle(ST.StructuredTextParagraph):
"""Represents a section of a document with a title and a body"""
@@ -62,16 +62,16 @@
class StructuredTextSection(ST.StructuredTextParagraph):
"""Represents a section of a document with a title and a body"""
def __init__(self, src, subs=None, **kw):
- apply(ST.StructuredTextParagraph.__init__,
- (self, StructuredTextSectionTitle(src), subs),
- kw)
+ apply(ST.StructuredTextParagraph.__init__,
[-=- -=- -=- 590 lines omitted -=- -=- -=-]
expr = re.compile('\s*\*\*([ \n%s0-9.:/;\-,!\?\'\"]+)\*\*' % letters).search
):
r=expr(s)
if r:
- start, end = r.span(1)
- return (StructuredTextStrong(s[start:end]), start-2, end+2)
+ start, end = r.span(1)
+ return (StructuredTextStrong(s[start:end]), start-2, end+2)
else:
- return None
+ return None
+
-
def doc_href1(self, s,
expr=re.compile("(\"[ %s0-9\n\-\.\,\;\(\)\/\:\/\*\']+\")(:)([a-zA-Z0-9\@\.\,\?\!\/\:\;\-\#\~]+)([,]*\s*)" % letters).search
):
@@ -594,11 +594,11 @@
def doc_href(self, s, expr, punctuation = re.compile("[\,\.\?\!\;]+").match):
r=expr(s)
-
+
if r:
# need to grab the href part and the
# beginning part
-
+
start,e = r.span(1)
name = s[start:e]
name = name.replace('"','',2)
@@ -607,13 +607,13 @@
if punctuation(s[end-1:end]):
end = end -1
link = s[st:end]
- #end = end - 1
-
+ #end = end - 1
+
# name is the href title, link is the target
# of the href
return (StructuredTextLink(name, href=link),
start, end)
-
+
#return (StructuredTextLink(s[start:end], href=s[start:end]),
# start, end)
else:
=== Zope/lib/python/StructuredText/ClassicStructuredText.py 1.6 => 1.7 ===
--- Zope/lib/python/StructuredText/ClassicStructuredText.py:1.6 Sat Apr 13 10:22:39 2002
+++ Zope/lib/python/StructuredText/ClassicStructuredText.py Wed Aug 14 17:58:22 2002
@@ -2,22 +2,22 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
'''Structured Text Manipulation
-Parse a structured text string into a form that can be used with
+Parse a structured text string into a form that can be used with
structured formats, like html.
Structured text is text that uses indentation and simple
-symbology to indicate the structure of a document.
+symbology to indicate the structure of a document.
A structured string consists of a sequence of paragraphs separated by
one or more blank lines. Each paragraph has a level which is defined
@@ -60,7 +60,7 @@
first '**' and whitespace or punctuation to the right of the second '**')
is made strong.
-- Text surrounded by '_' underscore characters (with whitespace to the left
+- Text surrounded by '_' underscore characters (with whitespace to the left
and whitespace or punctuation to the right) is made underlined.
- Text encloded by double quotes followed by a colon, a URL, and concluded
@@ -74,16 +74,16 @@
- Text enclosed by double quotes followed by a comma, one or more spaces,
an absolute URL and concluded by punctuation plus white space, or just
- white space, is treated as a hyper link. For example:
+ white space, is treated as a hyper link. For example:
"mail me", mailto:amos@digicool.com.
- Is interpreted as '<a href="mailto:amos@digicool.com">mail me</a>.'
+ Is interpreted as '<a href="mailto:amos@digicool.com">mail me</a>.'
- Text enclosed in brackets which consists only of letters, digits,
underscores and dashes is treated as hyper links within the document.
For example:
-
+
As demonstrated by Smith [12] this technique is quite effective.
Is interpreted as '... by Smith <a href="#12">[12]</a> this ...'. Together
@@ -92,11 +92,11 @@
- Text enclosed in brackets which is preceded by the start of a line, two
periods and a space is treated as a named link. For example:
- .. [12] "Effective Techniques" Smith, Joe ...
+ .. [12] "Effective Techniques" Smith, Joe ...
Is interpreted as '<a name="12">[12]</a> "Effective Techniques" ...'.
Together with the previous rule this allows easy coding of references or
- end notes.
+ end notes.
- A paragraph that has blocks of text enclosed in '||' is treated as a
@@ -295,15 +295,15 @@
pat = ' \"([%s0-9-_,./?=@~&]*)\":' % string.letters+ \
'([-:%s0-9_,./?=@#~&]*?)' % string.letters + \
- '([.:?;] )'
+ '([.:?;] )'
p_reg = re.compile(pat,re.M)
-
+
aStructuredString = p_reg.sub(r'<a href="\2">\1</a>\3 ' , aStructuredString)
pat = ' \"([%s0-9-_,./?=@~&]*)\", ' % string.letters+ \
'([-:%s0-9_,./?=@#~&]*?)' % string.letters + \
- '([.:?;] )'
+ '([.:?;] )'
p_reg = re.compile(pat,re.M)
@@ -327,10 +327,10 @@
return str(self.structure)
-ctag_prefix=r'([\x00- \\(]|^)'
-ctag_suffix=r'([\x00- ,.:;!?\\)]|$)'
-ctag_middle=r'[%s]([^\x00- %s][^%s]*[^\x00- %s]|[^%s])[%s]'
-ctag_middl2=r'[%s][%s]([^\x00- %s][^%s]*[^\x00- %s]|[^%s])[%s][%s]'
+ctag_prefix=r'([\x00- \\(]|^)'
+ctag_suffix=r'([\x00- ,.:;!?\\)]|$)'
+ctag_middle=r'[%s]([^\x00- %s][^%s]*[^\x00- %s]|[^%s])[%s]'
+ctag_middl2=r'[%s][%s]([^\x00- %s][^%s]*[^\x00- %s]|[^%s])[%s][%s]'
def ctag(s,
em=re.compile(
@@ -347,7 +347,7 @@
s=under.sub( r'\1<u>\2</u>\3',s)
s=code.sub( r'\1<code>\2</code>\3',s)
s=em.sub( r'\1<em>\2</em>\3',s)
- return s
+ return s
class HTML(StructuredText):
@@ -388,7 +388,7 @@
if level > 0 and level < 6:
return ('%s<h%d>%s</h%d>\n%s\n'
% (before,level,ctag(t).strip(),level,d))
-
+
t="<p><strong>%s</strong></p>" % ctag(t).strip()
return ('%s<dl><dt>%s\n</dt><dd>%s\n</dd></dl>\n'
% (before,t,d))
@@ -406,10 +406,10 @@
r="%s%s\n\n%s" % (r,html_quote(s[0]),self.pre(s[1],1))
if not tagged: r=r+'</PRE>\n'
return r
-
+
def table(self,before,table,after):
return '%s<p>%s</p>\n%s\n' % (before,ctag(table),after)
-
+
def _str(self,structure,level,
# Static
bullet=ts_regex.compile('[ \t\n]*[o*-][ \t\n]+\([^\0]*\)'
@@ -476,7 +476,7 @@
else:
r=self.normal(r,s[0],self._str(s[1],level))
return r
-
+
def html_quote(v,
character_entities=(
@@ -485,10 +485,10 @@
(re.compile(">"), '>' ),
(re.compile('"'), '"')
)): #"
- text=str(v)
- for re,name in character_entities:
- text=re.sub(name,text)
- return text
+ text=str(v)
+ for re,name in character_entities:
+ text=re.sub(name,text)
+ return text
def html_with_references(text, level=1):
text = re.sub(
@@ -500,14 +500,14 @@
r'([\x00- ,])\[(?P<ref>[0-9_%s-]+)\]([\x00- ,.:])' % string.letters,
r'\1<a href="#\2">[\2]</a>\3',
text)
-
+
text = re.sub(
r'([\0- ,])\[([^]]+)\.html\]([\0- ,.:])',
r'\1<a href="\2.html">[\2]</a>\3',
text)
return HTML(text,level=level)
-
+
def main():
import sys, getopt
@@ -535,7 +535,7 @@
mo = re.compile('([\0-\n]*\n)').match(s)
if mo is not None:
s = s[len(mo.group(0)) :]
-
+
s=str(html_with_references(s))
if s[:4]=='<h1>':
t=s[4: s.find('</h1>')]
=== Zope/lib/python/StructuredText/DocBookClass.py 1.5 => 1.6 ===
--- Zope/lib/python/StructuredText/DocBookClass.py:1.5 Fri Dec 21 11:00:16 2001
+++ Zope/lib/python/StructuredText/DocBookClass.py Wed Aug 14 17:58:22 2002
@@ -1,258 +1,256 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
class DocBookClass:
- element_types={
- '#text': '_text',
- 'StructuredTextDocument': 'document',
- 'StructuredTextParagraph': 'paragraph',
- 'StructuredTextExample': 'example',
- 'StructuredTextBullet': 'bullet',
- 'StructuredTextNumbered': 'numbered',
- 'StructuredTextDescription': 'description',
- 'StructuredTextDescriptionTitle': 'descriptionTitle',
- 'StructuredTextDescriptionBody': 'descriptionBody',
- 'StructuredTextSection': 'section',
- 'StructuredTextSectionTitle': 'sectionTitle',
- 'StructuredTextLiteral': 'literal',
- 'StructuredTextEmphasis': 'emphasis',
- 'StructuredTextStrong': 'strong',
- 'StructuredTextLink': 'link',
- 'StructuredTextXref': 'xref',
- 'StructuredTextSGML': 'sgml',
- }
-
- def dispatch(self, doc, level, output):
- getattr(self, self.element_types[doc.getNodeName()])(doc, level, output)
-
- def __call__(self, doc, level=1):
- r=[]
- self.dispatch(doc, level-1, r.append)
- return ''.join(r)
-
- def _text(self, doc, level, output):
- if doc.getNodeName() == 'StructuredTextLiteral':
- output(doc.getNodeValue())
- else:
- output(doc.getNodeValue().lstrip())
-
- def document(self, doc, level, output):
- output('<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN">\n')
- output('<book>\n')
- children=doc.getChildNodes()
- if (children and
- children[0].getNodeName() == 'StructuredTextSection'):
- output('<title>%s</title>' % children[0].getChildNodes()[0].getNodeValue())
- for c in children:
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('</book>\n')
-
- def section(self, doc, level, output):
- output('\n<section>\n')
- children=doc.getChildNodes()
- for c in children:
- getattr(self, self.element_types[c.getNodeName()])(c, level+1, output)
- output('\n</section>\n')
-
- def sectionTitle(self, doc, level, output):
- output('<title>')
- for c in doc.getChildNodes():
- try:
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- except:
- print "failed", c.getNodeName(), c
- output('</title>\n')
-
- def description(self, doc, level, output):
- p=doc.getPreviousSibling()
- if p is None or p.getNodeName() is not doc.getNodeName():
- output('<variablelist>\n')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- n=doc.getNextSibling()
- if n is None or n.getNodeName() is not doc.getNodeName():
- output('</variablelist>\n')
-
- def descriptionTitle(self, doc, level, output):
- output('<varlistentry><term>\n')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('</term>\n')
-
- def descriptionBody(self, doc, level, output):
- output('<listitem><para>\n')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('</para></listitem>\n')
- output('</varlistentry>\n')
-
- def bullet(self, doc, level, output):
- p=doc.getPreviousSibling()
- if p is None or p.getNodeName() is not doc.getNodeName():
- output('<itemizedlist>\n')
- output('<listitem><para>\n')
-
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- n=doc.getNextSibling()
- output('</para></listitem>\n')
- if n is None or n.getNodeName() is not doc.getNodeName():
- output('</itemizedlist>\n')
-
- def numbered(self, doc, level, output):
- p=doc.getPreviousSibling()
- if p is None or p.getNodeName() is not doc.getNodeName():
- output('<orderedlist>\n')
- output('<listitem><para>\n')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- n=doc.getNextSibling()
- output('</para></listitem>\n')
- if n is None or n.getNodeName() is not doc.getNodeName():
- output('</orderedlist>\n')
-
- def example(self, doc, level, output):
- i=0
- for c in doc.getChildNodes():
- if i==0:
- output('<programlisting>\n<![CDATA[\n')
- ##
- ## eek. A ']]>' in your body will break this...
- ##
- output(prestrip(c.getNodeValue()))
- output('\n]]></programlisting>\n')
- else:
+ element_types={
+ '#text': '_text',
+ 'StructuredTextDocument': 'document',
+ 'StructuredTextParagraph': 'paragraph',
+ 'StructuredTextExample': 'example',
+ 'StructuredTextBullet': 'bullet',
+ 'StructuredTextNumbered': 'numbered',
+ 'StructuredTextDescription': 'description',
+ 'StructuredTextDescriptionTitle': 'descriptionTitle',
+ 'StructuredTextDescriptionBody': 'descriptionBody',
+ 'StructuredTextSection': 'section',
+ 'StructuredTextSectionTitle': 'sectionTitle',
+ 'StructuredTextLiteral': 'literal',
+ 'StructuredTextEmphasis': 'emphasis',
+ 'StructuredTextStrong': 'strong',
+ 'StructuredTextLink': 'link',
+ 'StructuredTextXref': 'xref',
+ 'StructuredTextSGML': 'sgml',
+ }
+
+ def dispatch(self, doc, level, output):
+ getattr(self, self.element_types[doc.getNodeName()])(doc, level, output)
+
+ def __call__(self, doc, level=1):
+ r=[]
+ self.dispatch(doc, level-1, r.append)
+ return ''.join(r)
+
+ def _text(self, doc, level, output):
+ if doc.getNodeName() == 'StructuredTextLiteral':
+ output(doc.getNodeValue())
+ else:
+ output(doc.getNodeValue().lstrip())
+
+ def document(self, doc, level, output):
+ output('<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN">\n')
+ output('<book>\n')
+ children=doc.getChildNodes()
+ if (children and
+ children[0].getNodeName() == 'StructuredTextSection'):
+ output('<title>%s</title>' % children[0].getChildNodes()[0].getNodeValue())
+ for c in children:
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('</book>\n')
+
+ def section(self, doc, level, output):
+ output('\n<section>\n')
+ children=doc.getChildNodes()
+ for c in children:
+ getattr(self, self.element_types[c.getNodeName()])(c, level+1, output)
+ output('\n</section>\n')
+
+ def sectionTitle(self, doc, level, output):
+ output('<title>')
+ for c in doc.getChildNodes():
+ try:
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ except:
+ print "failed", c.getNodeName(), c
+ output('</title>\n')
+
+ def description(self, doc, level, output):
+ p=doc.getPreviousSibling()
+ if p is None or p.getNodeName() is not doc.getNodeName():
+ output('<variablelist>\n')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ n=doc.getNextSibling()
+ if n is None or n.getNodeName() is not doc.getNodeName():
+ output('</variablelist>\n')
+
+ def descriptionTitle(self, doc, level, output):
+ output('<varlistentry><term>\n')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('</term>\n')
+
+ def descriptionBody(self, doc, level, output):
+ output('<listitem><para>\n')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('</para></listitem>\n')
+ output('</varlistentry>\n')
+
+ def bullet(self, doc, level, output):
+ p=doc.getPreviousSibling()
+ if p is None or p.getNodeName() is not doc.getNodeName():
+ output('<itemizedlist>\n')
+ output('<listitem><para>\n')
+
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ n=doc.getNextSibling()
+ output('</para></listitem>\n')
+ if n is None or n.getNodeName() is not doc.getNodeName():
+ output('</itemizedlist>\n')
+
+ def numbered(self, doc, level, output):
+ p=doc.getPreviousSibling()
+ if p is None or p.getNodeName() is not doc.getNodeName():
+ output('<orderedlist>\n')
+ output('<listitem><para>\n')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ n=doc.getNextSibling()
+ output('</para></listitem>\n')
+ if n is None or n.getNodeName() is not doc.getNodeName():
+ output('</orderedlist>\n')
+
+ def example(self, doc, level, output):
+ i=0
+ for c in doc.getChildNodes():
+ if i==0:
+ output('<programlisting>\n<![CDATA[\n')
+ ##
+ ## eek. A ']]>' in your body will break this...
+ ##
+ output(prestrip(c.getNodeValue()))
+ output('\n]]></programlisting>\n')
+ else:
+ getattr(self, self.element_types[c.getNodeName()])(
+ c, level, output)
+
+ def paragraph(self, doc, level, output):
+ output('<para>\n\n')
+ for c in doc.getChildNodes():
getattr(self, self.element_types[c.getNodeName()])(
c, level, output)
+ output('</para>\n\n')
- def paragraph(self, doc, level, output):
- output('<para>\n\n')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(
- c, level, output)
- output('</para>\n\n')
-
- def link(self, doc, level, output):
- output('<ulink url="%s">' % doc.href)
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('</ulink>')
-
- def emphasis(self, doc, level, output):
- output('<emphasis>')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('</emphasis> ')
-
- def literal(self, doc, level, output):
- output('<literal>')
- for c in doc.getChildNodes():
- output(c.getNodeValue())
- output('</literal>')
-
- def strong(self, doc, level, output):
- output('<emphasis>')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('</emphasis>')
+ def link(self, doc, level, output):
+ output('<ulink url="%s">' % doc.href)
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('</ulink>')
- def xref(self, doc, level, output):
- output('<xref linkend="%s"/>' % doc.getNodeValue())
+ def emphasis(self, doc, level, output):
+ output('<emphasis>')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('</emphasis> ')
+
+ def literal(self, doc, level, output):
+ output('<literal>')
+ for c in doc.getChildNodes():
+ output(c.getNodeValue())
+ output('</literal>')
+
+ def strong(self, doc, level, output):
+ output('<emphasis>')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('</emphasis>')
- def sgml(self, doc, level, output):
- output(doc.getNodeValue())
+ def xref(self, doc, level, output):
+ output('<xref linkend="%s"/>' % doc.getNodeValue())
+
+ def sgml(self, doc, level, output):
+ output(doc.getNodeValue())
def prestrip(v):
- v=v.replace( '\r\n', '\n')
- v=v.replace( '\r', '\n')
- v=v.replace( '\t', ' ')
- lines=v.split('\n')
- indent=len(lines[0])
- for line in lines:
- if not len(line): continue
- i=len(line)-len(line.lstrip())
- if i < indent:
- indent=i
- nlines=[]
- for line in lines:
- nlines.append(line[indent:])
- return '\n'.join(nlines, '\n')
+ v=v.replace( '\r\n', '\n')
+ v=v.replace( '\r', '\n')
+ v=v.replace( '\t', ' ')
+ lines=v.split('\n')
+ indent=len(lines[0])
+ for line in lines:
+ if not len(line): continue
+ i=len(line)-len(line.lstrip())
+ if i < indent:
+ indent=i
+ nlines=[]
+ for line in lines:
+ nlines.append(line[indent:])
+ return '\n'.join(nlines, '\n')
class DocBookChapter(DocBookClass):
- def document(self, doc, level, output):
- output('<chapter>\n')
- children=doc.getChildNodes()
- if (children and
- children[0].getNodeName() == 'StructuredTextSection'):
- output('<title>%s</title>' % children[0].getChildNodes()[0].getNodeValue())
- for c in children[0].getChildNodes()[1:]:
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('</chapter>\n')
+ def document(self, doc, level, output):
+ output('<chapter>\n')
+ children=doc.getChildNodes()
+ if (children and
+ children[0].getNodeName() == 'StructuredTextSection'):
+ output('<title>%s</title>' % children[0].getChildNodes()[0].getNodeValue())
+ for c in children[0].getChildNodes()[1:]:
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('</chapter>\n')
ets = DocBookClass.element_types
-ets.update({'StructuredTextImage': 'image'})
+ets.update({'StructuredTextImage': 'image'})
class DocBookChapterWithFigures(DocBookChapter):
element_types = ets
def image(self, doc, level, output):
- if hasattr(doc, 'key'):
- output('<figure id="%s"><title>%s</title>\n' % (doc.key, doc.getNodeValue()) )
- else:
- output('<figure><title>%s</title>\n' % doc.getNodeValue())
+ if hasattr(doc, 'key'):
+ output('<figure id="%s"><title>%s</title>\n' % (doc.key, doc.getNodeValue()) )
+ else:
+ output('<figure><title>%s</title>\n' % doc.getNodeValue())
## for c in doc.getChildNodes():
## getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('<graphic fileref="%s"></graphic>\n</figure>\n' % doc.href)
+ output('<graphic fileref="%s"></graphic>\n</figure>\n' % doc.href)
class DocBookArticle(DocBookClass):
- def document(self, doc, level, output):
- output('<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN">\n')
- output('<article>\n')
- children=doc.getChildNodes()
- if (children and
- children[0].getNodeName() == 'StructuredTextSection'):
- output('<articleinfo>\n<title>%s</title>\n</articleinfo>\n' %
- children[0].getChildNodes()[0].getNodeValue())
- for c in children:
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('</article>\n')
+ def document(self, doc, level, output):
+ output('<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN">\n')
+ output('<article>\n')
+ children=doc.getChildNodes()
+ if (children and
+ children[0].getNodeName() == 'StructuredTextSection'):
+ output('<articleinfo>\n<title>%s</title>\n</articleinfo>\n' %
+ children[0].getChildNodes()[0].getNodeValue())
+ for c in children:
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('</article>\n')
class DocBookBook:
- def __init__(self, title=''):
- self.title = title
- self.chapters = []
-
- def addChapter(self, chapter):
- self.chapters.append(chapter)
-
- def read(self):
- out = '<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN">\n<book>\n'
- out = out + '<title>%s</title>\n' % self.title
- for chapter in self.chapters:
- out = out + chapter + '\n</book>\n'
-
- return out
-
- def __str__(self):
- return self.read()
-
+ def __init__(self, title=''):
+ self.title = title
+ self.chapters = []
+
+ def addChapter(self, chapter):
+ self.chapters.append(chapter)
+
+ def read(self):
+ out = '<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN">\n<book>\n'
+ out = out + '<title>%s</title>\n' % self.title
+ for chapter in self.chapters:
+ out = out + chapter + '\n</book>\n'
+
+ return out
+ def __str__(self):
+ return self.read()
=== Zope/lib/python/StructuredText/DocumentClass.py 1.48 => 1.49 === (830/930 lines abridged)
--- Zope/lib/python/StructuredText/DocumentClass.py:1.48 Thu Jun 20 13:43:29 2002
+++ Zope/lib/python/StructuredText/DocumentClass.py Wed Aug 14 17:58:22 2002
@@ -1,7 +1,7 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
@@ -19,11 +19,11 @@
ListType=type([])
def flatten(obj, append):
- if obj.getNodeType()==STDOM.TEXT_NODE:
- append(obj.getNodeValue())
- else:
- for child in obj.getChildNodes():
- flatten(child, append)
+ if obj.getNodeType()==STDOM.TEXT_NODE:
+ append(obj.getNodeValue())
+ else:
+ for child in obj.getChildNodes():
+ flatten(child, append)
class StructuredTextExample(ST.StructuredTextParagraph):
@@ -55,17 +55,17 @@
class StructuredTextDescription(ST.StructuredTextParagraph):
"""Represents a section of a document with a title and a body"""
-
+
def __init__(self, title, src, subs, **kw):
- apply(ST.StructuredTextParagraph.__init__, (self, src, subs), kw)
- self._title=title
+ apply(ST.StructuredTextParagraph.__init__, (self, src, subs), kw)
+ self._title=title
def getColorizableTexts(self): return self._title, self._src
def setColorizableTexts(self, src): self._title, self._src = src
def getChildren(self):
- return (StructuredTextDescriptionTitle(self._title),
- StructuredTextDescriptionBody(self._src, self._subs))
+ return (StructuredTextDescriptionTitle(self._title),
+ StructuredTextDescriptionBody(self._src, self._subs))
class StructuredTextSectionTitle(ST.StructuredTextParagraph):
[-=- -=- -=- 830 lines omitted -=- -=- -=-]
+ return None
## Some constants to make the doc_href() regex easier to read.
_DQUOTEDTEXT = r'("[ %s0-9\n\r%s]+")' % (letters,dbl_quoted_punc) ## double quoted text
@@ -894,7 +894,7 @@
def doc_href2(self, s,
expr=re.compile(_DQUOTEDTEXT + r'(\,\s+)' + _ABSOLUTE_URL + _SPACES).search
):
- return self.doc_href(s, expr)
+ return self.doc_href(s, expr)
def doc_href(self, s, expr, punctuation=re.compile(r"[\,\.\?\!\;]+").match):
@@ -904,7 +904,7 @@
if r:
# need to grab the href part and the
# beginning part
-
+
start,e = r.span(1)
name = s[start:e]
name = name.replace('"','',2)
@@ -913,18 +913,18 @@
if punctuation(s[end-1:end]):
end = end -1
link = s[st:end]
- #end = end - 1
-
+ #end = end - 1
+
# name is the href title, link is the target
# of the href
return (StructuredTextLink(name, href=link),
start, end)
-
+
#return (StructuredTextLink(s[start:end], href=s[start:end]),
# start, end)
else:
return None
-
+
def doc_sgml(self,s,expr=re.compile(r"\<[%s0-9\.\=\'\"\:\/\-\#\+\s\*]+\>" % letters).search):
"""
SGML text is ignored and outputed as-is
@@ -945,4 +945,3 @@
return (StructuredTextXref(s[start:end]), start-1, end+1)
else:
return None
-
=== Zope/lib/python/StructuredText/DocumentWithImages.py 1.7 => 1.8 ===
--- Zope/lib/python/StructuredText/DocumentWithImages.py:1.7 Sat Jun 8 14:32:12 2002
+++ Zope/lib/python/StructuredText/DocumentWithImages.py Wed Aug 14 17:58:22 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
import re
@@ -17,7 +17,7 @@
class StructuredTextImage(StructuredTextMarkup):
"A simple embedded image"
-class DocumentWithImages(DocumentClass):
+class DocumentWithImages(DocumentClass):
"""
"""
@@ -44,17 +44,17 @@
if not r.group(2) in ['http','file','ftp']:
- startt, endt = r.span(1)
- startk, endk = r.span(2)
- starth, endh = r.span(3)
- start, end = r.span()
-
- key = s[startk:endk]
-
- return (StructuredTextImage(s[startt:endt], href=s[starth:endh], key=s[startk:endk]),
- start, end)
+ startt, endt = r.span(1)
+ startk, endk = r.span(2)
+ starth, endh = r.span(3)
+ start, end = r.span()
+
+ key = s[startk:endk]
+
+ return (StructuredTextImage(s[startt:endt], href=s[starth:endh], key=s[startk:endk]),
+ start, end)
+
-
r=expr1(s)
if r:
startt, endt = r.span(1)
@@ -64,4 +64,3 @@
start, end)
return None
-
=== Zope/lib/python/StructuredText/HTMLClass.py 1.21 => 1.22 ===
--- Zope/lib/python/StructuredText/HTMLClass.py:1.21 Wed May 22 13:40:48 2002
+++ Zope/lib/python/StructuredText/HTMLClass.py Wed Aug 14 17:58:22 2002
@@ -43,7 +43,7 @@
def dispatch(self, doc, level, output):
getattr(self, self.element_types[doc.getNodeName()])(doc, level, output)
-
+
def __call__(self, doc, level=1, header=1):
r=[]
self.header = header
@@ -75,7 +75,7 @@
children=doc.getChildNodes()
for c in children:
getattr(self, self.element_types[c.getNodeName()])(c, level+1, output)
-
+
def sectionTitle(self, doc, level, output):
output('<h%d>' % (level))
for c in doc.getChildNodes():
@@ -84,20 +84,20 @@
def description(self, doc, level, output):
p=doc.getPreviousSibling()
- if p is None or p.getNodeName() is not doc.getNodeName():
+ if p is None or p.getNodeName() is not doc.getNodeName():
output('<dl>\n')
for c in doc.getChildNodes():
getattr(self, self.element_types[c.getNodeName()])(c, level, output)
n=doc.getNextSibling()
- if n is None or n.getNodeName() is not doc.getNodeName():
+ if n is None or n.getNodeName() is not doc.getNodeName():
output('</dl>\n')
-
+
def descriptionTitle(self, doc, level, output):
output('<dt>')
for c in doc.getChildNodes():
getattr(self, self.element_types[c.getNodeName()])(c, level, output)
output('</dt>\n')
-
+
def descriptionBody(self, doc, level, output):
output('<dd>')
for c in doc.getChildNodes():
@@ -113,12 +113,12 @@
getattr(self, self.element_types[c.getNodeName()])(c, level, output)
n=doc.getNextSibling()
output('</li>\n')
- if n is None or n.getNodeName() is not doc.getNodeName():
+ if n is None or n.getNodeName() is not doc.getNodeName():
output('\n</ul>\n')
def numbered(self, doc, level, output):
p=doc.getPreviousSibling()
- if p is None or p.getNodeName() is not doc.getNodeName():
+ if p is None or p.getNodeName() is not doc.getNodeName():
output('\n<ol>\n')
output('<li>')
for c in doc.getChildNodes():
@@ -174,13 +174,13 @@
for c in doc.getChildNodes():
getattr(self, self.element_types[c.getNodeName()])(c, level, output)
output('</strong>')
-
+
def underline(self, doc, level, output):
output("<u>")
for c in doc.getChildNodes():
getattr(self, self.element_types[c.getNodeName()])(c, level, output)
output("</u>")
-
+
def innerLink(self, doc, level, output):
output('<a href="#ref');
for c in doc.getChildNodes():
@@ -189,7 +189,7 @@
for c in doc.getChildNodes():
getattr(self, self.element_types[c.getNodeName()])(c, level, output)
output(']</a>')
-
+
def namedLink(self, doc, level, output):
output('<a name="ref')
for c in doc.getChildNodes():
@@ -198,7 +198,7 @@
for c in doc.getChildNodes():
getattr(self, self.element_types[c.getNodeName()])(c, level, output)
output(']</a>')
-
+
def sgml(self,doc,level,output):
for c in doc.getChildNodes():
getattr(self, self.element_types[c.getNodeName()])(c, level, output)
@@ -206,7 +206,7 @@
def xref(self, doc, level, output):
val = doc.getNodeValue()
output('<a href="#ref%s">[%s]</a>' % (val, val) )
-
+
def table(self,doc,level,output):
"""
A StructuredTextTable holds StructuredTextRow(s) which
=== Zope/lib/python/StructuredText/HTMLWithImages.py 1.9 => 1.10 ===
--- Zope/lib/python/StructuredText/HTMLWithImages.py:1.9 Wed May 22 14:04:14 2002
+++ Zope/lib/python/StructuredText/HTMLWithImages.py Wed Aug 14 17:58:22 2002
@@ -1,21 +1,21 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
from HTMLClass import HTMLClass
ets = HTMLClass.element_types
-ets.update({'StructuredTextImage': 'image'})
+ets.update({'StructuredTextImage': 'image'})
class HTMLWithImages(HTMLClass):
@@ -23,9 +23,8 @@
def image(self, doc, level, output):
- if hasattr(doc, 'key'):
- output('<a name="%s"></a>\n' % doc.key)
- output('<img src="%s" alt="%s">\n' % (doc.href, doc.getNodeValue()))
- if doc.getNodeValue() and hasattr(doc, 'key'):
- output('<p><b>Figure %s</b> %s</p>\n' % (doc.key, doc.getNodeValue()))
-
+ if hasattr(doc, 'key'):
+ output('<a name="%s"></a>\n' % doc.key)
+ output('<img src="%s" alt="%s">\n' % (doc.href, doc.getNodeValue()))
+ if doc.getNodeValue() and hasattr(doc, 'key'):
+ output('<p><b>Figure %s</b> %s</p>\n' % (doc.key, doc.getNodeValue()))
=== Zope/lib/python/StructuredText/ST.py 1.16 => 1.17 ===
--- Zope/lib/python/StructuredText/ST.py:1.16 Mon Mar 11 10:13:34 2002
+++ Zope/lib/python/StructuredText/ST.py Wed Aug 14 17:58:22 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
import re, STDOM
@@ -18,10 +18,10 @@
#####################################################################
def indention(str,front = re.compile("^\s+").match):
- """
+ """
Find the number of leading spaces. If none, return 0.
"""
-
+
result = front(str)
if result is not None:
start, end = result.span()
@@ -48,7 +48,7 @@
i = i + 1
#print "parent for level ", level, " was => ", run.getColorizableTexts()
return run.getSubparagraphs()
-
+
def display(struct):
"""
runs through the structure and prints out
@@ -56,27 +56,27 @@
correctly, display's results should mimic
the orignal paragraphs.
"""
-
+
if struct.getColorizableTexts():
print join(struct.getColorizableTexts()),"\n"
if struct.getSubparagraphs():
for x in struct.getSubparagraphs():
display(x)
-
+
def display2(struct):
"""
runs through the structure and prints out
the paragraphs. If the insertion works
correctly, display's results should mimic
- the orignal paragraphs.
+ the orignal paragraphs.
"""
-
+
if struct.getNodeValue():
print struct.getNodeValue(),"\n"
if struct.getSubparagraphs():
for x in struct.getSubparagraphs():
display(x)
-
+
def findlevel(levels,indent):
"""
remove all level information of levels
@@ -84,7 +84,7 @@
Then return which level should insert this
paragraph
"""
-
+
keys = levels.keys()
for key in keys:
if levels[key] > indent:
@@ -109,7 +109,7 @@
# Golly, the capitalization of this function always makes me think it's a class
def StructuredText(paragraphs, delimiter=re.compile(para_delim)):
"""
- StructuredText accepts paragraphs, which is a list of
+ StructuredText accepts paragraphs, which is a list of
lines to be parsed. StructuredText creates a structure
which mimics the structure of the paragraphs.
Structure => [paragraph,[sub-paragraphs]]
@@ -125,21 +125,21 @@
paragraphs = paragraphs.expandtabs()
paragraphs = '%s%s%s' % ('\n\n', paragraphs, '\n\n')
paragraphs = delimiter.split(paragraphs)
- paragraphs = [ x for x in paragraphs if x.strip() ]
+ paragraphs = [ x for x in paragraphs if x.strip() ]
if not paragraphs: return StructuredTextDocument()
-
+
ind = [] # structure based on indention levels
for paragraph in paragraphs:
ind.append([indention(paragraph), paragraph])
-
+
currentindent = indention(paragraphs[0])
levels[0] = currentindent
-
+
#############################################################
# updated #
#############################################################
-
+
for indent,paragraph in ind :
if indent == 0:
level = level + 1
@@ -170,7 +170,7 @@
run = struct
currentindent = indent
run.append(StructuredTextParagraph(paragraph, indent=indent, level=currentlevel))
-
+
return StructuredTextDocument(struct)
Basic = StructuredText
@@ -183,7 +183,7 @@
if subs is None: subs=[]
self._src=src
self._subs=list(subs)
-
+
self._attributes=kw.keys()
for k, v in kw.items(): setattr(self, k, v)
@@ -194,7 +194,7 @@
def getAttribute(self, name):
return getattr(self, name, None)
-
+
def getAttributeNode(self, name):
if hasattr(self, name):
return STDOM.Attr(name, getattr(self, name))
@@ -233,10 +233,10 @@
def _get_Children(self, type=type, lt=type([])):
return self.getChildren(type,lt)
-
+
def _get_Attribute(self, name):
return self.getAttribute(name)
-
+
def _get_AttributeNode(self, name):
return self.getAttributeNode(name)
@@ -261,7 +261,7 @@
as its subparagraphs.
"""
_attributes=()
-
+
def __init__(self, subs=None, **kw):
apply(StructuredTextParagraph.__init__,
(self, '', subs),
@@ -269,10 +269,10 @@
def getChildren(self):
return self._subs
-
+
def getColorizableTexts(self):
return ()
-
+
def setColorizableTexts(self, src):
pass
@@ -282,16 +282,16 @@
for p in self._subs: a(`p`+',')
a('])')
return '\n'.join(r)
-
+
"""
create aliases for all above functions in the pythony way.
"""
-
+
def _get_Children(self):
return self.getChildren()
-
+
def _get_ColorizableTexts(self):
return self.getColorizableTexts()
-
+
def _set_ColorizableTexts(self, src):
return self.setColorizableTexts(src)
=== Zope/lib/python/StructuredText/STDOM.py 1.6 => 1.7 === (1075/1175 lines abridged)
--- Zope/lib/python/StructuredText/STDOM.py:1.6 Fri Jun 7 21:10:25 2002
+++ Zope/lib/python/StructuredText/STDOM.py Wed Aug 14 17:58:22 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
"""
DOM implementation in StructuredText : Read-Only methods
@@ -76,588 +76,588 @@
# ------------
class ParentNode:
- """
- A node that can have children, or, more precisely, that implements
- the child access methods of the DOM.
- """
-
- def getChildNodes(self, type=type, st=type('')):
- """
- Returns a NodeList that contains all children of this node.
- If there are no children, this is a empty NodeList
- """
-
- r=[]
- for n in self.getChildren():
- if type(n) is st: n=TextNode(n)
- r.append(n.__of__(self))
-
- return NodeList(r)
-
- def getFirstChild(self, type=type, st=type('')):
- """
- The first child of this node. If there is no such node
- this returns None
- """
- children = self.getChildren()
-
- if not children:
- return None
[-=- -=- -=- 1075 lines omitted -=- -=- -=-]
+ """
+ return self.name
+
+ def getName(self):
+ """
+ Returns the name of this attribute.
+ """
+ return self.name
+
+ def getNodeValue(self):
+ """
+ The value of this node, depending on its type
+ """
+ return self.value
+
+ def getNodeType(self):
+ """
+ A code representing the type of the node.
+ """
+ return ATTRIBUTE_NODE
+
+ def getSpecified(self):
+ """
+ If this attribute was explicitly given a value in the
+ original document, this is true; otherwise, it is false.
+ """
+ return self.specified
+
+ """
+ create aliases for all above functions in the pythony way.
+ """
+
+ def _get_NodeName(self):
+ return self.getNodeName()
+
+ def _get_Name(self):
+ return self.getName()
+
+ def _get_NodeValue(self):
+ return self.getNodeValue()
- def _get_NodeType(self):
- return self.getNodeType()
+ def _get_NodeType(self):
+ return self.getNodeType()
- def _get_Specified(self):
- return self.getSpecified()
+ def _get_Specified(self):
+ return self.getSpecified()
=== Zope/lib/python/StructuredText/STletters.py 1.6 => 1.7 ===
--- Zope/lib/python/StructuredText/STletters.py:1.6 Tue Oct 16 08:46:11 2001
+++ Zope/lib/python/StructuredText/STletters.py Wed Aug 14 17:58:22 2002
@@ -14,4 +14,3 @@
strongem_punc = punc_func('*')
under_punc = punc_func('_<>')
phrase_delimiters = r'\s\.\,\?\/\!\&\(\)'
-
=== Zope/lib/python/StructuredText/StructuredText.py 1.48 => 1.49 ===
--- Zope/lib/python/StructuredText/StructuredText.py:1.48 Mon Mar 11 10:13:34 2002
+++ Zope/lib/python/StructuredText/StructuredText.py Wed Aug 14 17:58:22 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
""" Alias module for StructuredTextClassic compatibility which makes
@@ -46,7 +46,7 @@
r'([\000- ,])\[(?P<ref>[0-9_%s-]+)\]([\000- ,.:])' % letters,
r'\1<a href="#\2">[\2]</a>\3',
text)
-
+
text = re.sub(
r'([\000- ,])\[([^]]+)\.html\]([\000- ,.:])',
r'\1<a href="\2.html">[\2]</a>\3',
@@ -61,10 +61,10 @@
(re.compile(">"), '>' ),
(re.compile('"'), '"')
)): #"
- text=str(v)
- for re,name in character_entities:
- text=re.sub(name,text)
- return text
+ text=str(v)
+ for re,name in character_entities:
+ text=re.sub(name,text)
+ return text
if __name__=='__main__':
@@ -78,4 +78,3 @@
for f in args:
print HTML(open(f).read())
-
=== Zope/lib/python/StructuredText/Zwiki.py 1.6 => 1.7 ===
--- Zope/lib/python/StructuredText/Zwiki.py:1.6 Mon Mar 11 10:13:35 2002
+++ Zope/lib/python/StructuredText/Zwiki.py Wed Aug 14 17:58:22 2002
@@ -2,14 +2,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
from Html import HTML
@@ -21,65 +21,65 @@
"""
class Zwiki_Title:
- def __init__(self,str=''):
- self.expr1 = re.compile('([A-Z]+[A-Z]+[a-zA-Z]*)').search
- self.expr2 = re.compile('([A-Z]+[a-z]+[A-Z]+[a-zA-Z]*)').search
- self.str = [str]
- self.typ = "Zwiki_Title"
-
- def type(self):
- return '%s' % self.typ
-
- def string(self):
- return self.str
-
- def __getitem__(self,index):
- return self.str[index]
-
- def __call__(self,raw_string,subs):
-
- """
- The raw_string is checked to see if it matches the rules
- for this structured text expression. If the raw_string does,
- it is parsed for the sub-string which matches and a doc_inner_link
- instance is returned whose string is the matching substring.
- If raw_string does not match, nothing is returned.
- """
-
- if self.expr1(raw_string):
- start,end = self.expr1(raw_string).span()
- result = Zwiki_Title(raw_string[start:end])
- result.start,result.end = self.expr1(raw_string).span()
- return result
- elif self.expr2(raw_string):
- start,end = self.expr2(raw_string).span()
- result = Zwiki_Title(raw_string[start:end])
- result.start,result.end = self.expr2(raw_string).span()
- return result
- else:
- return None
+ def __init__(self,str=''):
+ self.expr1 = re.compile('([A-Z]+[A-Z]+[a-zA-Z]*)').search
+ self.expr2 = re.compile('([A-Z]+[a-z]+[A-Z]+[a-zA-Z]*)').search
+ self.str = [str]
+ self.typ = "Zwiki_Title"
+
+ def type(self):
+ return '%s' % self.typ
+
+ def string(self):
+ return self.str
+
+ def __getitem__(self,index):
+ return self.str[index]
+
+ def __call__(self,raw_string,subs):
+
+ """
+ The raw_string is checked to see if it matches the rules
+ for this structured text expression. If the raw_string does,
+ it is parsed for the sub-string which matches and a doc_inner_link
+ instance is returned whose string is the matching substring.
+ If raw_string does not match, nothing is returned.
+ """
+
+ if self.expr1(raw_string):
+ start,end = self.expr1(raw_string).span()
+ result = Zwiki_Title(raw_string[start:end])
+ result.start,result.end = self.expr1(raw_string).span()
+ return result
+ elif self.expr2(raw_string):
+ start,end = self.expr2(raw_string).span()
+ result = Zwiki_Title(raw_string[start:end])
+ result.start,result.end = self.expr2(raw_string).span()
+ return result
+ else:
+ return None
- def span(self):
- return self.start,self.end
+ def span(self):
+ return self.start,self.end
class Zwiki_doc(DOC):
- def __init__(self):
- DOC.__init__(self)
- """
- Add the new type to self.types
- """
- self.types.append(Zwiki_Title())
+ def __init__(self):
+ DOC.__init__(self)
+ """
+ Add the new type to self.types
+ """
+ self.types.append(Zwiki_Title())
class Zwiki_parser(HTML):
- def __init__(self):
- HTML.__init__(self)
- self.types["Zwiki_Title"] = self.zwiki_title
-
- def zwiki_title(self,object):
- result = ""
- for x in object.string():
- result = result + x
- result = "<a href=%s>%s</a>" % (result,result)
- #result = "<dtml-wikiname %s>" % result
- self.string = self.string + result
+ def __init__(self):
+ HTML.__init__(self)
+ self.types["Zwiki_Title"] = self.zwiki_title
+
+ def zwiki_title(self,object):
+ result = ""
+ for x in object.string():
+ result = result + x
+ result = "<a href=%s>%s</a>" % (result,result)
+ #result = "<dtml-wikiname %s>" % result
+ self.string = self.string + result
=== Zope/lib/python/StructuredText/__init__.py 1.8 => 1.9 ===
--- Zope/lib/python/StructuredText/__init__.py:1.8 Mon Feb 11 08:29:02 2002
+++ Zope/lib/python/StructuredText/__init__.py Wed Aug 14 17:58:22 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
import HTMLClass, DocumentClass
@@ -23,7 +23,7 @@
ClassicHTML=HTML
HTMLNG=HTMLClass.HTMLClass()
-def HTML(src, level=1):
+def HTML(src, level=1):
if isinstance(src, StringType):
return ClassicHTML(src, level)
return HTMLNG(src, level)
@@ -37,5 +37,3 @@
DocBookChapter=DocBookClass.DocBookChapter()
DocBookChapterWithFigures=DocBookClass.DocBookChapterWithFigures()
DocBookArticle=DocBookClass.DocBookArticle()
-
-