[Pharo-project] File Out html with Syntax Highlighting

Levente Uzonyi leves at elte.hu
Wed Feb 10 21:11:48 EST 2010

On Wed, 10 Feb 2010, Nathan Tuttle wrote:

> I find it very useful when learning a language to see the code accurately
> syntax highlighted on a web page when a snippet is shown. I want to design a
> fileout method that will allow developers to file out code with html to put
> into a web page.
> I know I need to use RBFormatter; any ideas on where to go from here? Where
> do I get a codestream for example?

In Squeak there's a "copy html" menu item in the context menu of 
StringHolder (available in Browser, Workspace, etc.) which copies the 
contents as html to the clipboard. If you just want a few code snippets 
with syntax highlight you can use this (the syntax highlight is provided 
by Shout).

If you need something more complex, you can still use Shout to higlight 
your code (which will give you Text objects) and Text >> #printHtmlOn: to 
convert it to html.

Note that both the "copy html" menu item and the Text to html conversion 
was removed from Pharo so you have to roll your own if you need it. Syntax 
highlighting can still be done with Shout.


> thanks

More information about the Pharo-dev mailing list