[erlang-questions] Syntax highlight erlang code with erlang
Mats Cronqvist
mats.cronqvist@REDACTED
Tue May 29 16:25:27 CEST 2007
Richard Carlsson wrote:
> Petter Larsson XA (TN/EAB) wrote:
>> I would actually prefer doing it in erlang code, soo I can create links
>> fo other filer etc. when possible.
>>
>> Doesn't anyone have an example code of highligting erlang code with
>> erl_syntax etc.
>
> I don't have any example code at hand, but you can do it fairly easily,
> the following way:
>
> 1. Traverse the syntax tree (use erl_syntax:subtrees/1) and add
> annotations (erl_syntax:add_ann/2) on nodes of interest.
>
> 2. Use erl_prettypr:format/2 and pass it a hook function that adds
> additional markup depending on the annotation. (See the
> documentation for a trivial example.)
>
i have code that does exactly this. i intend to post it on google code shortly.
there are some issues;
* "non-syntactic" macros are not handled well.
* code is re-indented (IMHO a feature, since improperly indented code becomes
legible)
* keywords such as "case" and "catch" can not be marked up(?)
mats
More information about the erlang-questions
mailing list