[Zope-CMF] STX and long links

Tres Seaver tseaver@palladion.com
Thu, 30 Aug 2001 11:43:38 -0400 (EDT)


On Thu, 30 Aug 2001, Dave Lehman wrote:

> I'm having some problems with creating hyperlinks in STX (Standard Text).
> For example (no, i'm not trying to convert you all-- this is actually what
> I was working on):
> 
> The verse "Ephesians
> 2:8-9":http://bible.gospelcom.net/bible?passage=Ephesians+2:8-9 explains
> that God's grace is our only way to salvation.
> 
> renders as:
> 
> <p>The verse <a href="http://bible.gospelcom.net/bible?passage">Ephesians
> 2:8-9</a>=Ephesians+2:8-9 explains that God's grace is our only way to
> salvation.</p>
> 
> when what I want is:
> 
> <p>The verse <a href
> ="http://bible.gospelcom.net/bible?passage=Ephesians+2:8-9
> &language=english&version=NIV">Ephesians 2:8-9</a> explains that God's
> grace is our only way to salvation.
> 
> It's getting mixed up and ending the hyperlink after the "=" instead of
> waiting for the first whitespace (which is what I want it to do).
> 
> Is this a bug, or does STX have a legitimate reason to sneer at equals
> signs?

It is a bug -- the regular expression which CMF's STX is using to
recognize URLs is deficient.  Here is a patch::

============ Cut here ===================
--- CMFCore/utils.py	20 Jun 2001 02:17:27 -0000	1.15
+++ CMFCore/utils.py	30 Aug 2001 17:36:58 -0000
@@ -501,7 +501,7 @@
         'doc_inner_link',
         ] + _STXDWI.text_types
     
-    _URL_AND_PUNC = r'([a-zA-Z0-9_\@\.\,\?\!\/\:\;\-\#\~]+)'
+    _URL_AND_PUNC = r'([a-zA-Z0-9_\@\.\,\?\=\+\!\/\:\;\-\#\~]+)'
     def doc_href( self
                 , s
                 , expr1 = re.compile( _STXDWI._DQUOTEDTEXT

============ Cut here ===================

We probably need to submit a patch for StructuredText.DocumentClass,
as well (the CMF is trying to work around bugs there).

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com