[Zope3-Users] Disable raw directive in restructured text
Florian Lindner
mailinglists at xgm.de
Thu Mar 15 16:56:43 EDT 2007
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.
Regards,
Florian
More information about the Zope3-users
mailing list