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

From Rosetta Code
Content added Content deleted
m (→‎Language tags: removed winbatch as highlighting tag for "DOS Batch File" since it's an entirely different language)
(→‎Relationship Between Rosetta Code and GeSHi: Link to explanation of language files from GeSHi)
Line 12: Line 12:
:It would be nice if there was an example GeSHi file downloadable somewhere (or perhaps even a few of them). The only one I found was at GeSHi web page. I had to cut and paste the source from the browser, and the do quite a lot editing to get newlines etc. fixed. --[[User:PauliKL|PauliKL]] 15:26, 30 June 2009 (UTC)
:It would be nice if there was an example GeSHi file downloadable somewhere (or perhaps even a few of them). The only one I found was at GeSHi web page. I had to cut and paste the source from the browser, and the do quite a lot editing to get newlines etc. fixed. --[[User:PauliKL|PauliKL]] 15:26, 30 June 2009 (UTC)
:: Email them to me at mikemol@gmail.com, and I'll get them tested, staged on RC and committed to SVN as quickly as I can. --[[User:Short Circuit|Short Circuit]] 17:06, 30 June 2009 (UTC)
:: Email them to me at mikemol@gmail.com, and I'll get them tested, staged on RC and committed to SVN as quickly as I can. --[[User:Short Circuit|Short Circuit]] 17:06, 30 June 2009 (UTC)

If anyone else would like to make a language file, look at this explanation of the language file format from the GeSHi site: http://qbnz.com/highlighter/geshi-doc.html#language-files. --[[User:Mwn3d|Mwn3d]] 19:56, 8 September 2009 (UTC)


=C syntax highlight=
=C syntax highlight=

Revision as of 19:56, 8 September 2009

Discuss issues related to the Syntax Highlighting system here. The old page got huge, and it became hard to discern what problems were current.

Relationship Between Rosetta Code and GeSHi

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 AutoHotKey is the direct result of contributions by MBishop and 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. --Short Circuit 06:43, 18 June 2009 (UTC)

So how can I add a language? I have made a GeSHi file for Vedit macro language. Where can I upload it? (I can not test it myself so I don't know if it is OK). I could do a file for RapidQ quite easily, too, since I have Vedit syntax file for it.
It would be nice if there was an example GeSHi file downloadable somewhere (or perhaps even a few of them). The only one I found was at GeSHi web page. I had to cut and paste the source from the browser, and the do quite a lot editing to get newlines etc. fixed. --PauliKL 15:26, 30 June 2009 (UTC)
Email them to me at mikemol@gmail.com, and I'll get them tested, staged on RC and committed to SVN as quickly as I can. --Short Circuit 17:06, 30 June 2009 (UTC)

If anyone else would like to make a language file, look at this explanation of the language file format from the GeSHi site: http://qbnz.com/highlighter/geshi-doc.html#language-files. --Mwn3d 19:56, 8 September 2009 (UTC)

C syntax highlight

I've noticed that the "string" word is highlighted as a type in C; it shouldn't be so. --ShinTakezou 23:00, 3 July 2009 (UTC)

Whitespace at program beginning/end

I just wanted to make sure that this problem doesn't get forgotten now that the thread moved to the archive page. --Ce 23:18, 6 July 2009 (UTC)

I think you're going to have to reiterate exactly what the problem is, and how it manifests itself under the current configuration. --Short Circuit 23:50, 6 July 2009 (UTC)
In
<lang cpp>
int main {}
</lang>
there are additional blank lines,

<lang cpp> int main {} </lang>

which don't appear in
<pre>
int main()
</pre>
which results in
int main()
Those lines shouldn't be there. Currently the only way to get rid of them is to put the beginning/end tag on the same line as the first/last line of the code, which makes editing (and especially modifying existing snippets) unnecessarily hard (especially it's easy to miss an end tag, since it's bolted onto the last line of the code). In addition, it's an inconsistency. The lang tags should work exactly like pre tags, except for syntax hilighting.
The old discussion is in Village Pump:Home/Syntax Highlighting ( archived 2009-06-18 )#Another problem with eating whitespace characters (note that the start of that discussion concerns an older state with a different problem; initially too much was removed). --Ce 10:42, 7 July 2009 (UTC)

Java5 Highlighting

The java5 highlighting removes links to classes when generics are specified for them without a space between the class name and the <. Example: <lang java5>LinkedList<T></lang> "LinkedList" should be a link. If you add a space the link shows up: <lang java5>LinkedList <T></lang> I think a lot of people leave the space out so the highlighting should put a link in with or without the space. --Mwn3d 12:35, 29 July 2009 (UTC)

Language tags

Due to changes I want to implement in the way processing of the lang tag is done, we need to standardize codes for all of the languages currently on Rosetta Code ASAP. Subsequently, all pages need to be scoured for code snippets.

Here is a list of the languages that currently exist on Rosetta code as I write this. Next to each language, place the code for that language. If the code is already established in GeSHi, make it bold. If no code is provided by GeSHi, and no code is currently in use for that language on the wiki, make one up. Once this list is fully populated, all the pages for each language need to be checked, and ensure that the code snippets for that language are correct. (Not sure what to do about command-line one-liners or similar yet, though.)

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. --Short Circuit 07:01, 18 June 2009 (UTC)

  • 4D

A

  • ALGOL 60
  • ALGOL 68
  • APL apl
  • AWK awk
  • ActionScript actionscript
  • Ada ada
  • Agda2
  • AmigaE amigae
  • AppleScript applescript
  • Assembly asm (for x86)
  • AutoHotkey autohotkey

B

  • BASIC qbasic freebasic thinbasic
  • Bc
  • Befunge
  • Brainf*** bf

C

  • C c
  • C sharp csharp
  • C++ cpp
  • Caml
  • Clean clean
  • Clojure
  • Cobol cobol
  • ColdFusion
  • Common Lisp lisp
  • Component Pascal
  • Coq

D

  • D d
  • DOS Batch File dos
  • Dc
  • Delphi delphi

E

  • E e
  • EC
  • ELLA
  • ESQL
  • Eiffel eiffel
  • Emacs Lisp
  • Erlang

F

  • F
  • F Sharp fsharp
  • FALSE
  • FP
  • Factor
  • Fan
  • Forth forth
  • Fortran fortran

G

  • GAP
  • Gnuplot
  • Groovy groovy

H

  • HaXe haxe
  • Haskell haskell

I

  • IDL idl
  • Icon
  • Io io

J

  • J j
  • JSON
  • JScript.NET
  • Java java java5
  • JavaScript javascript
  • JoCaml
  • Joy joy
  • JudoScript

K

  • Korn Shell

L

  • LSE64
  • LaTeX latex
  • LabVIEW
  • Lisaac
  • Lisp lisp
  • Logo logo
  • Logtalk
  • LotusScript lotusscript
  • Lua lua
  • Lucid lucid

M

  • M4 m4
  • MAXScript maxscript
  • MIRC Scripting Language mirc
  • MS SQL
  • Make make
  • Maple
  • Mathematica mathematica
  • MATLAB matlab
  • Maxima
  • Metafont metafont
  • Modula-3 modula3

N

  • NewLISP
  • Nial nial

O

  • OCaml ocaml
  • Oberon-2 oberon2
  • Object Pascal
  • Objective-C objc
  • Octave octave
  • Omega
  • OpenEdge/Progress
  • Oz

P

  • PHP php
  • PL/I
  • PL/SQL plsql
  • Pascal pascal
  • Perl perl
  • Pike
  • PlainTeX tex
  • Pop11 pop11
  • PostScript postscript
  • PowerShell powershell
  • Prolog prolog
  • Python python

Q

  • Q q

R

  • R r R
  • REXX rexx
  • RapidQ rapidq
  • Raven
  • Rhope
  • Ruby ruby

S

  • SAS sas
  • SETL
  • SMEQL
  • SNUSP
  • SQL sql
  • Scala scala
  • Scheme scheme
  • Script3D
  • Seed7
  • Self
  • Slate slate
  • Smalltalk smalltalk
  • Standard ML sml (ocaml?)

T

  • TI-83 BASIC
  • TI-89 BASIC
  • Tcl tcl
  • Toka
  • Tr
  • Transact-SQL
  • Twelf

U

  • UNIX Shell bash
  • UnixPipes
  • Unlambda

V

  • V v
  • VBScript
  • Vedit macro language vedit
  • Visual Basic vb
  • Visual Basic .NET vbnet
  • Visual Objects

W

  • Wrapl

X

  • XSLT
  • XTalk

Here is a list of the codes currently provided by GeSHi.

<lang list></lang>

OCaml for Standard ML?

It has been suggested to use the OCaml syntax highlighting for Standard ML, and some SML code has been changed to OCaml highlighting already. While the languages are similar, they have many differences in keywords and stuff, and I feel that Standard ML should have a separate highlighting scheme. For example, SML has "datatype" keyword and OCaml does not; logical operators are "andalso" and "orelse" instead of "&&" and "||"; pattern matching is "case ... of" instead of "match ... with"; the "fn" keyword; and lots of other stuff. If I have time I could try to translate the OCaml GeSHi language file into SML; but I am reluctant to do so as I do not own a copy of the Definition of Standard ML, and so I am not confident I will get everything. --76.91.63.71 08:22, 19 July 2009 (UTC)

Sounds reasonable. Grepping around, I find that the list of keywords is this:
and abstype as case datatype else end eqtype exception do fn fun functor funsig handle if in include infix infixr lazy let local nonfix of op open overload raise rec sharing sig signature struct structure then type val where while with withtype orelse andalso
This list was extracted directly from the lexer's keyword table in the source to the SML/NJ implementation, so it should be complete and accurate. I've not categorized their meaning at all. —Donal Fellows 13:46, 19 July 2009 (UTC)
If the languages really are that similar, copy the language file, adjust it for any differences, and send it to me. I'll see that it gets added in as a proper language (and winds up in GeSHi upstream, as well.) --Short Circuit 14:47, 20 July 2009 (UTC)