Skip to content

Commit 32a2deb

Browse files
author
José Valim
committed
Rollback syntax highlight.
1 parent 9ac9075 commit 32a2deb

File tree

2 files changed

+62
-74
lines changed

2 files changed

+62
-74
lines changed

_posts/2012-04-17-what-s-new-in-elixir-1.markdown

+39-45
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,34 @@ Last week Elixir has seen a lot of new features, improvements, and bug fixes. In
1010

1111
* Access protocol has been added for tuples, lists, strings, and whatnot. It allows us to easily access elements of a collection. We can also use a regex to find the first match in a string or a list. Examples follow:
1212

13-
{% highlight elixir %}
14-
dict = [a: 1, b: 2, c: 3]
15-
dict[:a] #=> 1
16-
dict[:d] #=> nil
17-
18-
tuple = {5, 4, 3, 2, 1}
19-
tuple[1] #=> 5
20-
tuple[0] #=> nil
21-
tuple[-1] #=> 1
22-
23-
defrecord TestRec, red: 0, green: 0, blue: 0
24-
r = TestRec[red: 255, blue: 80] #=> new record
25-
s = "The quick brown fox jumps over the lazy dog."
26-
s[%r/[a-z]+o[a-z]+/] #=> "brown"
27-
{% endhighlight %}
13+
14+
dict = [a: 1, b: 2, c: 3]
15+
dict[:a] #=> 1
16+
dict[:d] #=> nil
17+
18+
tuple = {5, 4, 3, 2, 1}
19+
tuple[1] #=> 5
20+
tuple[0] #=> nil
21+
tuple[-1] #=> 1
22+
23+
defrecord TestRec, red: 0, green: 0, blue: 0
24+
r = TestRec[red: 255, blue: 80] #=> new record
25+
s = "The quick brown fox jumps over the lazy dog."
26+
s[%r/[a-z]+o[a-z]+/] #=> "brown"
2827

2928
* Access protocol also makes it possible to pattern-match records:
3029

31-
{% highlight elixir %}
32-
defrecord TestRec, red: 0, green: 0, blue: 0
33-
r = TestRec[red: 255, blue: 80] #=> new record
34-
case r do
35-
match: TestRec[red: 0]
36-
:no_match
37-
match: TestRec[red: red, blue: 80]
38-
:ok
39-
end
40-
#=> :ok
41-
red === 255 #=> true
42-
{% endhighlight %}
30+
31+
defrecord TestRec, red: 0, green: 0, blue: 0
32+
r = TestRec[red: 255, blue: 80] #=> new record
33+
case r do
34+
match: TestRec[red: 0]
35+
:no_match
36+
match: TestRec[red: red, blue: 80]
37+
:ok
38+
end
39+
#=> :ok
40+
red === 255 #=> true
4341

4442
* The `Orddict` module is no longer with us, it has been renamed to `Keyword`. The new module only allows atoms to be used as keys. A general purpose module for dicts will be added sooner or later.
4543

@@ -49,28 +47,24 @@ red === 255 #=> true
4947

5048
* Support for nested modules has been added.
5149

52-
{% highlight elixir %}
53-
defmodule Father do
54-
defmodule Child do
55-
def child_fun(str) do
56-
IO.puts str
50+
defmodule Father do
51+
defmodule Child do
52+
def child_fun(str) do
53+
IO.puts str
54+
end
55+
end
56+
def fun do
57+
Child.child_fun "some argument"
58+
end
5759
end
58-
end
59-
def fun do
60-
Child.child_fun "some argument"
61-
end
62-
end
63-
Father.Child.child_fun "hello!"
64-
{% endhighlight %}
60+
Father.Child.child_fun "hello!"
6561

6662
* The `Regex` module has received new functions, namely, `source` and `opts`. It can also be `inspect`ed now.
6763

