Recently changes have been made to the syntax highlighter used in the forums on the main website. Rather than just apply a generic highlighting template it will attempt to accommodate the preferred programming language of the member. However, sometimes members solve a problem in a different language, or wish to give examples of code that works in more than one language in the same post. So it is possible to override by using the tag
.
Support is currently limited to the following languages (the term found in the bracket contains the keyword that language must be set to):
APL/J/K (apl, j, or k) [alias for text]
BASIC (basic)
C/C++ (c++)
C# (c#)
Delphi (delphi)
Haskell (haskell)
Java (java)
Pascal (pascal) [alias for delphi]
Perl (perl)
PHP (php)
Python (python)
Ruby (ruby)
TCL (tcl)
TECO (teco) [alias for text]
If your language is not in the list it will default to generic (which is an adapted form of javascript).
Although I may add support for other languages over time it is essential that we get a workable system before dealing with the details. So please do not use this thread to bombard me with, "Please add support for X" requests.
One thing I can offer at this stage is the use of aliases. I simply do not know enough programming languages to make these calls myself, but if members tell me that language X uses almost identical syntax to a currently supported language then I can at least make their language adopt that particular highlighting template.
However, once we have a reliable system I will open up the options for more languages. I must stress that when we get to this stage the responsibility will fall on you, the members, requiring a general template to be adapted for their language. But more information about this will be published when we get to that point.
In the meantime please report any glitches or general comments in this thread.
Good point, stihn263. I've just modified the script so that if a member is quoted and they've left the tag as [ code ], then it will insert the member's preferred language. If the member's language is not currently supported then the parser will revert to generic, but the advantage is that if support is added in future that quote should work properly.
The problem with tweaking scripts is that flattening the bump in the carpet in one place causes it to appear somewhere else in the room. Please let me know if anything starts misbehaving.
hi,
it should be possible to disable syntax highlighting completely. the generic template doesn't work good on TECO code and I really don't want to bother you to write one which does (if that's even possible with your current system)
As far as I can see Delphi syntax is in fact the same as Pascal. (Delphi is in fact Pascal)
So you could let both be rendered by the Delphi highlighting.
War ruins the life and health of untold numbers of innocent children.
In lieu of full Lua support (which I'd be happy to help with if desired), I'd like to ask that Lua be aliased to text, since otherwise the odd comment style (eliding some detail, "--" for line-based and "--[[" to "]]" for block-based) causes some errors when using the default JavaScript-based highlighter. (Namely, unmatched quotation marks [e.g. in contractions] inside comments create an unterminated string. See my post for problem #058 for an example.) Thanks!
I wonder how hard it would be to use GeSHi syntax highlighter. That would give you support for 90+ languages. And it would work with TCL, which I've used for most of my solutions.
Actually, I use the GeSHi engine, but due to the way that the forum is parsed it requires a little work to integrate languages. I've just added support for TCL.
Yes, TECO does it, but APL, J, K, and text still have no effect. But woe, when the code is hidden, it is announced as a TECO code. Oh yeah, I did perpetrate some short programs in TECO a-noise-on-the-line-language, but that was so loooooooooong ago... These days I'd rather die than be accused of authoring a piece of TECO code. So I have chosen the lesser evil and switched back to the colorful
.
The right thing would be for [code=mathematica] to switch off the highligting, without any detrimental side effects, such as being forced to go incognito under the name of some other programming language. Mathematica code does not need highlithing for presentation, it is quite readable in black'n'white, without any bold or italic keywords, or any other visual effects, or whatever.
Perhaps the simplest solution would be to make no-highlithing-at-all the default syntax highlighting. Yes, I know about the dangers of tweaking scripts, as "euler" aptly decribes them:
"The problem with tweaking scripts is that flattening the bump in the carpet in one place causes it to appear somewhere else in the room."
But surely, the decision "I don't know what to do, so I will do nothing at all" cannot be so hard to implement, even in a script all tangled up from numerous additions, modifications, tweaks and kludges?