[Zope3-Users] Disable raw directive in restructured text

Jonathan dev101 at magma.ca
Thu Mar 15 17:01:26 EDT 2007


----- Original Message ----- 
From: "Florian Lindner" <mailinglists at xgm.de>
To: <zope3-users at zope.org>
Cc: "Jonathan" <dev101 at magma.ca>
Sent: Thursday, March 15, 2007 4:56 PM
Subject: Re: [Zope3-Users] Disable raw directive in restructured text


> Am Donnerstag, 15. März 2007 21:14 schrieb Jonathan:
>> ----- Original Message -----
>> From: "Florian Lindner" <mailinglists at xgm.de>
>> To: <zope3-users at zope.org>
>> Sent: Thursday, March 15, 2007 3:46 PM
>> Subject: [Zope3-Users] Disable raw directive in restructured text
>>
>> > Hello,
>> > I'm using this code to render a rest snippet to HTML:
>> >
>> >    def convertToHTML(self, comment):
>> >        """ Converts a comment from restructured text to HTML. """
>> >        text = unicode(comment.content)
>> >        renderer = ReStructuredTextToHTMLRenderer(text, self.request)
>> >        return renderer.render().strip()
>> >
>> > Since the text in entered by users I want to disable the raw directive
>> > [1].
>> > How can I do this? (only while rendering this text, not globally)
>>
>> How about passing the original (ie. user-entered) ReST data to your 
>> display
>> widget which then strips the 'raw::' string from the rest data before
>> calling convertToHTML?
>>
>> Alternatively, pass an additional arguement to convToHTML which is a flag
>> that tells the routine whether or not to strip the raw command from the
>> passed text string before processing it.
>
> Of course it's possible to strip it before passing the text to the rest
> renderer. But maybe somebody wants to really print .. raw:: html, maybe
> giving an example of the directive. If I would have stripped the raw there
> would be no text at all, but I want the raw to be treated just like any 
> other
> text.

If you want to preserve the raw command, how about swaping the 'raw::' 
directive for a placeholder (eg. ||rw|| ), process the ReST data normally, 
then swap the 'raw::' command back in place of the placeholder?


Jonathan 



More information about the Zope3-users mailing list