Skip to content

Commit 9784347

Browse files
committed
syntax highlighting
1 parent a3a4107 commit 9784347

File tree

1 file changed

+111
-111
lines changed

1 file changed

+111
-111
lines changed

README.md

Lines changed: 111 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ UTF-8 is the preferred source file encoding.
7979

8080
If using a module system (CommonJS Modules, AMD, etc.), `require` statements should be placed on separate lines.
8181

82-
```coffeescript
83-
require 'lib/setup'
84-
Backbone = require 'backbone'
85-
```
82+
```coffeescript
83+
require 'lib/setup'
84+
Backbone = require 'backbone'
85+
```
8686
These statements should be grouped in the following order:
8787

8888
1. Standard library imports _(if a standard library exists)_
@@ -96,17 +96,17 @@ Avoid extraneous whitespace in the following situations:
9696

9797
- Immediately inside parentheses, brackets or braces
9898

99-
```coffeescript
100-
($ 'body') # Yes
101-
( $ 'body' ) # No
102-
```
99+
```coffeescript
100+
($ 'body') # Yes
101+
( $ 'body' ) # No
102+
```
103103

104104
- Immediately before a comma
105105

106-
```coffeescript
107-
console.log x, y # Yes
108-
console.log x , y # No
109-
```
106+
```coffeescript
107+
console.log x, y # Yes
108+
console.log x , y # No
109+
```
110110

111111
Additional recommendations:
112112

@@ -119,24 +119,24 @@ Additional recommendations:
119119

120120
- _(Do not use more than one space around these operators)_
121121

122-
```coffeescript
123-
# Yes
124-
x = 1
125-
y = 1
126-
fooBar = 3
122+
```coffeescript
123+
# Yes
124+
x = 1
125+
y = 1
126+
fooBar = 3
127127

128-
# No
129-
x = 1
130-
y = 1
131-
fooBar = 3
132-
```
128+
# No
129+
x = 1
130+
y = 1
131+
fooBar = 3
132+
```
133133

134134
- Do not use spaces around the `=` sign when used to indicate a default parameter value
135135

136-
```coffeescript
137-
test: (param=null) -> # Yes
138-
test: (param = null) -> # No
139-
```
136+
```coffeescript
137+
test: (param=null) -> # Yes
138+
test: (param = null) -> # No
139+
```
140140

141141
<a name="comments"/>
142142
## Comments
@@ -156,18 +156,18 @@ Each line of a block comment starts with a `#` and a single space, and should be
156156
157157
Paragraphs inside of block comments are separated by a line containing a single `#`.
158158
159-
```coffeescript
160-
# This is a block comment. Note that if this were a real block
161-
# comment, we would actually be describing the proceeding code.
162-
#
163-
# This is the second paragraph of the same block comment. Note
164-
# that this paragraph was separated from the previous paragraph
165-
# by a line containing a single comment character.
166-
167-
init()
168-
start()
169-
stop()
170-
```
159+
```coffeescript
160+
# This is a block comment. Note that if this were a real block
161+
# comment, we would actually be describing the proceeding code.
162+
#
163+
# This is the second paragraph of the same block comment. Note
164+
# that this paragraph was separated from the previous paragraph
165+
# by a line containing a single comment character.
166+
167+
init()
168+
start()
169+
stop()
170+
```
171171
172172
<a name="inline_comments"/>
173173
### Inline Comments
@@ -180,17 +180,17 @@ The use of inline comments should be limited, because their existence is typical
180180

181181
Do not use inline comments when they state the obvious:
182182

183-
```coffeescript
184-
# No
185-
x = x + 1 # Increment x
186-
```
183+
```coffeescript
184+
# No
185+
x = x + 1 # Increment x
186+
```
187187

188188
However, inline comments can be useful in certain scenarios:
189189

190-
```coffeescript
191-
# Yes
192-
x = x + 1 # Compensate for border
193-
```
190+
```coffeescript
191+
# Yes
192+
x = x + 1 # Compensate for border
193+
```
194194

