I'd like to know whether there's a way to get Pharo's syntax highlighting in a web app coded in Iliad.

Actually, the framework shouldn't matter, as what I'd need is a plain HTML string of the sort:

<span style="color: rgb(102, 0, 0);">^</span> Set <span
style="color: rgb(0, 0, 153);">withAll:</span> <span
style="color: rgb(102, 0, 0);">self</span>

I'm guessing this is not going to be trivial at all... :)

有帮助吗?

解决方案

We wrote a small, but rather complete syntax highlighter in Pharo for Seaside. It takes a method, parses it and outputs annotated html. You only have to specify some rules in css to change the color of the different AST nodes (selectors, strings, symbols, numbers, keywords, variables).

You will find a complete example in the WebDoc project on squeaksource. Look for the SourceFormatter class, everything you need is there.

其他提示

Pier supports syntax highlighting. An example can be found here: http://book.seaside.st/. This is implemented in the package Pier-Shout (see Lukas Renggli's SqueakSource repository).

There is also a smalltalk lexer for pygments which has a bit more penetration than the smalltalk based alternatives.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top