"Simon" == Simon Michael <simon@joyful.com> writes:
Simon> that's right. I think WikiForNow solves this specific Simon> problem, and it's one of the changes I hope to get into Simon> zwiki 1.0. If you're in a hurry you might want to check Simon> what Ken did (and send me a patch if it's easy :). Ok, got it. I added a function to ZWikiPage.py that calls the wikilink substitutions *unless* you are in a PRE environment. Thanks to Greg Jorgensen <greg@pdxperts.com> on c.l.python who suggested the method used below. Below is the diff on ZWikiPage.py from v0.8.1. I haven't submitted a diff before (I just ran 'diff orig new') so if there is a more appropriate syntax, please let me know. Form all of my tests, it works as desired. A word of warning though, I believe the re objects use some methods not available in earlier releases of python. I have only tested this on Zope-2.3.2 with Python-2.1. 228a229,242
#this function replaces wikilinks unless in an html 'pre' environment def _sub_wikilinks_unless_code(self, s): rgx = re.compile(r'(<pre>.*?</pre>)', re.DOTALL+re.IGNORECASE) chunks = rgx.split(s) out = "" for chunk in chunks: if chunk[0:5].lower() != '<pre>': # Not in a code environment; do wikilinks chunk = re.sub(interwikilink, self._interwikilink_replace, chunk) chunk = re.sub(wikilink, self._wikilink_replace, chunk) out = out + chunk
return out
241,242c255 < t = re.sub(interwikilink, self._interwikilink_replace, t) < t = re.sub(wikilink, self._wikilink_replace, t) ---
t = self._sub_wikilinks_unless_code(t)
252,253c265 < t = re.sub(interwikilink, self._interwikilink_replace, t) < t = re.sub(wikilink, self._wikilink_replace, t) ---
t = self._sub_wikilinks_unless_code(t)
264,265c276 < t = re.sub(interwikilink, self._interwikilink_replace, t) < t = re.sub(wikilink, self._wikilink_replace, t) ---
t = self._sub_wikilinks_unless_code(t)
Happy wikiing, John Hunter