195195
<a name="naming_conventions"/>
196196
## Naming Conventions
@@ -203,15 +203,15 @@ _(The **official** CoffeeScript convention is camelcase, because this simplifies
203203

204204
For constants, use all uppercase with underscores:
205205

206-
```coffeescript
207-
CONSTANT_LIKE_THIS
208-
```
206+
```coffeescript
207+
CONSTANT_LIKE_THIS
208+
```
209209

210210
Methods and variables that are intended to be "private" should begin with a leading underscore:
211211

212-
```coffeescript
213-
_privateMethod: ->
214-
```
212+
```coffeescript
213+
_privateMethod: ->
214+
```
215215

216216
<a name="functions"/>
217217
## Functions
@@ -220,58 +220,58 @@ _(These guidelines also apply to the methods of a class.)_
220220

221221
When declaring a function that takes arguments, always use a single space after the closing parenthesis of the arguments list:
222222

223-
```coffeescript
224-
foo = (arg1, arg2) -> # Yes
225-
foo = (arg1, arg2)-> # No
226-
```
223+
```coffeescript
224+
foo = (arg1, arg2) -> # Yes
225+
foo = (arg1, arg2)-> # No
226+
```
227227

228228
Do not use parentheses when declaring functions that take no arguments:
229229

230-
```coffeescript
231-
bar = -> # Yes
232-
bar = () -> # No
233-
```
230+
```coffeescript
231+
bar = -> # Yes
232+
bar = () -> # No
233+
```
234234

235235
In cases where method calls are being chained and the code does not fit on a single line, each call should be placed on a separate line and indented by one level (i.e., two spaces), with a leading `.`.
236236

237-
```coffeescript
238-
[1..3]
239-
.map((x) -> x * x)
240-
.concat([10..12])
241-
.filter((x) -> x < 11)
242-
.reduce((x, y) -> x + y)
243-
```
237+
```coffeescript
238+
[1..3]
239+
.map((x) -> x * x)
240+
.concat([10..12])
241+
.filter((x) -> x < 11)
242+
.reduce((x, y) -> x + y)
243+
```
244244

245245
When calling functions, omit the parentheses on the final method call in a chain. For example:
246246

247-
```coffeescript
248-
baz 12
247+
```coffeescript
248+
baz 12
249249

250-
foo(4).bar 8
251-
```
250+
foo(4).bar 8
251+
```
252252

253253
You will sometimes see parentheses used to group functions (instead of being used to group function parameters). Examples of using this style (hereafter referred to as the "function grouping style"):
254254

255-
```coffeescript
256-
($ '#selektor').addClass 'klass'
255+
```coffeescript
256+
($ '#selektor').addClass 'klass'
257257

258-
(foo 4).bar 8
259-
```
258+
(foo 4).bar 8
259+
```
260260

261261
This is in contrast to:
262262

263-
```coffeescript
264-
$('#selektor').addClass 'klass'
263+
```coffeescript
264+
$('#selektor').addClass 'klass'
265265

266-
foo(4).bar 8
267-
```
266+
foo(4).bar 8
267+
```
268268

269269
The correct way to apply the function grouping style when chaining is to use it for the initial call only:
270270

271-
```coffeescript
272-
($ '#selektor').addClass('klass').hide() # Yes
273-
($ '#selektor').(addClass 'klass').hide() # No
274-
```
271+
```coffeescript
272+
($ '#selektor').addClass('klass').hide() # Yes
273+
($ '#selektor').(addClass 'klass').hide() # No
274+
```
275275

276276
This guide does not prescribe the use of the function grouping style or the alternative. However, **if the function grouping style is adopted for a particular project, be consistent with its usage.**
277277

@@ -280,10 +280,10 @@ This guide does not prescribe the use of the function grouping style or the alte
280280

281281
Use string interpolation instead of string concatenation:
282282

283-
```coffeescript
284-
"this is an #{adjective} string" # Yes
285-
"this is an " + adjective + " string" # No
286-
```
283+
```coffeescript
284+
"this is an #{adjective} string" # Yes
285+
"this is an " + adjective + " string" # No
286+
```
287287

288288
Prefer single quoted strings (`''`) instead of double quoted (`""`) strings, unless features like string interpolation are being used for the given string.
289289

@@ -294,33 +294,33 @@ Favor `unless` over `if` for negative conditions.
294294

295295
Instead of using `unless...else`, use `if...else`:
296296

297-
```coffeescript
298-
# Yes
299-
if true
300-
...
301-
else
302-
...
303-
304-
# No
305-
unless false
306-
...
307-
else
308-
...
309-
```
297+
```coffeescript
298+
# Yes
299+
if true
300+
...
301+
else
302+
...
303+
304+
# No
305+
unless false
306+
...
307+
else
308+
...
309+
```
310310

311311
Multi-line if/else clauses should use indentation:
312312

313-
```coffeescript
314-
# Yes
315-
if true
316-
...
317-
else
318-
...
319-
320-
# No
321-
if true then ...
322-
else ...
323-
```
313+
```coffeescript
314+
# Yes
315+
if true
316+
...
317+
else
318+
...
319+
320+
# No
321+
if true then ...
322+
else ...
323+
```
324324

325325
<a name="looping_and_comprehensions"/>
326326
## Looping and Comprehensions

0 commit comments

Comments
 (0)