[Zope] Using Images in Structured Text
Mike Renfro
renfro@tntech.edu
Fri, 14 Sep 2001 09:39:58 -0500
On Fri, Sep 14, 2001 at 12:13:33PM +0200, Severin Wiedemann wrote:
> I want to use the img-Style in DTML-Documents which I include in
> other Documents via the <dtml-var xyz fmt=structured-text> command.
This is a hack, one that doesn't provide for alt text, and doesn't use
exactly the same tag structure that you want, but it's a start, and
may spur someone into showing a better solution:
in StructuredText.py, change the ctag function to:
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
This does allow for you to insert images with --image_object-- tags in
the structured text. As I said, no alt tags currently, but it's a
start. It will revert back to old behavior on each Zope upgrade if you
do it exactly this way, but I'm sure someone else can show how to turn
it into a monkey-patch or some other improvement.
--
Mike Renfro / R&D Engineer, Center for Manufacturing Research,
931 372-3601 / Tennessee Technological University -- renfro@tntech.edu