Commit b058178f authored by Andreas Jung's avatar Andreas Jung

- _..._ was still broken. Even more __....__ was broken. Underlines are evil.

- added script to recreate regression reference files
- added another test
parent 647367d2
......@@ -925,7 +925,7 @@ class DocumentClass:
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):
expr=re.compile(r'_([%s%s%s\s]+)_[\s%s]' % (letters, digits, under_punc,phrase_delimiters)).search):
result = expr(s)
if result:
......@@ -933,7 +933,7 @@ class DocumentClass:
return None # no double unders
start,end = result.span(1)
st,e = result.span()
return (StructuredTextUnderline(s[start:end]),st,e)
return (StructuredTextUnderline(s[start:end]),st,e-1)
else:
return None
......
......@@ -258,4 +258,3 @@
OOPSLA '96 Proceedings, ACM SIG-PLAN, October, 1996</p>
</body>
</html>
......@@ -410,13 +410,13 @@
be used to compute an attribute, and calls the function when
it's <code>__of__</code> method is called:<p> import ExtensionClass</p>
<h5> class ComputedAttribute(ExtensionClass.Base):</h5>
<p> def _<u>init</u>_(self, func): self.func=func</p>
<p> def _<u>of</u>_(self, parent): return self.func(parent)</p>
<p> def __init__(self, func): self.func=func</p>
<p> def __of__(self, parent): return self.func(parent)</p>
</p>
<p> Then we can use this class to create computed attributes. In the
example below, we create a computed attribute, 'radius':<p> from math import sqrt</p>
<h5> class Point(ExtensionClass.Base):</h5>
<p> def _<u>init</u>_(self, x, y): self.x, self.y = x, y</p>
<p> def __init__(self, x, y): self.x, self.y = x, y</p>
<p> radius=ComputedAttribute(lambda self: sqrt(self.x<strong>2+self.y</strong>2))</p>
</p>
<h5> which we can use just like an ordinary attribute:</h5>
......@@ -612,4 +612,3 @@
<p>.. <a href="#6">[6]</a> Beaudry, D., and Ascher, D., <a href="http://starship.skyport.net/~da/mess/">The Meta-Extension Set</a>.</p>
</body>
</html>
......@@ -8,10 +8,10 @@
<ul>
<li><p>please click <a href="/Members/Zope">here</a></p></li>
<li><p>please click <a href="/Members/Zope?a=b&c=d%20blabla">here</a></p></li>
<li><p>please click <a href="http://www.zope.org">here</a>" </p></li>
<li><p>please click <a href="http://www.zope.org/members/">here</a>" </p></li>
<li><p>please click <a href="http://www.zope.org:2001">here</a>" </p></li>
<li><p>please click <a href="http://www.zope.org:2001/members/">here</a>" </p></li>
<li><p>please click <a href="http://www.zope.org">here</a></p></li>
<li><p>please click <a href="http://www.zope.org/members/">here</a></p></li>
<li><p>please click <a href="http://www.zope.org:2001">here</a> </p></li>
<li><p>please click <a href="http://www.zope.org:2001/members/">here</a></p></li>
<li><p>please click <a href="http://www.zope.org:2001/%20/Members/zope?a=222&b=213&_xc=just%20a%20test">here</a> </p></li>
<li><p>please click <a href="http://www.zope.org:2001/%20/Members/zope?a=222&b=213&_xc=just%20a%20test">here</a> </p></li>
<li><p>please click <a href="http://www.zope.org:2001/%20/Members/zope?a=222&b=213&_xc=just%20a%20test">here</a> </p></li>
......@@ -21,4 +21,3 @@
<a href="http://www.zope-is-kewl.com">Link 2</a> and <a href="http://www.freshmeat.net">one more link - yeah.</a></p>
</body>
</html>
......@@ -4,13 +4,13 @@ This is LinkTest
- please click "here":/Members/Zope?a=b&c=d%20blabla
- please click "here":http://www.zope.org"
- please click "here":http://www.zope.org
- please click "here":http://www.zope.org/members/"
- please click "here":http://www.zope.org/members/
- please click "here":http://www.zope.org:2001"
- please click "here":http://www.zope.org:2001
- please click "here":http://www.zope.org:2001/members/"
- please click "here":http://www.zope.org:2001/members/
- please click "here":http://www.zope.org:2001/%20/Members/zope?a=222&b=213&_xc=just%20a%20test
......
......@@ -413,4 +413,3 @@
this document.</p>
</body>
</html>
##############################################################################
#
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# This license has been certified as Open Source(tm).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Digital Creations requests that attribution be given to Zope
# in any manner possible. Zope includes a "Powered by Zope"
# button that is installed by default. While it is not a license
# violation to remove this button, it is requested that the
# attribution remain. A significant investment has been put
# into Zope, and this effort will continue if the Zope community
# continues to grow. This is one way to assure that growth.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
import os
from StructuredText.StructuredText import HTML
files = os.listdir('.')
files = filter(lambda x: x.endswith('.stx'), files)
for f in files:
data = open(f,'r').read()
html = HTML(data)
outfile = f.replace('.stx','.ref')
open(outfile,'w').write(html)
......@@ -31,11 +31,11 @@
<p>.. <a href="#1">[1]</a> (The referring text should be a paragraph, not a header, and
should contain a reference to this footnote, footnote "<a href="#1">[1]</a>".)<p> Some hrefs, in a definition list:</p>
<dl>
<dt> <u>Regular</u></dt>
<dt> _Regular_</dt>
<dd><a href="http://www.zope.org">http://www.zope.org/</a></dd>
<dt> <u>W/trailing punctuation</u></dt>
<dt> _W/trailing punctuation_</dt>
<dd><a href="http://www.zope.org">http://www.zope.org/</a>.</dd>
<dt> <u>W protocol implicit</u></dt>
<dt> _W protocol implicit_</dt>
<dd><a href=":locallink">locallink</a></dd>
<dt> <u>W protocol implicit</u>, alternate</dt>
<dd>"locallink", :locallink</dd>
......@@ -46,4 +46,3 @@ should contain a reference to this footnote, footnote "<a href="#1">[1]</a>".)<p
</p>
</body>
</html>
......@@ -46,4 +46,3 @@
Python 1.5.1 using Microsoft Visual C++ 5.0 in "Release" mode.</p>
</body>
</html>
......@@ -44,4 +44,3 @@
</table>
</body>
</html>
......@@ -205,16 +205,21 @@ class BasicTests(unittest.TestCase):
res = HTML(stxtxt,level=1,header=0)
if res.find(expected)==-1:
print res
print "Text: ",stxtxt
print "Converted:",res
print "Expected: ",expected
raise AssertionError,"basic test failed for '%s'" % stxtxt
def testUnderline(self):
"""underline"""
self._test("xx _this is html_ xx","xx <u>this is html</u> xx")
self._test("xx _this is html_ xx",
"xx <u>this is html</u> xx")
def testEmphasis(self):
""" emphasis """
self._test("xx *this is html* xx","xx <em>this is html</em> xx")
self._test("xx *this is html* xx",
"xx <em>this is html</em> xx")
def testStrong(self):
""" strong """
......@@ -227,12 +232,25 @@ class BasicTests(unittest.TestCase):
'<a href="index_html">index_html</a>')
def testUnderscoresInLiteral(self):
def testUnderscoresInLiteral1(self):
""" underscores in literals shouldn't do unterlining """
self._test("def __init__(self)",
"def __init__(self)")
def testUnderscoresInLiteral2(self):
""" underscores in literals shouldn't do unterlining """
self._test("this is '__a_literal__' eh",
"<code>__a_literal__</code>")
def testUnderlinesWithoutWithspaces(self):
""" underscores in literals shouldn't do unterlining """
self._test("Zopes structured_text is sometimes a night_mare",
"Zopes structured_text is sometimes a night_mare")
def test_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( StructuredTextTests ) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment