Skip to content
This repository has been archived by the owner on Oct 5, 2018. It is now read-only.

Syntax highlighting for tracks #90

Closed
iHiD opened this issue Aug 24, 2017 · 47 comments
Closed

Syntax highlighting for tracks #90

iHiD opened this issue Aug 24, 2017 · 47 comments

Comments

@iHiD
Copy link
Member

iHiD commented Aug 24, 2017

Hi @exercism/track-maintainers

I'm trying to work out syntax highlighting for the solution viewing page on Nextercism. I'm doing this in two ways:

  1. Each track has a default language that all files are rendered in (e.g. any files on the Ruby track will be highlighted as Ruby by default)
  2. Having a mapping of filetypes to languages (e.g. if someone submits a markdown file as part of their solution, we understand to parse this as markdown, not Ruby)

All of the mapping for (1) is done. However, I am only just getting started on (2) and I need to crowd-source it to people that know languages. Could you please post below any files extensions that occur on your tracks, and the correct mapping. e.g.

  • rb = ruby
  • go = go
  • md = markdown

The following are the languages that the syntax highlighter currently supports (ie, the RHS of the = in your comments).

  • markup
  • css
  • clike
  • javascript
  • abap
  • actionscript
  • ada
  • apacheconf
  • apl
  • applescript
  • asciidoc
  • aspnet
  • autoit
  • autohotkey
  • bash
  • basic
  • batch
  • bison
  • brainfuck
  • bro
  • c
  • clojure
  • csharp
  • cpp
  • coffeescript
  • crystal
  • css-extras
  • d
  • dart
  • django
  • diff
  • docker
  • eiffel
  • elixir
  • erlang
  • fsharp
  • fortran
  • gherkin
  • git
  • glsl
  • go
  • graphql
  • groovy
  • haml
  • handlebars
  • haskell
  • haxe
  • http
  • icon
  • inform7
  • ini
  • j
  • jade
  • java
  • jolie
  • json
  • julia
  • keyman
  • kotlin
  • latex
  • less
  • livescript
  • lolcode
  • lua
  • makefile
  • markdown
  • matlab
  • mel
  • mizar
  • monkey
  • nasm
  • nginx
  • nim
  • nix
  • nsis
  • objectivec
  • ocaml
  • oz
  • parigp
  • parser
  • pascal
  • perl
  • php
  • php-extras
  • powershell
  • processing
  • prolog
  • properties
  • protobuf
  • puppet
  • pure
  • python
  • q
  • qore
  • r
  • jsx
  • reason
  • rest
  • rip
  • roboconf
  • ruby
  • rust
  • sas
  • sass
  • scss
  • scala
  • scheme
  • smalltalk
  • smarty
  • sql
  • stylus
  • swift
  • tcl
  • textile
  • twig
  • typescript
  • vbnet
  • verilog
  • vhdl
  • vim
  • wiki
  • xojo
  • yaml

Thank you all 💙

@ErikSchierboom
Copy link
Member

cs = csharp
csx = csharp
fs = fsharp
fsx = fsharp

@Theodus
Copy link

Theodus commented Aug 24, 2017

pony = pony

@ilya-khadykin
Copy link

py = python
java = java
groovy = groovy

@petertseng
Copy link
Member

hs = haskell
rs = rust
yaml = yaml
yml = yaml

@masters3d
Copy link

typescript = ts
swift = swift
objective-c = .h, .m

@iHiD
Copy link
Member Author

iHiD commented Aug 24, 2017

@Theodus Pony isn't in my list and Prism doesn't seem to have a syntax highlighter for it. Is there something that would be close?
@masters3d I imagine .h and .m will be pretty controversial as they're used in multiple. I think I might leave these out and presume if you submit them then you should default to the language of the track you're on. Seem reasonable?

@masters3d
Copy link

masters3d commented Aug 24, 2017

Sounds good. Basic C highlighting should be fine. Objective-C is weird.

@jonmcalder
Copy link
Member

R = r
r = r

@rpottsoh
Copy link
Member

