Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Colors!

  • Loading branch information...
commit c3d6fc5af8cf9d67afa572bba363bf0db256a900 1 parent dd62851
@josh josh authored
View
15 lib/linguist/language.rb
@@ -194,6 +194,13 @@ def self.unpopular
@unpopular ||= all.select(&:unpopular?).sort_by { |lang| lang.name.downcase }
end
+ # Public: A List of languages with assigned colors.
+ #
+ # Returns an Array of Languages.
+ def self.colors
+ @colors ||= all.select(&:color).sort_by { |lang| lang.name.downcase }
+ end
+
# Public: A List of languages compatible with Ace.
#
# Returns an Array of Languages.
@@ -214,6 +221,8 @@ def initialize(attributes = {})
raise ArgumentError, "invalid type: #{@type}"
end
+ @color = attributes[:color]
+
# Set aliases
@aliases = [default_alias_name] + (attributes[:aliases] || [])
@@ -269,6 +278,11 @@ def initialize(attributes = {})
# Returns a type Symbol or nil.
attr_reader :type
+ # Public: Get color.
+ #
+ # Returns a hex color String.
+ attr_reader :color
+
# Public: Get aliases
#
# Examples
@@ -434,6 +448,7 @@ def hash
YAML.load_file(File.expand_path("../languages.yml", __FILE__)).each do |name, options|
Language.create(
:name => name,
+ :color => options['color'],
:type => options['type'],
:aliases => options['aliases'],
:lexer => options['lexer'],
View
75 lib/linguist/languages.yml
@@ -17,6 +17,7 @@
# searchable - Boolean flag to enable searching (defaults to true)
# search_term - Deprecated: Some languages maybe indexed under a
# different alias. Avoid defining new exceptions.
+# color - CSS hex color to represent the language.
#
# Any additions or modifications (even trivial) should have corresponding
# test change in `test/test_blob.rb`.
@@ -25,6 +26,7 @@
ASP:
type: programming
+ color: "#6a40fd"
lexer: aspx-vb
search_term: aspx-vb
aliases:
@@ -43,6 +45,7 @@ ASP:
ActionScript:
type: programming
lexer: ActionScript 3
+ color: "#e3491a"
search_term: as3
aliases:
- as3
@@ -51,6 +54,7 @@ ActionScript:
Ada:
type: programming
+ color: "#02f88c"
extensions:
- .adb
- .ads
@@ -71,12 +75,14 @@ AppleScript:
Arc:
type: programming
+ color: "#ca2afe"
lexer: Text only
extensions:
- .arc
Arduino:
type: programming
+ color: "#bd79d1"
lexer: C++
extensions:
- .ino
@@ -84,6 +90,7 @@ Arduino:
Assembly:
type: programming
lexer: NASM
+ color: "#a67219"
search_term: nasm
aliases:
- nasm
@@ -98,6 +105,7 @@ Augeas:
AutoHotkey:
type: programming
lexer: autohotkey
+ color: "#6594b9"
aliases:
- ahk
extensions:
@@ -124,6 +132,7 @@ BlitzMax:
Boo:
type: programming
+ color: "#d4bec1"
extensions:
- .boo
@@ -139,6 +148,7 @@ Bro:
C:
type: programming
+ color: "#555"
overrides:
- .h
primary_extension: .c
@@ -151,6 +161,7 @@ C#:
type: programming
ace_mode: csharp
search_term: csharp
+ color: "#5a25a2"
aliases:
- csharp
extensions:
@@ -160,6 +171,7 @@ C++:
type: programming
ace_mode: c_cpp
search_term: cpp
+ color: "#f34b7d"
aliases:
- cpp
primary_extension: .cpp
@@ -211,6 +223,7 @@ ChucK:
Clojure:
type: programming
ace_mode: clojure
+ color: "#db5855"
primary_extension: .clj
extensions:
- .clj
@@ -219,6 +232,7 @@ Clojure:
CoffeeScript:
type: programming
ace_mode: coffee
+ color: "#244776"
aliases:
- coffee
extensions:
@@ -230,6 +244,7 @@ ColdFusion:
type: programming
lexer: Coldfusion HTML
ace_mode: coldfusion
+ color: "#ed2cd6"
search_term: cfm
aliases:
- cfm
@@ -240,6 +255,7 @@ ColdFusion:
Common Lisp:
type: programming
+ color: "#3fb68b"
aliases:
- lisp
primary_extension: .lisp
@@ -277,6 +293,7 @@ Cython:
D:
type: programming
+ color: "#fcd46d"
extensions:
- .d
- .di
@@ -302,6 +319,7 @@ Dart:
Delphi:
type: programming
+ color: "#b0ce4e"
primary_extension: .pas
extensions:
- .dpr
@@ -325,6 +343,7 @@ Diff:
Dylan:
type: programming
+ color: "#3ebc27"
extensions:
- .dylan
@@ -338,11 +357,13 @@ Ecere Projects:
Eiffel:
type: programming
lexer: Text only
+ color: "#946d57"
extensions:
- .e
Elixir:
type: programming
+ color: "#6e4a7e"
primary_extension: .ex
extensions:
- .ex
@@ -351,6 +372,7 @@ Elixir:
Emacs Lisp:
type: programming
lexer: Scheme
+ color: "#c065db"
aliases:
- elisp
- emacs
@@ -361,6 +383,7 @@ Emacs Lisp:
Erlang:
type: programming
+ color: "#949e0e"
primary_extension: .erl
extensions:
- .erl
@@ -369,6 +392,7 @@ Erlang:
F#:
type: programming
lexer: FSharp
+ color: "#b845fc"
search_term: ocaml
extensions:
- .fs
@@ -378,6 +402,7 @@ F#:
FORTRAN:
type: programming
lexer: Fortran
+ color: "#4d41b1"
primary_extension: .f90
extensions:
- .F
@@ -399,11 +424,13 @@ FORTRAN:
Factor:
type: programming
+ color: "#636746"
extensions:
- .factor
Fancy:
type: programming
+ color: "#7b9db4"
primary_extension: .fy
extensions:
- .fancypack
@@ -411,6 +438,7 @@ Fancy:
Fantom:
type: programming
+ color: "#dbded5"
extensions:
- .fan
@@ -449,11 +477,13 @@ Gettext Catalog:
Go:
type: programming
+ color: "#8d04eb"
extensions:
- .go
Gosu:
type: programming
+ color: "#82937f"
primary_extension: .gs
extensions:
- .gs
@@ -477,6 +507,7 @@ Groff:
Groovy:
type: programming
ace_mode: groovy
+ color: "#e69f56"
primary_extension: .groovy
extensions:
- .gradle
@@ -528,6 +559,7 @@ HaXe:
type: programming
lexer: haXe
ace_mode: haxe
+ color: "#346d51"
extensions:
- .hx
- .hxml
@@ -541,6 +573,7 @@ Haml:
Haskell:
type: programming
+ color: "#29b544"
extensions:
- .hs
- .hsc
@@ -565,11 +598,13 @@ IRC log:
Io:
type: programming
+ color: "#a9188d"
extensions:
- .io
Ioke:
type: programming
+ color: "#078193"
extensions:
- .ik
@@ -584,6 +619,7 @@ JSON:
Java:
type: programming
ace_mode: java
+ color: "#b07219"
extensions:
- .java
- .pde
@@ -600,6 +636,7 @@ Java Server Pages:
JavaScript:
type: programming
ace_mode: javascript
+ color: "#f15501"
aliases:
- js
- node
@@ -658,6 +695,7 @@ Logtalk:
Lua:
type: programming
ace_mode: lua
+ color: "#fa1fa1"
extensions:
- .lua
- .nse
@@ -690,6 +728,7 @@ Markdown:
Matlab:
type: programming
+ color: "#bb92ac"
primary_extension: .matlab
extensions:
- .m
@@ -697,6 +736,7 @@ Matlab:
Max/MSP:
type: programming
+ color: "#ce279c"
lexer: Text only
extensions:
- .mxt
@@ -709,6 +749,7 @@ Mirah:
type: programming
lexer: Ruby
search_term: ruby
+ color: "#c7a938"
extensions:
- .duby
- .mir
@@ -725,11 +766,13 @@ Myghty:
Nemerle:
type: programming
+ color: "#0d3c6e"
extensions:
- .n
Nimrod:
type: programming
+ color: "#37775b"
extensions:
- .nim
- .nimrod
@@ -737,6 +780,7 @@ Nimrod:
Nu:
type: programming
lexer: Scheme
+ color: "#c9df40"
aliases:
- nush
extensions:
@@ -755,6 +799,7 @@ NumPy:
OCaml:
type: programming
ace_mode: ocaml
+ color: "#3be133"
primary_extension: .ml
extensions:
- .ml
@@ -770,6 +815,7 @@ ObjDump:
Objective-C:
type: programming
+ color: "#438eff"
overrides:
- .m
primary_extension: .m
@@ -780,6 +826,7 @@ Objective-C:
Objective-J:
type: programming
+ color: "#ff0c5a"
extensions:
- .j
- .sj
@@ -810,6 +857,7 @@ OpenEdge ABL:
PHP:
type: programming
ace_mode: php
+ color: "#6e03c1"
extensions:
- .aw
- .ctp
@@ -823,6 +871,7 @@ PHP:
Parrot:
type: programming
+ color: "#f3ca0a"
lexer: Text only
primary_extension: .parrot # Dummy extension
@@ -847,6 +896,7 @@ Parrot Assembly:
Perl:
type: programming
ace_mode: perl
+ color: "#0298c3"
overrides:
- .pl
- .t
@@ -873,6 +923,7 @@ PowerShell:
Prolog:
type: programming
+ color: "#74283c"
extensions:
- .pl
- .pro
@@ -880,6 +931,7 @@ Prolog:
Puppet:
type: programming
+ color: "#cc5555"
extensions:
- .pp
filenames:
@@ -887,6 +939,7 @@ Puppet:
Pure Data:
type: programming
+ color: "#91de79"
lexer: Text only
extensions:
- .pd
@@ -894,6 +947,7 @@ Pure Data:
Python:
type: programming
ace_mode: python
+ color: "#3581ba"
primary_extension: .py
extensions:
- .py
@@ -911,6 +965,7 @@ Python traceback:
R:
type: programming
+ color: "#198ce7"
lexer: S
overrides:
- .r
@@ -928,6 +983,7 @@ RHTML:
Racket:
type: programming
lexer: Scheme
+ color: "#ae17ff"
primary_extension: .rkt
extensions:
- .rkt
@@ -945,6 +1001,7 @@ Raw token data:
Rebol:
type: programming
lexer: REBOL
+ color: "#358a5b"
extensions:
- .r
- .r2
@@ -958,6 +1015,7 @@ Redcode:
Ruby:
type: programming
ace_mode: ruby
+ color: "#701516"
aliases:
- jruby
- macruby
@@ -990,6 +1048,7 @@ Ruby:
Rust:
type: programming
+ color: "#dea584"
lexer: Text only
extensions:
- .rs
@@ -1024,6 +1083,7 @@ Sass:
Scala:
type: programming
ace_mode: scala
+ color: "#7dd3b0"
primary_extension: .scala
extensions:
- .sbt
@@ -1031,6 +1091,7 @@ Scala:
Scheme:
type: programming
+ color: "#1e4aec"
primary_extension: .scm
extensions:
- .scm
@@ -1047,6 +1108,7 @@ Scilab:
Self:
type: programming
+ color: "#0579aa"
lexer: Text only
extensions:
- .self
@@ -1055,6 +1117,7 @@ Shell:
type: programming
lexer: Bash
search_term: bash
+ color: "#5861ce"
aliases:
- sh
- bash
@@ -1076,6 +1139,7 @@ Shell:
Smalltalk:
type: programming
+ color: "#596706"
extensions:
- .st
@@ -1085,6 +1149,7 @@ Smarty:
Standard ML:
type: programming
+ color: "#dc566d"
aliases:
- sml
primary_extension: .sml
@@ -1094,12 +1159,14 @@ Standard ML:
SuperCollider:
type: programming
+ color: "#46390b"
lexer: Text only
extensions:
- .sc
Tcl:
type: programming
+ color: "#e4cc98"
extensions:
- .tcl
@@ -1148,6 +1215,7 @@ Textile:
Turing:
type: programming
+ color: "#45f715"
lexer: Text only
extensions:
- .t
@@ -1163,12 +1231,14 @@ Twig:
VHDL:
type: programming
lexer: vhdl
+ color: "#543978"
extensions:
- .vhd
- .vhdl
Vala:
type: programming
+ color: "#ee7d06"
extensions:
- .vala
- .vapi
@@ -1176,6 +1246,7 @@ Vala:
Verilog:
type: programming
lexer: verilog
+ color: "#848bf3"
overrides:
- .v
extensions:
@@ -1183,6 +1254,7 @@ Verilog:
VimL:
type: programming
+ color: "#199c4b"
search_term: vim
aliases:
- vim
@@ -1197,6 +1269,7 @@ VimL:
Visual Basic:
type: programming
lexer: VB.net
+ color: "#945db7"
primary_extension: .vb
extensions:
- .bas
@@ -1234,6 +1307,7 @@ XML:
XQuery:
type: programming
+ color: "#2700e2"
extensions:
- .xq
- .xqm
@@ -1270,6 +1344,7 @@ mupad:
ooc:
type: programming
lexer: Ooc
+ color: "#b0b77e"
extensions:
- .ooc
View
11 test/test_language.rb
@@ -309,6 +309,17 @@ def test_error_without_name
end
end
+ def test_color
+ assert_equal '#701516', Language['Ruby'].color
+ assert_equal '#3581ba', Language['Python'].color
+ assert_equal '#f15501', Language['JavaScript'].color
+ end
+
+ def test_colors
+ assert Language.colors.include?(Language['Ruby'])
+ assert Language.colors.include?(Language['Python'])
+ end
+
def test_ace_mode
assert_equal 'c_cpp', Language['C++'].ace_mode
assert_equal 'coffee', Language['CoffeeScript'].ace_mode
Please sign in to comment.
Something went wrong with that request. Please try again.