[Zope-dev] Structured text <img> html tag not working properly

Max M maxm at mxm.dk
Wed Nov 12 15:52:55 EST 2003


Chris McDonough wrote:

 > It's not a good idea to mix HTML and STX.. STX (at least using the
 > DocumentWithImages class for the document) has its own notation for
 > including image, e.g.
 >
 >     "DTML error message indicating that it cannot find a
 >     variable.":img:7-1:Figures/7-1.png



Yes. But I don't think that the image tag is the problem. I tried to 
change the HTML factory in StructuredText.py

from:

def HTML(aStructuredString, level=1, header=1):
     st = Basic(aStructuredString)
     doc = DocumentImages(st)
     return HTMLNGImages(doc,header=header,level=level)

to:

def HTML(aStructuredString, level=1, header=1):
     st = Basic(aStructuredString)
     doc = Document(st)
     return HTMLNG(doc,header=header,level=level)

So that it would use the old class.

But that changed nothing. It still rendered the html image tag as an error.

Also in the DocumentWithImages.py there is the regex:

     def doc_img(
         self, s,
         expr1=re.compile('\"([ 
_a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+)').search,
         expr2=re.compile('\"([ 
_a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+):([a-zA-Z0-9_\-.:/;,\n\~]+)').search
         ):

Suggesting at least that images should have the ":img:" to be recognised 
as an image tag.

So my second guess was that it is the in the ctag() function at line 335 
in ClassicStructuredText.py that the problem was. But I cannot find any 
problems with the regexs. Also a diff didn't show any significant 
changes in that file from 2.51 to 2.61

I don't understand it. Inline code should 'look like this'.

If there is no space before, it should not render as code.

ie. a tag='like this' should not render as code as there is no 
whitespace before it.

To quote the source:

- Text enclosed single quotes (with white-space to the left of the
   first quote and whitespace or punctuation to the right of the second 
quote) is treated as example code.


 > It was only by accident that using HTML tags to place images into STX to
 > work for you, unfortunately.


Ay, that sucks. Customers have been using it for 2-3 years now. And they 
have many many documents. I could write a converter, for converting it 
into the new image tag, but that would suck too.



regards Max M





More information about the Zope-Dev mailing list