Zope Zone Navigation
 
Document Actions
  • Print this page
  • Add Bookmarklet

Syntax highlighting code tags

Up to Plone / CMF

Syntax highlighting code tags

Posted by Jean-sebastien Guay at January 18. 2005
Hello,

I have done the Product example in the Plone Book (http://docs.neuroinf.de/PloneBook/ch12.rst) which implements a "Source Code" document type and does syntax highlighting on the code using SilverCity (http://silvercity.sf.net/). That's great, but I'd like to take it a step further.

I'd like to be able to put normal HTML code tags and have the code inside be syntax highlighted by SilverCity. I imagine there's a way to have Plone intercept a given tag, take its contents, run a Python method on it and put the returned value in its place... But I have no idea where to start.

What I have for now :

... document ...
<code language="python">
... python code ...
</code>
... rest of document ...

Then, take what's between <code> and </code>, put it into a raw_code variable, and put the language="..." value into a language variable, and call this method :

html, language = generate_html(raw_code, language, "";)

as in the Plone Book example, and replace the <code>...</code> block in the document by the returned html variable.

What I need help on is the step where I'd take what's between the tags, and then when I'd replace it with the return value. I have no idea how to do that. (It doesn't help that I'm pretty new to Zope and Plone, so I don't even know if it's possible)

Any help would be appreciated.

Syntax highlighting code tags

Posted by Jake at January 19. 2005
Take a look at the Zope Cookbook as I think it does some of what you want to do.

Jake
Powered by Ploneboard
 

Home Discussions Plone / CMF Syntax highlighting code tags