Re: WG: [Zope] Using Images in Structured Text
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.
This isn't actually working with Zope 2.4.1. It exists a file called Zope/lib/Python/StructuredText/StructuredText.py but there is no definition of the ctag in it. The file that contains this definition is now called ClassicStructuredText.py. but when i change this file it isn't recompliled at the start of Zope ( the StructuredText.py file is ). how can i compile the ClassicStructuredText file / is that the right file? Thanks in advance, Steffen Hausmann -- become who you are
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.
Hi Steffen! Instead of hacking into StructuredText.py, you may want to take a look at my external method http://www.zope.org/Members/Barabbas/stx_to_html , it subclasses and overrides, which is much cleaner. Of course you could copy that part into the original files if it is totally impossible for you to change you stx calls from <dtml-var xyz fmt=structured-text> to <dtml-var "stx_to_html(xyz)"> hth, Danny
participants (2)
-
Danny William Adair -
Steffen Hausmann