[Zope] Including images into stx

Tom Deprez Tom Deprez" <tom.deprez@uz.kuleuven.ac.be
Mon, 4 Mar 2002 14:42:57 +0100


Thanks Mike,

Meanwhile I found the problem in the stx_to_html code.

Just for other people who might get into the same problem:

change the code: st = StructuredText.Basic( text ) into
st=StructuredText.Basic( text.document_src() )

and all things will work out fine.

Regards, Tom

----- Original Message -----
From: "Mike Renfro" <renfro@tntech.edu>
To: "Tom Deprez" <tom.deprez@uz.kuleuven.ac.be>
Cc: <zope@zope.org>
Sent: Friday, March 01, 2002 10:28 PM
Subject: Re: [Zope] Including images into stx


> On Fri, Mar 01, 2002 at 07:20:15PM +0100, Tom Deprez wrote:
>
> > Are there other ways to include images inside stx?
>
> This is an ugly, ugly, ugly solution, but it works for my limited
> needs (see
> http://www.cae.tntech.edu/help/unix/x11/putty_xwin32_tunnelling for an
> example).
>
> In the directory lib/python/StructuredText, find the file
> StructuredText.py -- edit it as follows:
>
> Change the 'def ctag' stanza to something like:
>
> def ctag(s,
>          em=regex.compile(
>              ctag_prefix+(ctag_middle % (("*",)*6) )+ctag_suffix),
>          strong=regex.compile(
>              ctag_prefix+(ctag_middl2 % (("*",)*8))+ctag_suffix),
>          image=regex.compile(
>              ctag_prefix+(ctag_middl2 % (("-",)*8))+ctag_suffix),
>          under=regex.compile(
>              ctag_prefix+(ctag_middle % (("_",)*6) )+ctag_suffix),
>          code=regex.compile(
>              ctag_prefix+(ctag_middle % (("\'",)*6))+ctag_suffix),
>          ):
>     if s is None: s=''
>     s=gsub(strong,'\\1<strong>\\2</strong>\\3',s)
>     s=gsub(image,'\\1<center><img src="\\2"></center>\\3',s)
>     s=gsub(under, '\\1<u>\\2</u>\\3',s)
>     s=gsub(code,  '\\1<code>\\2</code>\\3',s)
>     s=gsub(em,    '\\1<em>\\2</em>\\3',s)
>     return s
>
> In my copy of the file, this is right above the 'class
> HTML(StructuredText):' declaration, and all I've changed is inserting
> an image= line into the def, and a corresponding gsub line shortly
> thereafter.
>
> Now, anytime I put --some_image_name-- in structured text, I get a
> centered image. Example from above:
>
> Start up X-Win32, and cancel out of the **New Connection Wizard**.
> Right-click the X-Win32 icon in your system tray, and select
> **XConfig**. Select the Security tab and add 127.0.0.1 to the
> X-Host list. Check the boxes labeled **Access Control** and **Use
> XAuth**, then click the **OK** button at the bottom.
> --xwin32_security_tab_gif--
>
> As I said above, ugly, ugly, ugly. Images blindly centered; no alt,
> height, or width tags; etc. Also breaks anytime I upgrade Zope. And
> did I mention it was ugly? But it does at least work.
>
> --
> Mike Renfro  / R&D Engineer, Center for Manufacturing Research,
> 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu