Rosetta Code:Village Pump/Syntax highlighting: Difference between revisions

no edit summary
(Haskell syntax highlighting issue with single quote)
No edit summary
 
(39 intermediate revisions by 17 users not shown)
Line 16:
 
--[[User:BenBE|BenBE]] 10:00, 17 July 2011 (UTC)
 
:The snippet fetching has been completed and resulted in about 30k of code snippets in all languages used for highlighting on RosettaCode which are about 100 languages. Most samples are highlighted as text (about 70%), but even then this gives a really nice code base for the project I'm working on. The collection will be available soon under the terms of the GFDL v1.2. More information will be available [http://blog.benny-baumann.de/ in my blog] or on the RosettaCode Planet. :There will be a project related to GeSHi which I'll detail there too.
 
:The snippet fetching has been removed from the RC site again as the purpose for which I added it has ben fulfilled. Stay tuned for updates!
 
:--[[User:BenBE|BenBE]] 22:37, 3 August 2011 (UTC)
 
== 2011/07/05 - GeSHi update to GeSHi 1.0.8.11pre1==
Line 57 ⟶ 63:
Rosetta Code first started using GeSHi for syntax highlighting a long while back, but due to our nature, we quickly discovered, and frequently continue to discover, programming languages which GeSHi does not provide highlighting functionality. Additionally, we've uncovered bugs in various releases of the software, and the GeSHi folks have been welcoming of fixes sent to them.
 
Due to the way language support is managed in GeSHi, it's fairly trivial for someone who can follow PHP syntax to create a PHP file that adds support for the language of their choice. GeSHi's support for [[Oberon-2]], [[Modula-3]] and [[AutoHotKeyAutoHotkey]] is the direct result of contributions by [[User:Mbishop|Mbishop]] and [[User:Tinku99|Tinku99]]. (If you like a language, and it doesn't appear to have syntax highlighting support, I strongly suggest you follow their lead. ;-) )
 
I am now also part of the GeSHi project focusing for now on adding and improving support for programming languages present on Rosetta Code. As a community of language aficionados and enthusiasts, Rosetta Code is a hotbed for opportunities for improving GeSHi, and improvement of GeSHi is extremely helpful for improving the readability code on Rosetta Code. --[[User:Short Circuit|Short Circuit]] 06:43, 18 June 2009 (UTC)
Line 76 ⟶ 82:
Note: AutoHotKey currently has two codes, ahk and autohotkey. When AutoHotKey support was added to GeSHi, it was added with the longer code. (lang codes are derived from the filename.) Since there were already code snippets on RC that used ahk for AutoHotKey, I created a symlink that allowed ahk to be used as a language code as well. This should likely be reversed, meaning instances of the ahk tag need to be replaced with the autohotkey tag. --[[User:Short Circuit|Short Circuit]] 07:01, 18 June 2009 (UTC)
 
'''The list moved to [[Help:Syntax Highlighting]].'''
==Recommended language tag usage==
<div style="clear: both; column-count: 3; -webkit-column-count:3; -moz-column-count:3">
* 4D 4d
* 4DOS Batch 4dos
 
A
 
* ALGOL 60 algol60
* ALGOL 68 algol68
* APL apl
* AWK '''awk'''
* ActionScript '''actionscript'''
* Ada '''ada'''
* Agda2 agda2
* AmigaE amigae
* AppleScript '''applescript'''
* Assembly '''asm''' (for x86)
* AutoHotkey '''autohotkey'''
 
B
 
* BASIC '''qbasic''' '''freebasic''' '''thinbasic''' bbcbasic
* Batch File '''dos'''
* Bc bc
* Befunge befunge
* Brainf*** '''bf'''
 
C
 
* C '''c'''
* C# '''csharp'''
* C++ '''cpp'''
* Caml caml
* Clean clean
* Clojure '''lisp'''
* Cobol '''cobol'''
* ColdFusion '''cfm'''
* Common Lisp '''lisp'''
* Component Pascal '''pascal'''
* Coq coq
 
D
 
* D '''d'''
* Dao dao
* Dc dc
* Delphi '''delphi'''
* DWScript '''delphi'''
 
E
 
* E '''e'''
* EC ec
* ELLA ella
* ESQL '''sql'''
* Eiffel '''eiffel'''
* Emacs Lisp lisp
* Erlang erlang
* Euphoria euphoria
 
F
 
* F f
* F# '''fsharp'''
* FALSE false
* FP fp
* Factor factor
* Fan fan
* Forth forth
* Fortran '''fortran'''
 
G
 
* GAP gap
* Gnuplot '''gnuplot'''
* Go go
* Groovy '''groovy'''
 
H
 
* HaXe haxe
* Haskell '''haskell'''
 
I
 
* IDL '''idl'''
* Icon '''icon'''
* Io '''io'''
 
J
 
* J '''j'''
* JSON json
* JScript.NET jscript
* Java '''java''' '''java5'''
* JavaScript '''javascript'''
* JoCaml jocaml
* Joy joy
* JudoScript judoscript
 
K
 
* Korn Shell korn
 
L
 
* LSE64 lse64
* LaTeX '''latex'''
* LabVIEW labview
* Lisaac lisaac
* Lisp '''lisp'''
* Locomotive BASIC '''locobasic'''
* Logo logo
* Logtalk logtalk
* LotusScript '''lotusscript'''
* Lua '''lua'''
* Lucid lucid
 
M
 
* M4 m4
* MAXScript maxscript
* MIRC Scripting Language '''mirc'''
* MS SQL '''sql'''
* Make '''make'''
* Maple maple
* Mathematica mathematica
* MATLAB '''matlab'''
* Maxima maxima
* Metafont metafont
* Modula-3 '''modula3'''
 
N
 
* NewLISP '''lisp'''
* Nial nial
 
O
 
* OCaml '''ocaml'''
* Oberon-2 '''oberon2'''
* Object Pascal '''pascal'''
* Objective-C '''objc'''
* Octave octave
* Omega omega
* OpenEdge/Progress '''progress'''
* Oz oz
 
P
 
* PHP '''php'''
* PL/I pli
* PL/SQL '''plsql'''
* Pascal '''pascal'''
* Perl '''perl'''
* Perl 6 '''perl6'''
* Pike '''pike'''
* PlainTeX tex
* Pop11 pop11
* PostScript postscript
* PowerShell '''powershell'''
* Prolog '''prolog'''
* Python '''python'''
 
Q
 
* Q q
 
R
 
* R r
* REXX rexx
* RapidQ rapidq
* Raven raven
* Rhope rhope
* Ruby '''ruby'''
 
S
 
* SAS '''sas'''
* SETL setl
* SMEQL smeql
* SNUSP snusp
* SQL '''sql'''
* Scala '''scala'''
* Scheme '''scheme'''
* Script3D script3d
* Seed7 seed7
* Self self
* Slate slate
* Smalltalk '''smalltalk'''
* Standard ML sml
 
T
 
* TI-83 BASIC ti83b
* TI-89 BASIC ti89b
* Tcl '''tcl'''
* Toka toka
* Tr tr
* Transact-SQL '''sql'''
* Twelf twelf
 
U
 
* Unicon '''unicon'''
* UNIX Shell '''bash'''
* UnixPipes '''bash'''
* Unlambda unlambda
 
V
 
* V v
* VBScript vbscript
* Vedit macro language vedit
* Visual Basic '''vb'''
* Visual Basic .NET '''vbnet'''
* Visual Objects visobj
 
W
 
* Wrapl wrapl
 
X
 
* XQuery xquery
* XSLT '''xml'''
* XTalk xtalk
</div>
 
== GeSHi extension self-report ==
Here is a list of the codes currently provided by GeSHi.
<div style="clear: both; column-count: 3; -webkit-column-count:3; -moz-column-count:3">
<lang list></lang>
</div>
 
 
= Non-GeSHi-issues to take care of =
Line 476 ⟶ 247:
== Haskell syntax highlighting issues ==
 
* A syntax highlighting issue with single quotes can be seen here: [[Bitmap/Bézier_curves/Quadratic#Haskell]] and there: [[Conway's_Game_of_Life#Haskell]]
 
== Unix Shell syntax highlighting issues ==
 
* a problem with escaped backticks in strings appears here: [[Simple_database#UNIX_Shell]]
 
 
== OCaml syntax highlighting issues, '''bis''' ==
 
* there is a problem with strings containing double quotes as we can see here [[JSON#OCaml]]
* a similar problem occurs with a double quote inside single quotes (the char '"'): [http://rosettacode.org/mw/index.php?title=S-Expressions&oldid=123055#OCaml S-Expressions#OCaml]
 
* the same problem affects Pike, but it doesn't affect Python. <lang ocaml>'"' ocaml</lang><lang pike>'"' pike</lang><lang python>'"' python</lang>
 
== OCaml syntax highlighting issues ==
 
:: Thanks a lot, BenBE, for the corrections! [[User:Blue Prawn|Blue Prawn]] 23:04, 28 February 2010 (UTC)
 
Here are bugs in the ocaml syntax highlighting
 
* This problem also occurs with fields of structures:
<blockquote>
<lang ocaml>type t = { x:int; y:int } ;;
let v = {x=2; y=3} ;;
print_int (v.x + v.y) ;;</lang>
</blockquote>
:* I disabled OOP Language Handling for OCaml for now. I guess there's some issue in how the magic is done inside the parser that needs to be tweaked ... But otherwise having v.x and v.y marked x and y as methods\fields is desired. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
:: About OOP method are accessed with the character '#' like this "my_obj#my_method param1 param2", but ocaml programmers don't use OO a lot ([[Go_Fish/OCaml]] is the only example on RC). Now if fields are not highlighted I don't feel this as annoying. [[User:Blue Prawn|Blue Prawn]] 23:04, 28 February 2010 (UTC)
 
* there is also something that I consider as an issue, when a function or a constructor follows a module name, these two different entities are colored in the same way, example (from [[Determine_if_Only_One_Instance_is_Running#OCaml|there]]):
<blockquote>
<lang ocaml>Unix.sleep (* function *)
Unix.O_CREAT (* constructor *)
Unix.LargeFile (* a sub-module *)
(ref 3).contents (* the field of a structure *)</lang>
also I don't find it very uniform to colorise elements that follow a module name, and not when the module is opened:
<lang ocaml>open Unix
(* equivalent elements, but here with different colors *)
sleep
O_CREAT
open LargeFile
{ contents = 3 }</lang>
so I think GeSHi should not colorise names after a dot.
This would by the way fix the bug with float operations.
</blockquote>
:* Hard to be done right without contextual parsing (which GeSHi 1.0.X currently doesn't). Should be a bit better with the OOLang handling currently being disabled. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
 
* when one open a module, we can open also open a module inside another module
<blockquote>
<lang ocaml>open Ode
open Ode.LowLevel (* LowLevel is a module inside the module Ode *)</lang>
</blockquote>
:* Need contextual parsing, cf. above. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
 
* Modules that are not part of the standard library are not colorised, ''IMHO'' this is not very uniform and relevant. In editors with ocaml syntax-highlight, all modules are highlighted. (modules from the standard lib have a link to the doc, please keep this feature)
** (identifiers (identifiers to values (often called variables) and identifiers to functions) have the first letter lower case or an underscore)
** a name that starts with an upper-case letter is a module name or a constructor (they are capitalised)
<blockquote>
we can make the difference between a module name and a constructor when it's followed by a dot it's a module name (maybe I'm wrong, but I can't find an example of a constructor followed by a dot)
<lang ocaml>Unix.sleep (* module *)
Some "text" (* a constructor *)</lang>
when there is no dot after it but the keyword <code>open</code> before it, it is a module name:
<lang ocaml>open Unix</lang>
we can also open a submodule:
<lang ocaml>open ExtString.String (* both modules ExtString and String should have the same color *)</lang>
there can be any depth:
<lang ocaml>open M1.M2.M3.M4.M5.M6.M7.M8</lang>
we can also recognize a module name if there is the keyword <code>module</code> before it:
<lang ocaml>module Attrib</lang>
in all other cases it is a constructor.
</blockquote>
:* Could be done, but produces quite messy language files and mostly isn't worth the drawbacks. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
 
* I think constructors should be highlighted too (with another color than modules), (in editors constructors are highlighted).
(see previous paragraph to see when a capitalised word is a module or a constructor)
:* hmmm, I'd like to keep contextual highlighting as much out of the language file as possible. The 1.1.X developement branch can do contextual highlighting\parsing, but this won't work together with the stable 1.0.X branch this site is using. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
 
* [http://caml.inria.fr/pub/docs/manual-ocaml/libref/index_modules.html Modules from the standard library] are not treated the same, some are highlighted with a link to the doc, and some other are not:
<blockquote>
<lang ocaml>Arg
Arith_status
Array
Array1 (* * *)
Array2 (* * *)
Array3 (* * *)
ArrayLabels
Big_int
Bigarray
Buffer
Callback
CamlinternalLazy (* TODO *)
CamlinternalMod (* TODO *)
CamlinternalOO
Char
Complex
Condition
Dbm
Digest
Dynlink
Event
Filename
Format
Gc
Genarray (* * *)
Genlex
Graphics
GraphicsX11
Hashtbl
Int32
Int64
LargeFile (* !!! *)
Lazy
Lexing
List
ListLabels
Make (* !!! *)
Map
Marshal
MoreLabels
Mutex
Nativeint
Num
Obj
Oo
Parsing
Pervasives
Printexc
Printf
Queue
Random
Scanf
Scanning (* * *)
Scanf
Set
MoreLabels
Sort
Stack
State (* * *)
Random
StdLabels
Str
Stream
String
StringLabels
Sys
Thread
ThreadUnix
Tk
Unix (* TODO *)
UnixLabels (* TODO *)
Weak (* TODO *)</lang>
Those tagged with TODO should be added (in particular Unix in priority), the other could be omited, those with a star are modules inside another module for example Array1, Array2, Array3 and Genarray are inside Bigarray, for a root module named Foo the url is <nowiki>http://caml.inria.fr/pub/docs/manual-ocaml/libref/</nowiki>'''Foo'''.html for a module Bar inside Foo the url is <nowiki>http://caml.inria.fr/pub/docs/manual-ocaml/libref/</nowiki>'''Foo'''.'''Bar'''.html
the tags !!! are for modules which url can not be resolved because for example for the module name LargeFile, there are LargeFile modules inside several root modules in Pervasives, in Unix, and in UnixLabels.
</blockquote>
:* I've added some Modules for now. For the star-ed Modules I'd need to have the Parent Module name or the Doc-Link that I should be generating. As each Group requires some overhead I'd suggest linking only those with at least 2 or 3 Submodules in it (e.g. Array) and simply highlighting (without Link) the others. Could you compile me that list? --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
:: Here are the full links of the star'ed modules:
Line 631 ⟶ 270:
Scanning => http://caml.inria.fr/pub/docs/manual-ocaml/libref/Scanf.Scanning.html
State => http://caml.inria.fr/pub/docs/manual-ocaml/libref/Random.State.html
:: [[User:Blue Prawn|Blue Prawn]] 23:04, 28 February 2010 (UTC)
 
 
* not a bug nor an issue, but a suggestion: maybe we could highlight the core OCaml types:
 
<blockquote>
* this type is currently linked to the url [1], which is wrong, the right url is [2]
<lang ocaml>list
<lang ocaml>file_descr
array
[1] http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#TYPEfile_descr
int
[2] http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html#TYPEfile_descr
float (* !!! *)
</lang>
bool
 
char
 
string
* I think that some links could be modified:
unit
<lang ocaml>
int32
int64
nativeint
<fun>
in_channel
out_channel
file_descr
exn</lang>
* I have keep in_channel and out_channel in the list because I think we should use the same color.
* float is a type in contexts where ocaml expects a type and a function in contexts where ocaml expects a function. So we could keep it as a function, or convert it to a type. I'm not sure which is best, but in RC context it seems it is most often the function.</blockquote>
:* Added them, left float as function. Left <fun> alone as this requires some special treatment. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
:: I think that some links could be modified:
file_descr => http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html#TYPEfile_descr
int32 => http://caml.inria.fr/pub/docs/manual-ocaml/libref/Int32.html
int64 => http://caml.inria.fr/pub/docs/manual-ocaml/libref/Int64.html
nativeint => http://caml.inria.fr/pub/docs/manual-ocaml/libref/Nativeint.html
</lang>
:: [[User:Blue Prawn|Blue Prawn]] 23:04, 28 February 2010 (UTC)
 
* not a bug nor an issue, but a suggestion: maybe we could highlight labels (names with a tild before it):
<blockquote><lang ocaml>let my_compare ~left ~right =
(* ... *)</lang>
 
I propose this style (<code>font-weight:bold; color:#339933;</code>):
<span style="font-weight: bold; color: #339933;">~left</span>
</blockquote>
:* Included in the language file, but needs a CSS Addition for class re1 (ocaml only) on RC. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
 
* not a bug nor an issue, but a suggestion: maybe we could highlight polymorphic variants (names with a backtick before it):
<blockquote><lang ocaml>`left (* constructor of a polymorphic variant *)
Left (* constructor of a non-polymorphic variant *)</lang>
''IMHO'' these two kinds of constructors should be highlighted with the same color.
 
I suggest this style (<code>font-weight:bold; color:#993399;</code>):
<span style="font-weight: bold; color: #993399;">Left</span>
<span style="font-weight: bold; color: #993399;">`left</span>
(if the highlight for names following a dot is removed as suggested above, because this is the same color)
</blockquote>
:* Included in language file but needs a CSS Addition for class re2 (ocaml only) on RC. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
 
* This bug is not related to the OCaml syntax (but affects ocaml syntax), GeSHi doesn't handle nested comments (see [[Comments]])
<blockquote><lang ocaml>(* This a comment
(* containing nested comment *)
*)</lang>
just a suggestion, maybe an easy way to handle this would be to match <code>*) ... *)</code>?
</blockquote>
:* Fixed. Now uses recursive regular expressions for comments with fallback for simple string search. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
:: This is very nice, thanks!
:: On the [[Comments]] page we can see other languages that use nested comments, here is the list that I can see:
* Clean
* D with /+ +/
* Haskell
* Mathematica
* Modula-3
* Pop11
* Seed7
* Standard ML
* Ursala
:: Also some that are not nested, but where I can see some bug:
* "perl6", see: [[Comments#Perl_6]]
* There is a bug with phpdoc in PHP: [[Comments#PHP]]
* multiline comments are not handled with Rebol: [[Comments#REBOL]]
:: [[User:Blue Prawn|Blue Prawn]] 23:04, 28 February 2010 (UTC)
 
* The parser brackets ('''[<''' and '''>]''') should be completely highlighted:
Line 712 ⟶ 295:
</blockquote>
:* Tweaked in language file but needs CSS class sy0 to be set for this to show. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
:: Unfortunately this sy0 CSS class is the same than when '''<''' appears alone (the ''lower than'' opperator), and here the '''[''' is CSS'ed in the same way than when it appears alone too. A different class for when they appear un pairs would be better ('''[<''' and '''>]'''). [[User:Blue Prawn|Blue Prawn]] 19:54, 18 August 2011 (UTC)
 
 
 
== Comments highlighting issues ==
 
* On the [[Comments]] page we can see some languages that use nested comments, here is the list that I can see:
-- [[User:Blue Prawn|Blue Prawn]] 21:29, 22 January 2010 (UTC)
** [[Comments#AppleScript]]
** [[Comments#Haskell]]
** [[Comments#Lua]]
** [[Comments#Modula-3]]
** [[Comments#Perl_6]]
** [[Comments#PHP]]
** [[Comments#REBOL]]
** [[Comments#REXX]]
** [[Comments#NetRexx]]
** [[Comments#ooRexx]]
 
==Regression in Tcl Syntax Highlighting==
Line 1,077 ⟶ 675:
BTW: The operators: '&amp;#8804;' and '&amp;#8805;' can be done in html as '&amp;le;' and '&amp;ge;' eg '&le;' and '&ge;';
 
There are a few of others: ne: &ne;, cent: &cent; pound: &pound; deg: &deg;, and: &and;, or: &or;, not: &not;, lceil: &lceil;, lfloor: &lfloor;, times: &times;, divide: &divide; larr: &larr;, rarr: &rarr;, uarr: &uarr;, darr: &darr;, and perp: &perp; <!-- The Algol 68 Report used alefsym: &alefsym;, "&#x226E;", "&#x226F;" and &#x2112; http://en.wikipedia.org/wiki/Van_Wijngaarden_grammar -->. But no HTML entities for □, ○, ⎩, ⎧ (Unicode 5.1) and "⏨" (decimal exponentiation - Unicode 5.2).
 
Detecting all the HTML entity defs (http://php.net/manual/en/function.htmlentities.php) is probably the easiest way of doing things.
 
Trivia: Standard Algol 60 required sup: &sup;, equiv: &equiv;, "&#x2423;" and "&#x23E8;" (decimal exponentiation - Unicode 5.2); The Soviet Algol compiler - used for the Buran Space Shuttle reentry software - even had the character: loz: &loz;, together with support for °&#xB0;, &#x2205;, ±&#xB1; and &#x2207; ... I could never figure out what this [http://en.wikipedia.org/wiki/Behenian_fixed_stars#Table_of_Behenian_Stars diamond &loz;] character was used for!!! The Germans also included the unusual "<font size=5>&#x16ED;</font>" (iron/runic cross), I'm not convinced it was used for multiplication. Probably something used for something mundane like printing train time tables, you would have to be German to understand. :-)
 
More Trivia: Most of the HTML entities appear to have arrived via Adobe fonts from an IBM Selectric typewriter font ball that was popular prior to ASCII 69 becoming a mandated US standard. Some of the HTML entities are fairly weird.
Line 1,322 ⟶ 920:
 
: Update: Submitted to the [http://sourceforge.net/tracker/?func=detail&aid=3303485&group_id=114997&atid=670234 GeSHi issue tracker]. [[User:CRGreathouse|CRGreathouse]] 15:50, 18 May 2011 (UTC)
 
= GeShi power appears to be very limited =
 
Look at this: no recogition of embedded command substitution syntax within the string:
 
<lang bash># this is <lang bash>
echo "$(foo "$(bar "asdf\"")")"</lang>
 
Why is the last closing parenthesis green? WTF?
:Because GeSHi doesn't implement recursive matching of strings with nested shell commands (as this would cause quite some trouble with other places. IF you write up some proper PCRE that properly matches such strings, just provide it to me and I'm happy to include it. --[[User:BenBE|BenBE]] 02:38, 28 January 2012 (UTC)
 
Type that same example above into Vim and it's handled perfectly by Vim's recursive, hierarchical language of syntax highlighting regions.
 
Also, what about this:
 
<lang bash>#
cat <<!
echo while true do ; done if fi
what the hell
!</lang>
 
:Use the more common
:<lang bash>#
cat <<HEREDOC
echo while true do ; done if fi
what the hell
HEREDOC</lang>
:and everything is fine. But if you can provide me with a more complete list of allowed characters in the definition of a HEREDOC spec, I'll try to add it. --[[User:BenBE|BenBE]] 01:12, 28 January 2012 (UTC)
 
Keywords are being highlighted inside a here document, which is verbatim text. Shell expressions can occur in a here document, but only as command substitutions $(...).
:GeSHi as used at RC is a mostly context-free parser. If you want something that's context-aware use GeSHi 1.1.X. But unfortunately you can't mix both versions in one script easily. And since GeSHi 1.0.X has a much broader language support, RC is using the stable 1.0.X version. --[[User:BenBE|BenBE]] 01:12, 28 January 2012 (UTC)
 
Sorry, this is not a usable syntax coloring system.
:Write a better one and come back then. --[[User:BenBE|BenBE]] 01:12, 28 January 2012 (UTC)
:: If I write a better one, will Rosetta switch to it? I have absolutely no use for GeShi (and therefore not for any replacement for GeShi, either) except that it's the only system supported in Rosetta. Why would I waste my spare time hacking on this when I can, like, put my spare time programming cycles into something better, like my own project. If we could use some HTML tags, the problem would be solved. Vim does the syntax highlighting perfectly, and can put out HTML that you can cut and paste into a web page or wiki. Say, maybe the HTML put out by Vim can be machine translated into colorized Wikimedia markup [http://en.wikipedia.org/wiki/Help:Wiki_markup#Coloring_text]. This may be the key to a GeShi-free solution, worth looking into.[[Special:Contributions/192.139.122.42|192.139.122.42]] 01:51, 28 January 2012 (UTC)
::: Well, let me thing about this for a moment ... No, you don't really want this. No. You don't! --[[User:BenBE|BenBE]] 02:25, 28 January 2012 (UTC)
::::: Proof of concept:<br><div class="text highlighted_source" style="border:1pt dashed black;white-space:pre;overflow:auto;background:white;color:black;padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.3em"><code><span style="color: #800090; background-color: #f0f0f0">#include </span><span style="color: #077807; background-color: #f0f0f0">&lt;stdio.h&gt;</span><br><br><span style="color: #912f11; background-color: #f0f0f0; font-weight: bold">char</span> input[] =<br>        <span style="color: #077807; background-color: #f0f0f0">&quot;Character,Speech</span><span style="color: #912f11; background-color: #f0f0f0">\n</span><span style="color: #077807; background-color: #f0f0f0">&quot;</span><br>        <span style="color: #077807; background-color: #f0f0f0">&quot;The multitude,The messiah! Show us the messiah!</span><span style="color: #912f11; background-color: #f0f0f0">\n</span><span style="color: #077807; background-color: #f0f0f0">&quot;</span><br>        <span style="color: #077807; background-color: #f0f0f0">&quot;Brians mother,&lt;angry&gt;Now you listen here! He's not the messiah; &quot;</span><br>                <span style="color: #077807; background-color: #f0f0f0">&quot;he's a very naughty boy! Now go away!&lt;/angry&gt;</span><span style="color: #912f11; background-color: #f0f0f0">\n</span><span style="color: #077807; background-color: #f0f0f0">&quot;</span><br>        <span style="color: #077807; background-color: #f0f0f0">&quot;The multitude,Who are you?</span><span style="color: #912f11; background-color: #f0f0f0">\n</span><span style="color: #077807; background-color: #f0f0f0">&quot;</span><br>        <span style="color: #077807; background-color: #f0f0f0">&quot;Brians mother,I'm his mother; that's who!</span><span style="color: #912f11; background-color: #f0f0f0">\n</span><span style="color: #077807; background-color: #f0f0f0">&quot;</span><br>        <span style="color: #077807; background-color: #f0f0f0">&quot;The multitude,Behold his mother! Behold his mother!&quot;</span>;<br><br><span style="color: #912f11; background-color: #f0f0f0; font-weight: bold">int</span> main()<br>{<br>        <span style="color: #912f11; background-color: #f0f0f0; font-weight: bold">char</span> *s = input;<br>        printf(<span style="color: #077807; background-color: #f0f0f0">&quot;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&quot;</span>);<br>        <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">for</span> (s = input; *s; s++) {<br>                <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">switch</span>(*s) {<br>                <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">case</span> <span style="color: #912f11; background-color: #f0f0f0">'\n'</span>: printf(<span style="color: #077807; background-color: #f0f0f0">&quot;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&quot;</span>); <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">break</span>;<br>                <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">case</span> <span style="color: #077807; background-color: #f0f0f0">','</span>:  printf(<span style="color: #077807; background-color: #f0f0f0">&quot;&lt;/td&gt;&lt;td&gt;&quot;</span>); <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">break</span>;<br>                <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">case</span> <span style="color: #077807; background-color: #f0f0f0">'&lt;'</span>:  printf(<span style="color: #077807; background-color: #f0f0f0">&quot;&amp;lt;&quot;</span>); <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">break</span>;<br>                <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">case</span> <span style="color: #077807; background-color: #f0f0f0">'&gt;'</span>:  printf(<span style="color: #077807; background-color: #f0f0f0">&quot;&amp;gt;&quot;</span>); <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">break</span>;<br>                <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">case</span> <span style="color: #077807; background-color: #f0f0f0">'&amp;'</span>:  printf(<span style="color: #077807; background-color: #f0f0f0">&quot;&amp;amp;&quot;</span>); <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">break</span>;<br>                <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">default</span>:   putchar(*s);<br>                }<br>        }<br>        puts(<span style="color: #077807; background-color: #f0f0f0">&quot;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</span>);<br><br>        <span style="color: #1f3f81; background-color: #f0f0f0; font-weight: bold">return</span> <span style="color: #077807; background-color: #f0f0f0">0</span>;<br>}<br></code></div>[[Special:Contributions/24.85.131.247|24.85.131.247]] 06:59, 28 January 2012 (UTC)
::::::I put <code>text</code> and <code>highlighted_code</code> classes onto the code tag, but nothing. RC's style sheet only asserts this on pre tags. I think that's where the dotted line border style is coming from, without which this is uselessly inconsistent.[[Special:Contributions/24.85.131.247|24.85.131.247]] 07:13, 28 January 2012 (UTC)
::: RC uses GeSHi in part because it's the best out there which can be integrated into PHP (or, at least, has been), and in part because I can trust BenBE enough to ''give him access to the server'', where he handles upgrading GeSHI for me. It reduces my maintenance load. He's also a little easier to work with. Coming in, ranting and raving as you appear to have done, does ''not'' make me want to work with you. --[[User:Short Circuit|Michael Mol]] 03:33, 28 January 2012 (UTC)
 
I'm giving up on defining a syntax coloring scheme for my language, since the official stuff in the GeShi distribution isn't doing the kinds of things that I need to do even a 60% accurate job of it. [[Special:Contributions/192.139.122.42|192.139.122.42]] 23:01, 27 January 2012 (UTC)
: Provide patches upstream and I'm sure to take care of it. Just complaining about the world being stupid doesn't help anyone. --[[User:BenBE|BenBE]] 01:12, 28 January 2012 (UTC)
: GeSHi also has problems with comments in Bash, and with here documents in Ruby. Many of the current syntax-highlighting rules are not correct. --[[User:Kernigh|Kernigh]] 00:32, 28 January 2012 (UTC)
:: And since nobody reported the problems here or upstream its unlikely they will be fixed soon. --[[User:BenBE|BenBE]] 01:12, 28 January 2012 (UTC)
 
= GeShi appears have become 99% transparent =
I just noticed that many code specimen on RC no longer have their Syntax Highlighting apparent. At first I thought it may be just me, but I have the problem in both Firefox and Chrome. So I checked wikipedia and there the Highlighting still appears fine. eg [[wp:ALGOL_68C#The_ENVIRON_and_USING_clauses|ALGOL_68C]], Note the <font color="red">RED</font> where a non standard keyword is used.
By way of contrast <font color="red">ENVIRON</font> in the following is not <font color="red">RED</font> (currently) :
<lang algol68>BEGIN
INT dim = 3; # a constant #
INT a number := 120; # a variable #
ENVIRON EXAMPLE1;
MODE MATRIX = [dim, dim]REAL; # a type definition #
MATRIX m1;
a number := ENVIRON EXAMPLE2;
print((a number))
END</lang>
 
A good place to see the problem is in [[Hello_world]]. eg in [[Hello_world#Python]] & al. I (at least) cannot see any highlighting.
Then when one takes a closer look at the HTML source to the code specimen one finds:
<lang html><pre class="python highlighted_source"><span class="kw1">print</span> <span class="st0">"Goodbye, World!"</span></pre></lang>
 
So it looks like there is a missing style sheet for class="python highlighted_source" & others.
 
Here is the HTML for ALGOL_68:
<lang html><pre class="algol68 highlighted_source">main<span class="sy1">:</span> <span class="br0">(</span><br>
<span class="kw22">printf</span><span class="br0">(</span>$<span class="st0">"Goodbye, World!"</span>l$<span class="br0">)
</span><br><span class="br0">)</span><</pre></lang>
 
A missing style sheet for class="algol68 highlighted_source" maybe?
 
Work around is: think in monochrome! :-)
 
[[User:NevilleDNZ|NevilleDNZ]] 03:49, 20 March 2013 (UTC)
 
Update... today the highlighting is working fine in Algol68 and Python and probably everything else....
 
Problem resolved by some phantom somewhere :-)
 
I note that the wikipedia color schemes are different from rosettacode GeShi color schemes.... Not a big problem, but is there someone somewhere that has proposed a viable "standard" color scheme for syntax highlighting. GeShi itself hints at it, but gedit and vim hint totally different ideas.
 
[[User:NevilleDNZ|NevilleDNZ]] 07:03, 22 March 2013 (UTC)
 
= Highlighting for МК-61 =
I propose to install a syntax highlighting of MK-61/52: [http://pastebin.com/BNByHpac file]. [[User:Русский|Русский]] ([[User talk:Русский|talk]]) 16:02, 11 March 2014 (UTC)
: Or think the highlighting for it is not necessary and the code is clear so? [[User:Русский|Русский]] ([[User talk:Русский|talk]]) 16:09, 12 March 2014 (UTC)
: Do not present the technical opportunities to add new lighting? 19:18, 20 April 2014 (UTC)
:: I think you need to send a pull request if you want to add your language file to GeSHi. The repository is on [https://github.com/GeSHi/geshi-1.0 GitHub]. --[[User:AndiPersti|Andreas Perstinger]] ([[User talk:AndiPersti|talk]]) 06:53, 23 April 2014 (UTC)
::: So, I've finally managed to add a pull request for Phix, any idea how long that will take? [[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 01:00, 25 October 2015 (UTC)
* [https://github.com/GeSHi/geshi-1.0/blob/master/src/geshi/mk-61.php]
*: Is there still someone alive here? When is the update? 14:20, 13 May 2017 (UTC)
 
= AppleScript Comments =
AppleScript '#' comments do not get properly highlighted, nor do nested comments
 
=Tags: lang rsplus vs lang r=
I'm an R user and, like many of the R solutions on this site, when I want to contribute a solution in R, I do what seems to be the natural thing and start my solution with a '''lang r''' tag. This doesn't introduce any special formatting, but I didn't know to expect it to. Recently, I've noticed other R solutions on the site that start their code with '''lang rsplus''' tags and these appear to format the submitted code with nice colours that make R users smile. This raises a few questions that I'd like answered:
 
1) Is there any reason that any one of '''lang r''' or '''lang rsplus''' may be considered the correct option? If so, I'll gladly convert all of my solutions to the correct option.
 
2) Why does '''lang r''' appear to do nothing? Why does it not have the same functionality as '''lang rsplus'''? Is there a template that could be copied to give them the same functionality?
 
3) If the answer to #2 is anything to do with avoiding duplication of work, then is it possible to do a site-wide replacement of one tag for another (e.g. replace all '''lang r''' tags with '''lang rsplus''' tags)? Users would be much less likely to use an incorrect tag if they have never seen it before.
 
As an example of the difference between '''lang r''' and '''lang rsplus''' tags, have a look at the two solutions found at https://rosettacode.org/wiki/Left_factorials#R
--[[User:ReeceGoding|ReeceGoding]] ([[User talk:ReeceGoding|talk]]) 20:03, 18 June 2020 (UTC)
 
= Updating =
Does the site ever update syntax highlighting at all? [[User:Русский|Русский]] ([[User talk:Русский|talk]]) 10:37, 8 March 2021 (UTC)