Skip to content

Commit f36c96b

Browse files
committed
Add 1: "Test Highlights"
1 parent 2d6678f commit f36c96b

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Test Highlights
3+
date: 2015-05-01
4+
tags: syntax, highlighter, tools
5+
---
6+
7+
Compared to other languages, Ruby does not have very good tool support for development. This might not be a problem for many of us, in the end, humans create the code, and not tools.
8+
9+
Nevertheless, it would be better to have better tools. Or at least valid syntax highlighting. The following table shows popular options for code highlighting, but none of them can manage to properly highlight more advanced Ruby features. Here is the:
10+
11+
## Syntax Highlighter Comparison
12+
13+
Editors or Syntax Highlighter | Version | Highlights Ruby Correctly?¹
14+
---------------------------------------------------| ---------------|---------------
15+
[coderay](https://github.com/rubychan/coderay) | 1.1.0 | no. score: 4/5
16+
[ruby mine](https://www.jetbrains.com/ruby/) | 7.1 RM-141.664 | no. score: 4/5
17+
[rouge](https://github.com/jneen/rouge) | 1.8.0 | no. score: 3/5
18+
[emacs](https://www.gnu.org/software/emacs/) | 24.3.1 | no. score: 2/5
19+
[pygments](http://pygments.org/) | 1.6 | no. score: 2/5
20+
[gedit](https://wiki.gnome.org/Apps/Gedit) | 3.10.4 | no. score: 1/5
21+
[prism.js](https://github.com/PrismJS/prism) | 0.0.1 | no. score: 1/5
22+
[rainbow.js](https://github.com/ccampbell/rainbow) | 1.1.9 | no. score: 1/5
23+
[src-highlight](https://www.gnu.org/software/src-highlite/) | 3.1.6 (library: 4:0:0) | no. score: 1/5
24+
[syntaxhighlighter.js](https://github.com/syntaxhighlighter/syntaxhighlighter) | 3.0.83 | no. score: 1/5
25+
[vim](http://www.vim.org/) | 7.4.52 | no. score: 1/5
26+
[atom](https://atom.io/) | 0.192.0 | no. score: 0/5
27+
[highlight.js](https://github.com/isagalaev/highlight.js) | 8.5 | no. score: 0/5
28+
[sublime text](https://www.sublimetext.com/) | 3 Build 3083 | no. score: 0/5
29+
30+
¹ Obviously, passing the test does not necessarily mean that a tool highlights Ruby correctly - but it is an indication.
31+
32+
## The Idiosyncratic Ruby Syntax Highlight Test
33+
34+
# # #
35+
# For Reference
36+
42
37+
"String with #{ :interpolation }"
38+
/regex$/
39+
$/
40+
41+
# # #
42+
# TEST CASE 1: Question Marks
43+
# SHOULD BE HIGHLIGHTED AS: Array of Strings - Operator - String - Operator - String
44+
45+
[?', ?(] ?'a':'b'
46+
47+
# # #
48+
# TEST CASE 2: Percent Format
49+
# SHOULD BE HIGHLIGHTED AS: String - Operator - Array of Numbers
50+
51+
"%d %d %d"%[1,2,3]
52+
53+
# # #
54+
# TEST CASE 3: Space-delimited String
55+
# SHOULD BE HIGHLIGHTED AS: String Delimiter - String
56+
57+
% 5 #
58+
59+
# # #
60+
# TEST CASE 4: Multi-line Regex with Global Variable Interpolation
61+
# SHOULD BE HIGHLIGHTED AS: Regex Delimiter - Regex -
62+
# Interpolation Character (Optional) -
63+
# Global Variable -
64+
# Regex Delimiter - Regex Options
65+
66+
/
67+
$$#$/
68+
/omix
69+
70+
# # #
71+
# TEST CASE 5: Nested Heredoc
72+
# SHOULD BE HIGHLIGHTED AS: Method - String Delimiter - Operator -
73+
# String Delimiter - String - String Delimiter
74+
# String - String Delimiter
75+
76+
puts <<HERE<<<<THERE
77+
foo 42
78+
HERE
79+
bla 43
80+
THERE

0 commit comments

Comments
 (0)