Skip to content
Prev 173878 / 398503 Next

R-code in html help pages: syntax highlighting

On 3/16/2009 1:49 PM, Jose Quesada wrote:
This needs two things:  making the highlight program available to R, and 
then adding it to the Rd to HTML conversion code.  In current releases 
that conversion is done in Perl code, but with R 2.9 an R-based 
converter will be available (but not used by default; too many CRAN 
packages have too many errors in their Rd files, and the new converter 
is more sensitive to such things).  So sometime after 2.9.0 is released, 
it would seem like a reasonable project to modify the conversion to 
allow for syntax highlighting.

One likely complaint is that the highlighting will be inaccurate. 
Typically highlighters just have a list of things they know to be 
important names, they don't actually take scoping rules into account (so 
mean gets highlighted as a built in function even when used as

mean <- (x + y)/2

for example).  So it would be interesting if someone wanted to do the 
work to make a syntax highlighter that was accurate.  I'd say the R core 
work on something like this would be to provide the hook for a user to 
link in their own favourite highlighter; I doubt if we'd want to take on 
the bitching that the inaccurate highlighting would attract.

Duncan Murdoch


There is highlight