68-
{% highlight elixir %}
69-
reg = %r/[a-z]+o[a-z]+/im
70-
Regex.source reg #=> "[a-z]+o[a-z]+"
71-
Regex.opts reg #=> "im"
72-
inspect reg #=> "%r\"[a-z]+o[a-z]+\"im"
73-
{% endhighlight %}
64+
reg = %r/[a-z]+o[a-z]+/im
65+
Regex.source reg #=> "[a-z]+o[a-z]+"
66+
Regex.opts reg #=> "im"
67+
inspect reg #=> "%r\"[a-z]+o[a-z]+\"im"
7468

7569
* A new `read_info` function has been added to the [`File` module](https://github.com/elixir-lang/elixir/blob/35b22c598defd8be07d46d2e7e8fc0ddf9ec4e80/lib/file.ex) allowing
7670
users to query for file attributes.

_posts/2012-04-17-what-s-new-in-elixir-2.markdown

+23-29
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,40 @@ Let's get started with our usual overview. I'm using the latest master (`2851da4
1111

1212
* Literal support for hexadecimal, octal and binary numbers has been added.
1313

14-
{% highlight elixir %}
15-
0xFF #=> 255
16-
0o10 #=> 8
17-
0b1010 #=> 10
18-
{% endhighlight %}
14+
0xFF #=> 255
15+
0o10 #=> 8
16+
0b1010 #=> 10
1917

2018
* New functions in the [List module](https://github.com/elixir-lang/elixir/blob/master/lib/list.ex): `sort`, `zip`, `unzip`.
2119

22-
{% highlight elixir %}
23-
# Charlists are sorted in lexicographic order
24-
List.sort ['10', '2', '4', '1', '21']
25-
#=> ['1', '10', '2', '21', '4']
20+
# Charlists are sorted in lexicographic order
21+
List.sort ['10', '2', '4', '1', '21']
22+
#=> ['1', '10', '2', '21', '4']
2623

27-
# Numerical sort for charlists using a custom function
28-
List.sort ['10', '2', '4', '1', '21'], fn(a, b) ->
29-
{na, _} = :string.to_integer a
30-
{nb, _} = :string.to_integer b
31-
na <= nb
32-
end
33-
#=> ['1', '2', '4', '10', '21']
24+
# Numerical sort for charlists using a custom function
25+
List.sort ['10', '2', '4', '1', '21'], fn(a, b) ->
26+
{na, _} = :string.to_integer a
27+
{nb, _} = :string.to_integer b
28+
na <= nb
29+
end
30+
#=> ['1', '2', '4', '10', '21']
3431

35-
List.zip [[1, 2], [:a, :b], ["one", "two"]]
36-
#=> [{1,:a,"one"},{2,:b,"two"}]
37-
{% endhighlight %}
32+
List.zip [[1, 2], [:a, :b], ["one", "two"]]
33+
#=> [{1,:a,"one"},{2,:b,"two"}]
3834

3935
* The [System module](https://github.com/elixir-lang/elixir/blob/master/lib/system.ex) has been merged into master. It provides functions for communicating with OS environment, running external commands, getting the stacktrace, etc.
4036

41-
{% highlight elixir %}
42-
System.pwd
43-
#=> "/Users/alco/Documents/git/elixir"
37+
System.pwd
38+
#=> "/Users/alco/Documents/git/elixir"
4439

45-
System.get_env "PAGER"
46-
#=> "less"
40+
System.get_env "PAGER"
41+
#=> "less"
4742

48-
System.cmd 'date'
49-
#=> "Fri Apr 13 19:35:13 EEST 2012\n"
43+
System.cmd 'date'
44+
#=> "Fri Apr 13 19:35:13 EEST 2012\n"
5045

51-
System.stacktrace
52-
#=> (usually long output)
53-
{% endhighlight %}
46+
System.stacktrace
47+
#=> (usually long output)
5448

5549
* In other news, we're getting closer to having a dedicated site for documentation, JSON parsing/serialization is currently in the works, and there's also work being done on bringing dicts back into Elixir.
5650

0 commit comments

Comments
 (0)