Delphi is not listed as one of the languages, but Pascal is, perhaps Delphi can be aliased in a similar fashion as it was in exercism/exercism#3451 if necessary

For the sake of item 2:
pas = Delphi
dfm = Delphi

These are the only file extensions I am expecting for submitted files.

@ozan
Copy link

ozan commented Aug 24, 2017

None of these are likely to do a good job for MIPS. On the other hand, MIPS code really doesn't need syntax highlighting :)

@ricemery
Copy link
Member

ricemery commented Aug 24, 2017 via email

@mcmillhj
Copy link

SML is also missing from the list of supported languages, but using the Ocaml highlighting would be better than nothing: https://github.com/exercism/exercism.io/pull/3451/files

fun = sml
sig = sml
sml = sml

@Theodus
Copy link

Theodus commented Aug 24, 2017

@iHiD Scala would probably be the closest thing to Pony syntax

@NobbZ
Copy link
Member

NobbZ commented Aug 24, 2017

ending language comment
*.erl erlang main ending for erlang code
*.hrl erlang unlikely to get submitted but has a chance to
*.config erlang when in an erlang context at least; maybe similar to the problem with *.h in C, C++ and Obj-C? Shouldn't get submitted though
*.app.src erlang Shouldn't get submitted
*.app erlang
*.idr (Idris) Haskell is sufficient as fallback though
*.ex elixir
*.exs elixir
*.rs rust
*.go go

That are those that I have to deal with on a more or less daily basis…

@SaschaMann
Copy link

SaschaMann commented Aug 24, 2017 via email

@stevejb71
Copy link

ml, mli = ocaml

@stkent
Copy link

stkent commented Aug 25, 2017

kt = kotlin

@sdavids13
Copy link

kts = kotlin script

@stkent
Copy link

stkent commented Aug 25, 2017

kts = kotlin script

which should map to kotlin in the supported languages list afaik!

@SuperPaintman
Copy link

SuperPaintman commented Aug 25, 2017

dart = dart

@ryanplusplus
Copy link
Member

*.c, *.h -> c
*.lua -> lua

@marnen
Copy link

marnen commented Aug 25, 2017

APL: .apl, .tc
.tc files are GNU APL test cases. They're essentially interactive interpreter session logs, and should probably be highlighted as APL.

Dyalog APL (a popular proprietary interpreter) uses .dyalog, so perhaps we should support that for APL syntax highlighting too.

Doesn't the syntax highlighting library already have a list like this that we can use?

@NobbZ
Copy link
Member

NobbZ commented Aug 25, 2017

Doesn't the syntax highlighting library already have a list like this that we can use?

Nope, Prism is a syntax highlighting framework for the browser written in JavaScript, therefore it doesn't even know about a files ending.

@marnen
Copy link

marnen commented Aug 25, 2017

@NobbZ Except when it does, apparently: http://prismjs.com/plugins/file-highlight/

I don't know if that would be useful to us, but I thought I'd at least point it out.

@NobbZ
Copy link
Member

NobbZ commented Aug 25, 2017

Oh, in general thats a nice one, but it does create additional requests to the server, which needs to be handled as well and therefore create further load. I do think, that predetermining the type and generating appropriate markup is easier for the server than to wait for a roundtrip and do routing, authentication, authorisation and filepicking again.

@marnen
Copy link

marnen commented Aug 25, 2017

@NobbZ Yeah, probably the extra round trip is best avoided, but that plugin presumably contains a list of extension>language mappings...perhaps we could use just that bit from the plugin, instead of essentially reinventing the same list?

@iHiD
Copy link
Member Author

iHiD commented Aug 25, 2017

@marnen Thanks for pointing that out. It seems to only have the following though:

		var Extensions = {
			'js': 'javascript',
			'py': 'python',
			'rb': 'ruby',
			'ps1': 'powershell',
			'psm1': 'powershell',
			'sh': 'bash',
			'bat': 'batch',
			'h': 'c',
			'tex': 'latex'
		};

@NobbZ
Copy link
Member

NobbZ commented Aug 27, 2017

In v1 there is a different highlighter used than in v2. We are currently collecting a list of filename mappings for v2.

