[Zope-CMF] CMFDocument STX trailing punctuation bug?

David (Hamish) Harvey david.harvey@bristol.ac.uk
Sat, 07 Sep 2002 20:00:46 +0100


Colin,

--On Saturday, September 07, 2002 19:52:58 +0000 Colin Leath 
<cleath@postmark.net> wrote:

> I am not able to use STX URLS with trailing punctuation in a
> CMFDocument:
> e.g.:
> _W/trailing punctuation_ --
> "http://www.zope.org/":http://www.zope.org.
> in that case, the period is incorporated into the URL.
>
> This works for me when I create non-cmf documents and call them with
> dtml-var fmt="structured-text"

I refer you to my previous response when you asked this question:

http://lists.zope.org/pipermail/zope-cmf/2002-September/015029.html

The problem is known, and is the result of, if I understand correctly, a 
piece of legacy code in CMF which gets in the way of the proper processing 
of structured text. I've just added a followup to the collector item with a 
patch which fixes the bug *for me*. It may have side effects which I 
haven't noticed. Also I haven't tested it against even the released version 
of CMF 1.3, so ymmv.

If you don't grok "patch", find the place in CMFCore/utils.py which looks 
like this:

                 , expr2 = re.compile( _STXDWI._DQUOTEDTEXT
                                     + r'(\,\s+)'
                                     + _URL_AND_PUNC
                                     + _STXDWI._SPACES
                                     ).search

and replace it with this:

                 , expr2 = re.compile( r"[\,\.\?\!\;]+" ).match



>
> Also the following (an excerpt from an stx howto) is not underlined
> in a CMFDocument stx, but works with other ways of calling stx:
>
> .. [1] _(The referring text should be a paragraph, not a header, and
>     should contain a reference to this footnote, footnote "[1]".)_

Can't help with this I'm afraid. I've noticed some odd behaviour, and it 
likely has a similar cause to the above. I use stx quite a lot, so I may 
get round to looking at this in a couple of months.

> I assume this is a known issue?
>
> as a workaround I've been putting a space at the end of URL:
>
> "joycevedral.com":http://joycevedral.com ,

Yeah, it's ugly, though, isn't it!

> Why the difference in STX capabilities depending on where it's used
> (dtml, vs zpt, vs CMFDOC)? I've started looking in the code and my
> only initial guess is the "level" specification.

The STX functionality is wrapped by a class (CMFDocumentClass) in 
CMFCore/utils.py - for what reason I don't personally know. I'd imagine 
that "level" just controls which HTML header level the STX top level 
corresponds to (but that's a guess). I'm pretty sure it's not causing what 
you're seeing here.

Cheers,
Hamish