Skip to content

Commit b0248e8

Browse files
committed
Shell highlighting, MD Table support, Crash Course Tables converted and improvments
1 parent 51aab10 commit b0248e8

18 files changed

+248
-159
lines changed

Diff for: README.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ It is automatically transformed by [Jekyll](http://github.com/mojombo/jekyll) in
44

55
### Contributing to the blog
66

7-
Create a new file inside `_posts/YYYY-MM-DD-post-title.markdown` following the template:
7+
Create a new file inside `_posts/YYYY-MM-DD-post-title.markdown` following the template:
88

99
---
1010
layout: post
@@ -16,24 +16,28 @@ It is automatically transformed by [Jekyll](http://github.com/mojombo/jekyll) in
1616

1717
Body text goes here...
1818

19-
Or use `_bin/newpost` to bootstrap a new post file:
19+
Or use `_bin/newpost` to bootstrap a new post file:
2020

21-
export EDITOR=vim; _bin/newpost 'Post title'
21+
```bash
22+
export EDITOR=vim; _bin/newpost 'Post title'
23+
```
2224

2325
### Contributing improvements or bug fixes
2426

25-
1. Fork elixir-lang.github.com
27+
1. [Fork elixir-lang.github.com](https://github.com/elixir-lang/elixir-lang.github.com/fork).
2628

27-
2. Make your changes
29+
2. Make your changes.
2830

2931
3. Test it locally, you need to install the gems `jekyll` and `redcarpet`:
3032

31-
```shell
32-
$ gem install jekyll redcarpet
33-
$ jekyll serve # check localhost:4000
34-
```
33+
```bash
34+
$ gem install jekyll redcarpet
35+
$ jekyll serve # check localhost:4000
36+
```
3537

36-
4. Send a pull-request for your changes
38+
4. Push to your forked repository.
39+
40+
5. Submit a pull-request for your changes.
3741

3842
`jekyll` requires a javascript processor to be available too. Many OS provide such functionality but others do not. If you have an error related to ExecJS, you can work around it by either running `gem install therubyracer` or by ensuring node.js is available in your path.
3943

Diff for: _config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ markdown: redcarpet
22
highlighter: pygments
33
permalink: /blog/:year/:month/:day/:title/
44
redcarpet:
5-
extensions: ['with_toc_data']
5+
extensions: ['with_toc_data', 'tables']
66
gems:
77
- jekyll-redirect-from

Diff for: _includes/bottom.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="clear"></div>
44

55
<div id="copyright">
6-
&copy; 2012-2014 <a href="http://plataformatec.com.br/">Plataformatec</a>. All rights reserved.
6+
&copy; 2012-2015 <a href="http://plataformatec.com.br/">Plataformatec</a>. All rights reserved.
77
</div>
88
</div><!-- .wrap -->
99
</div><!-- #container -->

Diff for: _posts/2013-05-23-elixir-v0-9-0-released.markdown

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ As a project grows, it is recommended to break it apart into smaller, isolated a
3636

3737
Elixir v0.9.0 now supports umbrella projects which can work with many applications at the same time. You can create a new umbrella project with:
3838

39-
$ mix new my_project --umbrella
39+
```bash
40+
$ mix new my_project --umbrella
41+
```
4042

4143
The generated project will have the following structure:
4244

Diff for: _posts/2014-04-21-elixir-v0-13-0-released.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ The last big change we want to discuss in this release are the improvements done
241241

242242
In previous releases, Mix was used to download and compile dependencies per environment. That meant the usual workflow was less than ideal: every time a dependency was updated, developers had to explicitly fetch and compile the dependencies for each environment. The workflow would be something like:
243243

244-
```
244+
```bash
245245
$ mix deps.get
246246
$ mix compile
247247
$ MIX_ENV=test mix deps.get

Diff for: crash-course.markdown

+31-48
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,10 @@ layout: default
88

99
This is a quick introduction to the Elixir syntax for Erlang developers and vice-versa. It is the absolute minimum amount of knowledge you need in order to understand Elixir/Erlang code, support interoperability, read the docs, sample code, etc.
1010

11-
This page is divided into sections:
11+
<div class="toc"></div>
1212

13-
1. [Running Code](#running_code)
14-
2. [Notable Differences](#notable_differences)
15-
3. [Data Types](#data_types)
16-
4. [Modules](#modules)
17-
5. [Function Syntax](#function_syntax)
18-
6. [Control Flow](#control_flow)
19-
7. [Adding Elixir to existing Erlang programs](#interop)
20-
8. [Further reading](#further_reading)
2113

22-
<div id="running_code"></div>
23-
24-
## 1 Running Code
14+
## Running code
2515

2616
### Erlang
2717

@@ -82,26 +72,25 @@ defmodule MyModule do
8272
end
8373
```
8474

85-
<div id="notable_differences"></div>
8675

87-
## 2 Notable Differences
76+
## Notable differences
8877

8978
This section goes over some of the syntactic differences between the two languages.
9079

91-
### Operator Names
80+
### Operator names
9281

9382
Some operators are spelled differently.
9483

95-
| Erlang | Elixir | Meaning |
96-
-----------------------------------------------------------------------------
97-
| and | NOT AVAILABLE | Logical 'and', evaluates both arguments |
98-
| andalso | and | Logical 'and', short-circuits |
99-
| or | NOT AVAILABLE | Logical 'or', evaluates both arguments |
100-
| orelse | or | Logical 'or', short-circuits |
101-
| =:= | === | A match operator |
102-
| =/= | !== | A negative match |
103-
| /= | != | Not equals |
104-
| =< | <= | Less than or equals |
84+
| Erlang | Elixir | Meaning |
85+
|----------------|----------------|-----------------------------------------|
86+
| and | NOT AVAILABLE | Logical 'and', evaluates both arguments |
87+
| andalso | and | Logical 'and', short-circuits |
88+
| or | NOT AVAILABLE | Logical 'or', evaluates both arguments |
89+
| orelse | or | Logical 'or', short-circuits |
90+
| =:= | === | A match operator |
91+
| =/= | !== | A negative match |
92+
| /= | != | Not equals |
93+
| =< | <= | Less than or equals |
10594

10695

10796
### Delimiters
@@ -122,7 +111,7 @@ x = 2; y = 3
122111
x + y
123112
```
124113

125-
### Variable Names
114+
### Variable names
126115

127116
Variables in Erlang can only be assigned once. The Erlang shell provides a special command `f` that allows you to erase the binding of a variable or all variables at once.
128117

@@ -161,14 +150,14 @@ iex> ^a = 3
161150
** (MatchError) no match of right hand side value: 3
162151
```
163152

164-
### Calling Functions
153+
### Calling functions
165154

166155
Elixir allows you to omit parentheses in function calls, Erlang does not.
167156

168-
| Erlang | Elixir |
169-
--------------------------------------
170-
| some_function(). | some_function |
171-
| sum(A, B) | sum a, b |
157+
| Erlang | Elixir |
158+
|-------------------|----------------|
159+
| some_function(). | some_function |
160+
| sum(A, B) | sum a, b |
172161

173162
Invoking a function from a module uses different syntax. In Erlang, you would write
174163

@@ -190,9 +179,8 @@ Kernel.self
190179

191180
All of the Erlang built-ins reside in the `:erlang` module.
192181

193-
<div id="data_types"></div>
194182

195-
## 3 Data Types
183+
## Data types
196184

197185
Erlang and Elixir have the same data types for the most part, but there are a number of differences.
198186

@@ -264,7 +252,7 @@ elem({ :a, :b, :c }, 0) #=> :a
264252
put_elem({ :a, :b, :c }, 0, :d) #=> { :d, :b, :c }
265253
```
266254

267-
### Lists and Binaries
255+
### Lists and binaries
268256

269257
Elixir has a shortcut syntax for binaries:
270258

@@ -374,9 +362,8 @@ lines.
374362
"""
375363
```
376364

377-
<div id="modules"></div>
378365

379-
## 4 Modules
366+
## Modules
380367

381368
Each Erlang module lives in its own file which has the following structure:
382369

@@ -452,15 +439,14 @@ HelloModule.Utils.priv
452439
#=> ** (UndefinedFunctionError) undefined function: HelloModule.Utils.priv/0
453440
```
454441

455-
<div id="function_syntax"></div>
456442

457-
## 5 Function Syntax
443+
## Function syntax
458444

459445
[This chapter][3] from the Erlang book provides a detailed description of pattern matching and function syntax in Erlang. Here, I'm briefly covering the main points and provide sample code both in Erlang and Elixir.
460446

461447
[3]: http://learnyousomeerlang.com/syntax-in-functions
462448

463-
### Pattern Matching
449+
### Pattern matching
464450

465451
Pattern matching in Elixir is based on Erlang's implementation and in general is very similar:
466452

@@ -574,7 +560,7 @@ mul_by 4, 3 #=> 12
574560
mul_by 4 #=> 8
575561
```
576562

577-
### Anonymous Functions
563+
### Anonymous functions
578564

579565
Anonymous functions are defined in the following way:
580566

@@ -637,7 +623,7 @@ f.({:a, :b})
637623
#=> "All your {:a,:b} are belong to us"
638624
```
639625

640-
### First-Class Functions
626+
### First-class functions
641627

642628
Anonymous functions are first-class values, so they can be passed as arguments to other functions and also can serve as a return value. There is a special syntax to allow named functions be treated in the same manner.
643629

@@ -692,9 +678,8 @@ Enum.map [1,2,3], &Math.square/1
692678
#=> [1, 4, 9]
693679
```
694680

695-
<div id="control_flow"></div>
696681

697-
## 6 Control Flow
682+
## Control flow
698683

699684
The constructs `if` and `case` are actually expressions in both Erlang and Elixir, but may be used for control flow as in imperative languages.
700685

@@ -791,7 +776,7 @@ else
791776
end
792777
```
793778

794-
### Sending and Receiving Messages
779+
### Sending and receiving messages
795780

796781
The syntax for sending and receiving differs only slightly between Erlang and Elixir.
797782

@@ -825,9 +810,8 @@ after
825810
end
826811
```
827812

828-
<div id="interop"></div>
829813

830-
## 7 Adding Elixir to existing Erlang programs
814+
## Adding Elixir to existing Erlang programs
831815

832816
Elixir compiles into BEAM byte code (via Erlang Abstract Format). This means that Elixir code can be called from Erlang and vice versa, without the need to write any bindings. All Elixir modules start with the `Elixir.` prefix followed by the regular Elixir name. For example, here is how to use the utf-8 aware `String` downcase from Elixir in Erlang:
833817

@@ -859,9 +843,8 @@ This should be enough to invoke Elixir functions straight from your Erlang code.
859843

860844
If you are not using rebar, the easiest approach to use Elixir in your existing Erlang software is to install Elixir using one of the different ways specified in the [Getting Started guide](/getting-started/introduction.html) and add the `lib` directory in your checkout to `ERL_LIBS`.
861845

862-
<div id="further_reading"></div>
863846

864-
## 8 Further Reading
847+
## Further reading
865848

866849
Erlang's official documentation site has a nice [collection][4] of programming examples. It can be a good exercise to translate them into Elixir. [Erlang cookbook][5] offers even more useful code examples.
867850

Diff for: css/style.css

+27
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ ol ol ol { list-style: lower-roman }
161161
ol ol ol ol { list-style: upper-alpha }
162162
ol ol ol ol ol { list-style: lower-alpha }
163163
ul ul, ol ol, ul ol, ol ul { margin-bottom:0 }
164+
165+
.toc ol { counter-reset: item; }
166+
.toc ol li { display: block }
167+
.toc ol li:before {
168+
content: counters(item, ".") " ";
169+
counter-increment: item;
170+
}
171+
172+
164173
dl { margin: 0 0 1.692307em 5px }
165174
dt {
166175
font-weight: bold;
@@ -305,6 +314,24 @@ td {
305314
border-bottom: 1px solid #e7e7e7;
306315
}
307316

317+
#content table {
318+
margin-left: 1.692307em;
319+
width: auto;
320+
width: 85%;
321+
}
322+
#content table caption { color: #555; }
323+
#content table th {
324+
font-weight: bold;
325+
padding: 10px 4%;
326+
border-bottom: 3px solid #E6DFD5;
327+
background-color:#FFFAF3;
328+
}
329+
#content td {
330+
padding: 0.8125em 4%;
331+
border-bottom: 1px solid #E6DFD5;
332+
background-color:#FFFAF3;
333+
}
334+
308335
/* Lists
309336
-------------------------------------------------------------- */
310337
ul li, ol li { line-height: 2.1em; }

Diff for: getting-started/meta/macros.markdown

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ The function receives the arguments and passes them to `if`. However, as we lear
3434

3535
Let's start `iex` with the module above:
3636

37-
$ iex macros.exs
37+
```bash
38+
$ iex macros.exs
39+
```
3840

3941
And play with those definitions:
4042

Diff for: getting-started/mix-otp/agent.markdown

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ We will explore all of these abstractions in this guide. Keep in mind that they
3232

3333
[Agents](/docs/stable/elixir/Agent.html) are simple wrappers around state. If all you want from a process is to keep state, agents are a great fit. Let's start an `iex` session inside the project with:
3434

35-
$ iex -S mix
35+
```bash
36+
$ iex -S mix
37+
```
3638

3739
And play a bit with agents:
3840

0 commit comments

Comments
 (0)