But you are right, I can't find lisp in the above list as well. But there are scheme and clojure in the list, so one of those could be used?

@verdammelt
Copy link
Member

RE: could scheme or clojure be used?

They might work - but it depends on whether the highlighter knows keywords in the language. For example in Common Lisp you define a function with defun but it is define in Scheme and defn in Clojure. The basics of the syntax is the same however.

@bzz
Copy link

bzz commented Aug 28, 2017

@iHiD I'm sure you already know about these, but just in case it might help - there are two project that are relevant for programming language identification:

linguist/languages.yml also has extensive information on file extension mapping.

@iHiD
Copy link
Member Author

iHiD commented Jun 21, 2018

Hello everyone. Thank you all for your great work on this.

There are a few outstanding languages. It might be that there is no good choice but I need to put something by them. There are also a few new options here on Prism since we started this process. I would really appreciate it if people could help get this one over the line. @kytrinyx @jackhughesweb - maybe one of you could use your magic tools to open issues on these tracks' maintainers for this too?

  • ceylon
  • cfml
  • coq
  • factor
  • lfe
  • mips
  • purescript
  • racket
  • pharo

Thank you! 💙

@stevejb71
Copy link

Reason track was started recently.

re = reason

@LegalizeAdulthood
Copy link

.h, .hpp, .hxx, .cpp, .cxx are common extensions for C++.

@lpil
Copy link
Member

lpil commented Jun 21, 2018

@stevejb71 Reason also uses the .rei extension

@iHiD
Purescript uses the .purs extension.
LFE uses the .lfe extension.

@iHiD
Copy link
Member Author

iHiD commented Jun 22, 2018

@lpil Thank you :) Do you know which Prism language syntaxes they should use from this list?

@NobbZ
Copy link
Member

NobbZ commented Jun 22, 2018

@iHiD for LFE => "lisp" should be safe, as well as PureScript => Haskell. Reason has its own highlighter in that list.

@bencoman
Copy link

For Pharo...
.st = Smalltalk

@bdw429s
Copy link

bdw429s commented Jun 22, 2018

For the CFML track:

cfm = XML or HTML
cfc = javascript

I don't see XML or HTML above, but surely HTML is something most highlighters support. If not, I wouldn't worry too much about it since I expect most code to be in a CFC and using the script syntax. (CFC's can contain tags, but since these exercises didn't template HTML, it wouldn't make much sense).

@petertseng
Copy link
Member

Greetings. I come bearing news of the Ceylon track.

The only relevant file extension is ceylon

ceylon = ???

Okay so what am I going to put in the ???. I don't know. You could try, in rough order of likelihood to work, (most likely) Kotlin, Scala, Java, C#, C-like, anything else I didn't list (least likely)

Please accept my deep apologies that I cannot offer the time to actually test out any of my proposals; they are utterly wild speculation, worth what you paid for them.

@iHiD
Copy link
Member Author

iHiD commented Jun 22, 2018

@bencoman Thanks for helping :) Is the file-extension for pharo files .st? Just checking I've understood that correctly :)

@bencoman
Copy link

@iHiD, Correct. More broadly, its common to all flavours of Smalltalk, derived from the first two letters of that word. Here is an example...
https://github.com/pharo-project/pharo/blob/development/src/Balloon/BalloonEdgeData.class.st

@mhinz
Copy link

mhinz commented Jun 26, 2018

vim = vim

@catb0t
Copy link

catb0t commented Jul 7, 2018

factor = factor

Linguist information about syntax highlighting for Factor is here https://github.com/github/linguist/blob/master/lib/linguist/languages.yml#L1303

The TextMate bundle (used by Linguist) is https://github.com/factor/factor/blob/master/misc/Factor.tmbundle/Syntaxes/Factor.tmLanguage

@jackhughesweb
Copy link

v = coq
rkt = racket

@kytrinyx
Copy link
Member

kytrinyx commented Oct 4, 2018

It looks like we've sorted what we can here. We also have an open issue to manage this in a slightly more practical way: exercism/exercism#4385

@kytrinyx kytrinyx closed this as completed Oct 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests