Guides/Syntax Coloring/GeSHi Options

From J Wiki
Jump to navigation Jump to search

Choose Highlighting options for GeSHi support

The GeSHi Syntax-highlighter provides the syntax highlighting on Rosetta Code and now supports J.

There are a couple of J features that GeSHi doesn’t currently handle well and the options for handling them each have their pros and cons. One of those features is the control word construct controlword_myjvarname. . For example for_i. or goto_myname. .

The maintainer of GeSHi suggested I should seek guidance from the J community as to which of the following two methods fits best with J and best meets our needs. If you have a preference for one of the two methods please register it either here or on the forum. (Method B is currently being used on Rosetta Code).

Method A

Control keywords specified in the KEYWORDS[1] section of the J GeSHi file as in J Dictionary except for_varname. which is handled as special case using REGEXPS

    • Control words will have the trailing fullstop highlighted as

part of the control word

    • Use of fullstop is/will be consistent with its highlighting at

the end of the names of primitives keywords

    • The for_varname. will be highlighted using a different CSS class

from other Control keywords (re? Vs kw1), but screen appearance should be the same

    • The URLS feature (links keywords to html help page) once

implemented, won't work for the for_varname. keyword

    • Control words will have correct spelling in the KEYWORDS section of

the GeSHi language file for J

Method B

Control keywords specified in the KEYWORDS[1] section of the J GeSHi file without a trailing fullstop. Use PARSER_CONTROL regex to specify that KEYWORDS[1] must have a trailing fullstop, or in the case of "for" a trailing fullstop or a trailing underscore followed by a valid name and a full stop.

    • The trailing fullstop of control words will not be highlighted
    • Display style is highlighted using the same CSS class (kw1) for

all control words

    • The for part of for_varname. would be highlighted as a control word,

and varname part as a variable

    • The GeSHi URLS feature (links keywords to html help page) once

implemented, will work for the for part of the for_varname. keyword

    • Control words will not have correct spelling in the KEYWORDS section of

the GeSHi language file for J

Method A Method B
Option a.png Option b.png

Comments

I vote for Method A. The period is part of the word. Henry Rich


I have a strong preference for Method A. If any technique is devised to highlight variable names that result from extended keywords, it should not break the coloration of the entire keyword from first character through final inflection. -- Tracy Harms


I like Method B better, except for the cautions indicated (trailing dot not highlighted, etc). The ideal for me would be a hybrid, where for_ and the trailing . were one style (maybe bold), and the pronoun was another (maybe italic?). The reason is that the pronoun is "something different" from the rest of the control word, but is still part and parcel of the control word. Of course, in the cases of goto_xyz. and label_xyz. the xyz isn't a pronoun (or even a J name), so that's another degree of inconsistency and argues for Method A (where everything is treated equally).

-- Dan Bron <<DateTime(2010-02-19T12:15:19-0300)>>


My vote is for Method A. Control words are just inflected names and as such are just a class of primitives. "A primary may also be an inflected name" (JDic:dict1). The inflection is part of the word for primitives so Control words shouldn't be treated differently from other primitives. I have some sympathy for the idea of highlighting the variable name separately but for me the other concerns take precedence. -- Ric Sherlock <<DateTime(2010-02-20T13:07:04+1300)>>