Period: .
28 |
29 | These should get escaped, even though they're matching pairs for
106 | other Markdown constructs:
107 |
108 | Regular text.
5 |
6 | Regular text.
10 |
11 | Regular Text.
16 |
17 | `
2 |
3 | Fix for backticks within HTML tag: like this
4 |
5 | Here's how you put `` `backticks` `` in a code span.
6 |
7 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/def_blocks.html:
--------------------------------------------------------------------------------
1 |
2 | hello
3 | [1]: hello
4 |
5 |
6 |
7 |
8 |
9 | hello
10 |
11 |
12 |
13 |
14 | hello
15 | [3]: hello
16 |
17 |
18 |
19 |
22 |
23 |
24 |
25 | foo
26 | bar
27 | bar
28 |
29 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/def_blocks.text:
--------------------------------------------------------------------------------
1 | > hello
2 | > [1]: hello
3 |
4 | * * *
5 |
6 | > hello
7 | [2]: hello
8 |
9 |
10 | * hello
11 | * [3]: hello
12 |
13 |
14 | * hello
15 | [4]: hello
16 |
17 |
18 | > foo
19 | > bar
20 | [1]: foo
21 | > bar
22 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/double_link.html:
--------------------------------------------------------------------------------
1 | Already linked: http://example.com/ .
2 |
3 | Already linked: http://example.com/ .
4 |
5 | Already linked: http://example.com/ .
6 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/double_link.text:
--------------------------------------------------------------------------------
1 | Already linked: http://example.com/ .
2 |
3 | Already linked: [http://example.com/](http://example.com/).
4 |
5 | Already linked: **http://example.com/** .
6 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/escaped_angles.html:
--------------------------------------------------------------------------------
1 | >
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/escaped_angles.text:
--------------------------------------------------------------------------------
1 | \>
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_break.breaks.html:
--------------------------------------------------------------------------------
1 | Look at the pretty line breaks.
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_break.breaks.text:
--------------------------------------------------------------------------------
1 | Look at the
2 | pretty line
3 | breaks.
4 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_code.html:
--------------------------------------------------------------------------------
1 | var a = 'hello';
2 | console.log(a + ' world');
3 | echo "hello, ${WORLD}"
4 | Q: What do you call a tall person who sells stolen goods?
5 | A longfence!
6 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_code.text:
--------------------------------------------------------------------------------
1 | ``` js
2 | var a = 'hello';
3 | console.log(a + ' world');
4 | ```
5 |
6 | ~~~bash
7 | echo "hello, ${WORLD}"
8 | ~~~
9 |
10 | ```````longfence
11 | Q: What do you call a tall person who sells stolen goods?
12 | ```````
13 |
14 | ~~~~~~~~~~ ManyTildes
15 | A longfence!
16 | ~~~~~~~~~~
17 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_code_hr_list.html:
--------------------------------------------------------------------------------
1 | foo
2 |
3 | bar:
4 |
5 |
6 | one
7 | two
8 | three
9 | four
10 | five
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | foo:
19 | line 1
20 | line 2
21 |
22 | foo:
23 |
24 | foo bar
bar:
25 | some code here
26 |
27 |
28 | foo bar
bar:
29 | foo
30 | ---
31 | bar
32 | ---
33 | foo
34 | bar
35 |
36 | foo bar
bar:
37 | ---
38 | foo
39 | foo
40 | ---
41 | bar
42 |
43 | foo bar
bar:
44 | foo
45 | ---
46 | bar
47 |
48 | foo
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_code_hr_list.text:
--------------------------------------------------------------------------------
1 | ## foo
2 |
3 | 1. bar:
4 |
5 | > - one
6 | - two
7 | - three
8 | - four
9 | - five
10 |
11 | 1. foo:
12 |
13 | ```
14 | line 1
15 | line 2
16 | ```
17 |
18 | 1. foo:
19 |
20 | 1. foo `bar` bar:
21 |
22 | ``` erb
23 | some code here
24 | ```
25 |
26 | 2. foo `bar` bar:
27 |
28 | ``` erb
29 | foo
30 | ---
31 | bar
32 | ---
33 | foo
34 | bar
35 | ```
36 |
37 | 3. foo `bar` bar:
38 |
39 | ``` html
40 | ---
41 | foo
42 | foo
43 | ---
44 | bar
45 | ```
46 |
47 | 4. foo `bar` bar:
48 |
49 | foo
50 | ---
51 | bar
52 |
53 | 5. foo
54 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_del.html:
--------------------------------------------------------------------------------
1 | hello hi world
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_del.text:
--------------------------------------------------------------------------------
1 | hello ~~hi~~ world
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_em.html:
--------------------------------------------------------------------------------
1 | These words should_not_be_emphasized.
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_em.text:
--------------------------------------------------------------------------------
1 | These words should_not_be_emphasized.
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_links.html:
--------------------------------------------------------------------------------
1 | This should be a link:
2 | http://example.com/hello-world .
3 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_links.text:
--------------------------------------------------------------------------------
1 | This should be a link: http://example.com/hello-world.
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_tables.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Heading 1 Heading 2
4 |
5 |
6 | Cell 1 Cell 2
7 | Cell 3 Cell 4
8 |
9 |
10 |
11 |
12 | Header 1 Header 2 Header 3 Header 4
13 |
14 |
15 | Cell 1 Cell 2 Cell 3 Cell 4
16 | Cell 5 Cell 6 Cell 7 Cell 8
17 |
18 |
19 | Test code
20 |
21 |
22 | Header 1 Header 2
23 |
24 |
25 | Cell 1 Cell 2
26 | Cell 3 Cell 4
27 |
28 |
29 |
30 |
31 | Header 1 Header 2 Header 3 Header 4
32 |
33 |
34 | Cell 1 Cell 2 Cell 3 Cell 4
35 | Cell 5 Cell 6 Cell 7 Cell 8
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/gfm_tables.text:
--------------------------------------------------------------------------------
1 | | Heading 1 | Heading 2
2 | | --------- | ---------
3 | | Cell 1 | Cell 2
4 | | Cell 3 | Cell 4
5 |
6 | | Header 1 | Header 2 | Header 3 | Header 4 |
7 | | :------: | -------: | :------- | -------- |
8 | | Cell 1 | Cell 2 | Cell 3 | Cell 4 |
9 | | Cell 5 | Cell 6 | Cell 7 | Cell 8 |
10 |
11 | Test code
12 |
13 | Header 1 | Header 2
14 | -------- | --------
15 | Cell 1 | Cell 2
16 | Cell 3 | Cell 4
17 |
18 | Header 1|Header 2|Header 3|Header 4
19 | :-------|:------:|-------:|--------
20 | Cell 1 |Cell 2 |Cell 3 |Cell 4
21 | *Cell 5*|Cell 6 |Cell 7 |Cell 8
22 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/hard_wrapped_paragraphs_with_list_like_lines.nogfm.html:
--------------------------------------------------------------------------------
1 | In Markdown 1.0.0 and earlier. Version
2 | 8. This line turns into a list item.
3 | Because a hard-wrapped line in the
4 | middle of a paragraph looked like a
5 | list item.
6 |
7 | Here's one with a bullet.
8 | * criminey.
9 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/hard_wrapped_paragraphs_with_list_like_lines.nogfm.text:
--------------------------------------------------------------------------------
1 | In Markdown 1.0.0 and earlier. Version
2 | 8. This line turns into a list item.
3 | Because a hard-wrapped line in the
4 | middle of a paragraph looked like a
5 | list item.
6 |
7 | Here's one with a bullet.
8 | * criminey.
9 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/horizontal_rules.html:
--------------------------------------------------------------------------------
1 | Dashes:
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | ---
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | - - -
23 |
24 |
25 | Asterisks:
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | ***
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | * * *
47 |
48 |
49 | Underscores:
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | ___
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | _ _ _
71 |
72 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/horizontal_rules.text:
--------------------------------------------------------------------------------
1 | Dashes:
2 |
3 | ---
4 |
5 | ---
6 |
7 | ---
8 |
9 | ---
10 |
11 | ---
12 |
13 | - - -
14 |
15 | - - -
16 |
17 | - - -
18 |
19 | - - -
20 |
21 | - - -
22 |
23 |
24 | Asterisks:
25 |
26 | ***
27 |
28 | ***
29 |
30 | ***
31 |
32 | ***
33 |
34 | ***
35 |
36 | * * *
37 |
38 | * * *
39 |
40 | * * *
41 |
42 | * * *
43 |
44 | * * *
45 |
46 |
47 | Underscores:
48 |
49 | ___
50 |
51 | ___
52 |
53 | ___
54 |
55 | ___
56 |
57 | ___
58 |
59 | _ _ _
60 |
61 | _ _ _
62 |
63 | _ _ _
64 |
65 | _ _ _
66 |
67 | _ _ _
68 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/hr_list_break.html:
--------------------------------------------------------------------------------
1 |
2 | hello
3 | world
4 | how
5 | are
6 |
7 |
8 |
9 |
10 | you today?
11 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/hr_list_break.text:
--------------------------------------------------------------------------------
1 | * hello
2 | world
3 | * how
4 | are
5 | * * *
6 | you today?
7 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/inline_html_advanced.html:
--------------------------------------------------------------------------------
1 | Simple block on one line:
2 |
3 | foo
4 |
5 | And nested without indentation:
6 |
7 |
8 |
9 |
10 | foo
11 |
12 |
13 |
14 |
bar
15 |
16 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/inline_html_advanced.text:
--------------------------------------------------------------------------------
1 | Simple block on one line:
2 |
3 | foo
4 |
5 | And nested without indentation:
6 |
7 |
8 |
9 |
10 | foo
11 |
12 |
13 |
14 |
bar
15 |
16 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/inline_html_comments.html:
--------------------------------------------------------------------------------
1 | Paragraph one.
2 |
3 |
4 |
5 |
8 |
9 | Paragraph two.
10 |
11 |
12 |
13 | The end.
14 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/inline_html_comments.text:
--------------------------------------------------------------------------------
1 | Paragraph one.
2 |
3 |
4 |
5 |
8 |
9 | Paragraph two.
10 |
11 |
12 |
13 | The end.
14 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/inline_html_simple.html:
--------------------------------------------------------------------------------
1 | Here's a simple block:
2 |
3 |
4 | foo
5 |
6 |
7 | This should be a code block, though:
8 |
9 | <div>
10 | foo
11 | </div>
12 |
13 |
14 | As should this:
15 |
16 | <div>foo</div>
17 |
18 |
19 | Now, nested:
20 |
21 |
28 |
29 | This should just be an HTML comment:
30 |
31 |
32 |
33 | Multiline:
34 |
35 |
39 |
40 | Code block:
41 |
42 | <!-- Comment -->
43 |
44 |
45 | Just plain comment, with trailing spaces on the line:
46 |
47 |
48 |
49 | Code:
50 |
51 | <hr>
52 |
53 |
54 | Hr's:
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/inline_html_simple.text:
--------------------------------------------------------------------------------
1 | Here's a simple block:
2 |
3 |
4 | foo
5 |
6 |
7 | This should be a code block, though:
8 |
9 |
10 | foo
11 |
12 |
13 | As should this:
14 |
15 | foo
16 |
17 | Now, nested:
18 |
19 |
26 |
27 | This should just be an HTML comment:
28 |
29 |
30 |
31 | Multiline:
32 |
33 |
37 |
38 | Code block:
39 |
40 |
41 |
42 | Just plain comment, with trailing spaces on the line:
43 |
44 |
45 |
46 | Code:
47 |
48 |
49 |
50 | Hr's:
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/lazy_blockquotes.html:
--------------------------------------------------------------------------------
1 |
2 | hi there
3 | bud
4 |
5 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/lazy_blockquotes.text:
--------------------------------------------------------------------------------
1 | > hi there
2 | bud
3 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/links_inline_style.html:
--------------------------------------------------------------------------------
1 | Just a URL .
2 |
3 | URL and title .
4 |
5 | URL and title .
6 |
7 | URL and title .
8 |
9 | URL and title .
10 |
11 | URL and title .
12 |
13 | URL and title .
14 |
15 | Empty .
16 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/links_inline_style.text:
--------------------------------------------------------------------------------
1 | Just a [URL](/url/).
2 |
3 | [URL and title](/url/ "title").
4 |
5 | [URL and title](/url/ "title preceded by two spaces").
6 |
7 | [URL and title](/url/ "title preceded by a tab").
8 |
9 | [URL and title](/url/ "title has spaces afterward" ).
10 |
11 | [URL and title]( /url/has space ).
12 |
13 | [URL and title]( /url/has space/ "url has space and title").
14 |
15 | [Empty]().
16 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/links_reference_style.html:
--------------------------------------------------------------------------------
1 | Foo bar .
2 |
3 | Foo bar .
4 |
5 | Foo bar .
6 |
7 | With embedded [brackets] .
8 |
9 | Indented once .
10 |
11 | Indented twice .
12 |
13 | Indented thrice .
14 |
15 | Indented [four][] times.
16 |
17 | [four]: /url
18 |
19 |
20 |
21 |
22 | this should work
23 |
24 | So should this .
25 |
26 | And this .
27 |
28 | And this .
29 |
30 | And this .
31 |
32 | But not [that] [].
33 |
34 | Nor [that][].
35 |
36 | Nor [that].
37 |
38 | [Something in brackets like this should work]
39 |
40 | [Same with this .]
41 |
42 | In this case, this points to something else.
43 |
44 | Backslashing should suppress [this] and [this].
45 |
46 |
47 |
48 | Here's one where the link
49 | breaks across lines.
50 |
51 | Here's another where the link
52 | breaks across lines, but with a line-ending space.
53 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/links_reference_style.text:
--------------------------------------------------------------------------------
1 | Foo [bar] [1].
2 |
3 | Foo [bar][1].
4 |
5 | Foo [bar]
6 | [1].
7 |
8 | [1]: /url/ "Title"
9 |
10 |
11 | With [embedded [brackets]] [b].
12 |
13 |
14 | Indented [once][].
15 |
16 | Indented [twice][].
17 |
18 | Indented [thrice][].
19 |
20 | Indented [four][] times.
21 |
22 | [once]: /url
23 |
24 | [twice]: /url
25 |
26 | [thrice]: /url
27 |
28 | [four]: /url
29 |
30 |
31 | [b]: /url/
32 |
33 | * * *
34 |
35 | [this] [this] should work
36 |
37 | So should [this][this].
38 |
39 | And [this] [].
40 |
41 | And [this][].
42 |
43 | And [this].
44 |
45 | But not [that] [].
46 |
47 | Nor [that][].
48 |
49 | Nor [that].
50 |
51 | [Something in brackets like [this][] should work]
52 |
53 | [Same with [this].]
54 |
55 | In this case, [this](/somethingelse/) points to something else.
56 |
57 | Backslashing should suppress \[this] and [this\].
58 |
59 | [this]: foo
60 |
61 |
62 | * * *
63 |
64 | Here's one where the [link
65 | breaks] across lines.
66 |
67 | Here's another where the [link
68 | breaks] across lines, but with a line-ending space.
69 |
70 |
71 | [link breaks]: /url/
72 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/links_shortcut_references.html:
--------------------------------------------------------------------------------
1 | This is the simple case .
2 |
3 | This one has a line
4 | break .
5 |
6 | This one has a line
7 | break with a line-ending space.
8 |
9 | this and the other
10 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/links_shortcut_references.text:
--------------------------------------------------------------------------------
1 | This is the [simple case].
2 |
3 | [simple case]: /simple
4 |
5 |
6 |
7 | This one has a [line
8 | break].
9 |
10 | This one has a [line
11 | break] with a line-ending space.
12 |
13 | [line break]: /foo
14 |
15 |
16 | [this] [that] and the [other]
17 |
18 | [this]: /this
19 | [that]: /that
20 | [other]: /other
21 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/list_item_text.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/list_item_text.text:
--------------------------------------------------------------------------------
1 | * item1
2 |
3 | * item2
4 |
5 | text
6 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/literal_quotes_in_titles.html:
--------------------------------------------------------------------------------
1 | Foo bar .
2 |
3 | Foo bar .
4 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/literal_quotes_in_titles.text:
--------------------------------------------------------------------------------
1 | Foo [bar][].
2 |
3 | Foo [bar](/url/ "Title with "quotes" inside").
4 |
5 |
6 | [bar]: /url/ "Title with "quotes" inside"
7 |
8 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/loose_lists.html:
--------------------------------------------------------------------------------
1 |
2 | hello
3 | world
4 |
5 | how
6 | are
7 | you
8 |
9 |
10 |
11 |
12 | better behavior:
13 |
14 | hello
world
15 | how
are
16 | you
today
hi
17 |
18 |
19 |
20 |
21 | hello
22 | world
23 | hi
24 |
25 |
26 |
27 |
28 |
29 | hello
30 | world
31 | hi
32 |
33 |
34 |
35 |
36 |
37 | hello
38 | world
39 |
40 | how
41 | hi
42 |
43 |
44 |
45 |
46 |
47 | hello
48 | world
49 | how
50 |
51 | are
52 |
53 |
54 |
55 |
56 |
57 | hello
58 | world
59 | how
60 |
61 | are
62 |
63 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/loose_lists.text:
--------------------------------------------------------------------------------
1 | * hello
2 | world
3 |
4 | how
5 | are
6 | * you
7 |
8 |
9 |
10 | better behavior:
11 |
12 | * hello
13 | * world
14 | how
15 |
16 | are
17 | you
18 |
19 | * today
20 | * hi
21 |
22 |
23 |
24 | * hello
25 |
26 | * world
27 | * hi
28 |
29 |
30 |
31 | * hello
32 | * world
33 |
34 | * hi
35 |
36 |
37 |
38 | * hello
39 | * world
40 |
41 | how
42 | * hi
43 |
44 |
45 |
46 | * hello
47 | * world
48 | * how
49 |
50 | are
51 |
52 |
53 |
54 | * hello
55 | * world
56 |
57 | * how
58 |
59 | are
60 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/main.html:
--------------------------------------------------------------------------------
1 | A heading Just a note, I've found that I can't test my markdown parser vs others. For example, both markdown.js and showdown code blocks in lists wrong. They're also completely inconsistent with regards to paragraphs in list items.
A link. Not anymore.
This will make me fail the test because
2 | markdown.js doesnt acknowledge arbitrary html blocks =/ Paragraph.
bq Item 1 bq Item 2 New bq Item 1 New bq Item 2 Text here Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again
Another Heading Hello world . Here is a link . And an image .
Code goes here.
4 | Lots of it...
5 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/main.text:
--------------------------------------------------------------------------------
1 | [test]: http://google.com/ "Google"
2 |
3 | # A heading
4 |
5 | Just a note, I've found that I can't test my markdown parser vs others.
6 | For example, both markdown.js and showdown code blocks in lists wrong. They're
7 | also completely [inconsistent][test] with regards to paragraphs in list items.
8 |
9 | A link. Not anymore.
10 |
11 | This will make me fail the test because
12 | markdown.js doesnt acknowledge arbitrary html blocks =/
13 |
14 | * List Item 1
15 |
16 | * List Item 2
17 | * New List Item 1
18 | Hi, this is a list item.
19 | * New List Item 2
20 | Another item
21 | Code goes here.
22 | Lots of it...
23 | * New List Item 3
24 | The last item
25 |
26 | * List Item 3
27 | The final item.
28 |
29 | * List Item 4
30 | The real final item.
31 |
32 | Paragraph.
33 |
34 | > * bq Item 1
35 | > * bq Item 2
36 | > * New bq Item 1
37 | > * New bq Item 2
38 | > Text here
39 |
40 | * * *
41 |
42 | > Another blockquote!
43 | > I really need to get
44 | > more creative with
45 | > mockup text..
46 | > markdown.js breaks here again
47 |
48 | Another Heading
49 | -------------
50 |
51 | Hello *world*. Here is a [link](//hello).
52 | And an image .
53 |
54 | Code goes here.
55 | Lots of it...
56 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/markdown_documentation_basics.text:
--------------------------------------------------------------------------------
1 | Markdown: Basics
2 | ================
3 |
4 |
11 |
12 |
13 | Getting the Gist of Markdown's Formatting Syntax
14 | ------------------------------------------------
15 |
16 | This page offers a brief overview of what it's like to use Markdown.
17 | The [syntax page] [s] provides complete, detailed documentation for
18 | every feature, but Markdown should be very easy to pick up simply by
19 | looking at a few examples of it in action. The examples on this page
20 | are written in a before/after style, showing example syntax and the
21 | HTML output produced by Markdown.
22 |
23 | It's also helpful to simply try Markdown out; the [Dingus] [d] is a
24 | web application that allows you type your own Markdown-formatted text
25 | and translate it to XHTML.
26 |
27 | **Note:** This document is itself written using Markdown; you
28 | can [see the source for it by adding '.text' to the URL] [src].
29 |
30 | [s]: /projects/markdown/syntax "Markdown Syntax"
31 | [d]: /projects/markdown/dingus "Markdown Dingus"
32 | [src]: /projects/markdown/basics.text
33 |
34 |
35 | ## Paragraphs, Headers, Blockquotes ##
36 |
37 | A paragraph is simply one or more consecutive lines of text, separated
38 | by one or more blank lines. (A blank line is any line that looks like a
39 | blank line -- a line containing nothing spaces or tabs is considered
40 | blank.) Normal paragraphs should not be intended with spaces or tabs.
41 |
42 | Markdown offers two styles of headers: *Setext* and *atx*.
43 | Setext-style headers for `` and `` are created by
44 | "underlining" with equal signs (`=`) and hyphens (`-`), respectively.
45 | To create an atx-style header, you put 1-6 hash marks (`#`) at the
46 | beginning of the line -- the number of hashes equals the resulting
47 | HTML header level.
48 |
49 | Blockquotes are indicated using email-style '`>`' angle brackets.
50 |
51 | Markdown:
52 |
53 | A First Level Header
54 | ====================
55 |
56 | A Second Level Header
57 | ---------------------
58 |
59 | Now is the time for all good men to come to
60 | the aid of their country. This is just a
61 | regular paragraph.
62 |
63 | The quick brown fox jumped over the lazy
64 | dog's back.
65 |
66 | ### Header 3
67 |
68 | > This is a blockquote.
69 | >
70 | > This is the second paragraph in the blockquote.
71 | >
72 | > ## This is an H2 in a blockquote
73 |
74 |
75 | Output:
76 |
77 | A First Level Header
78 |
79 | A Second Level Header
80 |
81 | Now is the time for all good men to come to
82 | the aid of their country. This is just a
83 | regular paragraph.
84 |
85 | The quick brown fox jumped over the lazy
86 | dog's back.
87 |
88 | Header 3
89 |
90 |
91 | This is a blockquote.
92 |
93 | This is the second paragraph in the blockquote.
94 |
95 | This is an H2 in a blockquote
96 |
97 |
98 |
99 |
100 | ### Phrase Emphasis ###
101 |
102 | Markdown uses asterisks and underscores to indicate spans of emphasis.
103 |
104 | Markdown:
105 |
106 | Some of these words *are emphasized*.
107 | Some of these words _are emphasized also_.
108 |
109 | Use two asterisks for **strong emphasis**.
110 | Or, if you prefer, __use two underscores instead__.
111 |
112 | Output:
113 |
114 | Some of these words are emphasized .
115 | Some of these words are emphasized also .
116 |
117 | Use two asterisks for strong emphasis .
118 | Or, if you prefer, use two underscores instead .
119 |
120 |
121 |
122 | ## Lists ##
123 |
124 | Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
125 | `+`, and `-`) as list markers. These three markers are
126 | interchangable; this:
127 |
128 | * Candy.
129 | * Gum.
130 | * Booze.
131 |
132 | this:
133 |
134 | + Candy.
135 | + Gum.
136 | + Booze.
137 |
138 | and this:
139 |
140 | - Candy.
141 | - Gum.
142 | - Booze.
143 |
144 | all produce the same output:
145 |
146 |
147 | Candy.
148 | Gum.
149 | Booze.
150 |
151 |
152 | Ordered (numbered) lists use regular numbers, followed by periods, as
153 | list markers:
154 |
155 | 1. Red
156 | 2. Green
157 | 3. Blue
158 |
159 | Output:
160 |
161 |
162 | Red
163 | Green
164 | Blue
165 |
166 |
167 | If you put blank lines between items, you'll get `` tags for the
168 | list item text. You can create multi-paragraph list items by indenting
169 | the paragraphs by 4 spaces or 1 tab:
170 |
171 | * A list item.
172 |
173 | With multiple paragraphs.
174 |
175 | * Another item in the list.
176 |
177 | Output:
178 |
179 |
184 |
185 |
186 |
187 | ### Links ###
188 |
189 | Markdown supports two styles for creating links: *inline* and
190 | *reference*. With both styles, you use square brackets to delimit the
191 | text you want to turn into a link.
192 |
193 | Inline-style links use parentheses immediately after the link text.
194 | For example:
195 |
196 | This is an [example link](http://example.com/).
197 |
198 | Output:
199 |
200 | This is an
201 | example link .
202 |
203 | Optionally, you may include a title attribute in the parentheses:
204 |
205 | This is an [example link](http://example.com/ "With a Title").
206 |
207 | Output:
208 |
209 | This is an
210 | example link .
211 |
212 | Reference-style links allow you to refer to your links by names, which
213 | you define elsewhere in your document:
214 |
215 | I get 10 times more traffic from [Google][1] than from
216 | [Yahoo][2] or [MSN][3].
217 |
218 | [1]: http://google.com/ "Google"
219 | [2]: http://search.yahoo.com/ "Yahoo Search"
220 | [3]: http://search.msn.com/ "MSN Search"
221 |
222 | Output:
223 |
224 | I get 10 times more traffic from Google than from Yahoo or MSN .
228 |
229 | The title attribute is optional. Link names may contain letters,
230 | numbers and spaces, but are *not* case sensitive:
231 |
232 | I start my morning with a cup of coffee and
233 | [The New York Times][NY Times].
234 |
235 | [ny times]: http://www.nytimes.com/
236 |
237 | Output:
238 |
239 | I start my morning with a cup of coffee and
240 | The New York Times .
241 |
242 |
243 | ### Images ###
244 |
245 | Image syntax is very much like link syntax.
246 |
247 | Inline (titles are optional):
248 |
249 | 
250 |
251 | Reference-style:
252 |
253 | ![alt text][id]
254 |
255 | [id]: /path/to/img.jpg "Title"
256 |
257 | Both of the above examples produce the same output:
258 |
259 |
260 |
261 |
262 |
263 | ### Code ###
264 |
265 | In a regular paragraph, you can create code span by wrapping text in
266 | backtick quotes. Any ampersands (`&`) and angle brackets (`<` or
267 | `>`) will automatically be translated into HTML entities. This makes
268 | it easy to use Markdown to write about HTML example code:
269 |
270 | I strongly recommend against using any `` tags.
271 |
272 | I wish SmartyPants used named entities like `—`
273 | instead of decimal-encoded entites like `—`.
274 |
275 | Output:
276 |
277 | I strongly recommend against using any
278 | <blink>
tags.
279 |
280 | I wish SmartyPants used named entities like
281 | —
instead of decimal-encoded
282 | entites like —
.
283 |
284 |
285 | To specify an entire block of pre-formatted code, indent every line of
286 | the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`,
287 | and `>` characters will be escaped automatically.
288 |
289 | Markdown:
290 |
291 | If you want your page to validate under XHTML 1.0 Strict,
292 | you've got to put paragraph tags in your blockquotes:
293 |
294 |
295 | For example.
296 |
297 |
298 | Output:
299 |
300 | If you want your page to validate under XHTML 1.0 Strict,
301 | you've got to put paragraph tags in your blockquotes:
302 |
303 | <blockquote>
304 | <p>For example.</p>
305 | </blockquote>
306 |
307 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/nested_blockquotes.html:
--------------------------------------------------------------------------------
1 |
2 | foo
3 |
4 |
5 | bar
6 |
7 |
8 | foo
9 |
10 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/nested_blockquotes.text:
--------------------------------------------------------------------------------
1 | > foo
2 | >
3 | > > bar
4 | >
5 | > foo
6 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/nested_code.html:
--------------------------------------------------------------------------------
1 | hi ther `` ok ```
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/nested_code.text:
--------------------------------------------------------------------------------
1 | ````` hi ther `` ok ``` `````
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/nested_em.html:
--------------------------------------------------------------------------------
1 | test test test
2 |
3 | test test test
4 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/nested_em.text:
--------------------------------------------------------------------------------
1 | *test **test** test*
2 |
3 | _test __test__ test_
4 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/nested_square_link.html:
--------------------------------------------------------------------------------
1 | the ]
character
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/nested_square_link.text:
--------------------------------------------------------------------------------
1 | [the `]` character](/url)
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/not_a_link.html:
--------------------------------------------------------------------------------
1 | [test](not a link)
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/not_a_link.text:
--------------------------------------------------------------------------------
1 | \[test](not a link)
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/ordered_and_unordered_lists.html:
--------------------------------------------------------------------------------
1 | Unordered
2 |
3 | Asterisks tight:
4 |
5 |
6 | asterisk 1
7 | asterisk 2
8 | asterisk 3
9 |
10 |
11 | Asterisks loose:
12 |
13 |
14 | asterisk 1
15 | asterisk 2
16 | asterisk 3
17 |
18 |
19 |
20 |
21 | Pluses tight:
22 |
23 |
24 | Plus 1
25 | Plus 2
26 | Plus 3
27 |
28 |
29 | Pluses loose:
30 |
31 |
32 | Plus 1
33 | Plus 2
34 | Plus 3
35 |
36 |
37 |
38 |
39 | Minuses tight:
40 |
41 |
42 | Minus 1
43 | Minus 2
44 | Minus 3
45 |
46 |
47 | Minuses loose:
48 |
49 |
50 | Minus 1
51 | Minus 2
52 | Minus 3
53 |
54 |
55 | Ordered
56 |
57 | Tight:
58 |
59 |
60 | First
61 | Second
62 | Third
63 |
64 |
65 | and:
66 |
67 |
68 | One
69 | Two
70 | Three
71 |
72 |
73 | Loose using tabs:
74 |
75 |
76 | First
77 | Second
78 | Third
79 |
80 |
81 | and using spaces:
82 |
83 |
84 | One
85 | Two
86 | Three
87 |
88 |
89 | Multiple paragraphs:
90 |
91 |
92 | Item 1, graf one.
93 |
94 | Item 2. graf two. The quick brown fox jumped over the lazy dog's
95 | back.
96 | Item 2.
97 | Item 3.
98 |
99 |
100 | Nested
101 |
102 |
111 |
112 | Here's another:
113 |
114 |
115 | First
116 | Second:
117 |
118 | Fee
119 | Fie
120 | Foe
121 |
122 | Third
123 |
124 |
125 | Same thing but with paragraphs:
126 |
127 |
128 | First
129 | Second:
130 |
131 |
132 | Fee
133 | Fie
134 | Foe
135 |
136 | Third
137 |
138 |
139 |
140 | This was an error in Markdown 1.0.1:
141 |
142 |
143 | this
144 |
145 |
146 |
147 | that
148 |
149 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/ordered_and_unordered_lists.text:
--------------------------------------------------------------------------------
1 | ## Unordered
2 |
3 | Asterisks tight:
4 |
5 | * asterisk 1
6 | * asterisk 2
7 | * asterisk 3
8 |
9 |
10 | Asterisks loose:
11 |
12 | * asterisk 1
13 |
14 | * asterisk 2
15 |
16 | * asterisk 3
17 |
18 | * * *
19 |
20 | Pluses tight:
21 |
22 | + Plus 1
23 | + Plus 2
24 | + Plus 3
25 |
26 |
27 | Pluses loose:
28 |
29 | + Plus 1
30 |
31 | + Plus 2
32 |
33 | + Plus 3
34 |
35 | * * *
36 |
37 |
38 | Minuses tight:
39 |
40 | - Minus 1
41 | - Minus 2
42 | - Minus 3
43 |
44 |
45 | Minuses loose:
46 |
47 | - Minus 1
48 |
49 | - Minus 2
50 |
51 | - Minus 3
52 |
53 |
54 | ## Ordered
55 |
56 | Tight:
57 |
58 | 1. First
59 | 2. Second
60 | 3. Third
61 |
62 | and:
63 |
64 | 1. One
65 | 2. Two
66 | 3. Three
67 |
68 |
69 | Loose using tabs:
70 |
71 | 1. First
72 |
73 | 2. Second
74 |
75 | 3. Third
76 |
77 | and using spaces:
78 |
79 | 1. One
80 |
81 | 2. Two
82 |
83 | 3. Three
84 |
85 | Multiple paragraphs:
86 |
87 | 1. Item 1, graf one.
88 |
89 | Item 2. graf two. The quick brown fox jumped over the lazy dog's
90 | back.
91 |
92 | 2. Item 2.
93 |
94 | 3. Item 3.
95 |
96 |
97 |
98 | ## Nested
99 |
100 | * Tab
101 | * Tab
102 | * Tab
103 |
104 | Here's another:
105 |
106 | 1. First
107 | 2. Second:
108 | * Fee
109 | * Fie
110 | * Foe
111 | 3. Third
112 |
113 | Same thing but with paragraphs:
114 |
115 | 1. First
116 |
117 | 2. Second:
118 | * Fee
119 | * Fie
120 | * Foe
121 |
122 | 3. Third
123 |
124 |
125 | This was an error in Markdown 1.0.1:
126 |
127 | * this
128 |
129 | * sub
130 |
131 | that
132 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/ref_paren.html:
--------------------------------------------------------------------------------
1 | hi
2 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/ref_paren.text:
--------------------------------------------------------------------------------
1 | [hi]
2 |
3 | [hi]: /url (there)
4 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/same_bullet.html:
--------------------------------------------------------------------------------
1 |
2 | test
3 | test
4 | test
5 |
6 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/same_bullet.text:
--------------------------------------------------------------------------------
1 | * test
2 | + test
3 | - test
4 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/strong_and_em_together.html:
--------------------------------------------------------------------------------
1 | This is strong and em.
2 |
3 | So is this word.
4 |
5 | This is strong and em.
6 |
7 | So is this word.
8 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/strong_and_em_together.text:
--------------------------------------------------------------------------------
1 | ***This is strong and em.***
2 |
3 | So is ***this*** word.
4 |
5 | ___This is strong and em.___
6 |
7 | So is ___this___ word.
8 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/tabs.html:
--------------------------------------------------------------------------------
1 |
7 |
8 | Code:
9 |
10 | this code block is indented by one tab
11 |
12 |
13 | And:
14 |
15 | this code block is indented by two tabs
16 |
17 |
18 | And:
19 |
20 | + this is an example list item
21 | indented with tabs
22 |
23 | + this is an example list item
24 | indented with spaces
25 |
26 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/tabs.text:
--------------------------------------------------------------------------------
1 | + this is a list item
2 | indented with tabs
3 |
4 | + this is a list item
5 | indented with spaces
6 |
7 | Code:
8 |
9 | this code block is indented by one tab
10 |
11 | And:
12 |
13 | this code block is indented by two tabs
14 |
15 | And:
16 |
17 | + this is an example list item
18 | indented with tabs
19 |
20 | + this is an example list item
21 | indented with spaces
22 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/text.smartypants.html:
--------------------------------------------------------------------------------
1 | Hello world ‘how’ “are” you — today…
2 |
3 | “It’s a more ‘challenging’ smartypants test…”
4 |
5 | ‘And,’ as a bonus — “one
6 | multiline” test!
7 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/text.smartypants.text:
--------------------------------------------------------------------------------
1 | Hello world 'how' "are" you -- today...
2 |
3 | "It's a more 'challenging' smartypants test..."
4 |
5 | 'And,' as a bonus -- "one
6 | multiline" test!
7 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/tidyness.html:
--------------------------------------------------------------------------------
1 |
2 | A list within a blockquote:
3 |
4 | asterisk 1
5 | asterisk 2
6 | asterisk 3
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/tidyness.text:
--------------------------------------------------------------------------------
1 | > A list within a blockquote:
2 | >
3 | > * asterisk 1
4 | > * asterisk 2
5 | > * asterisk 3
6 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/toplevel_paragraphs.gfm.html:
--------------------------------------------------------------------------------
1 | hello world
2 | how are you
3 | how are you
4 |
5 | hello world
6 | how are you
7 |
8 | hello world
9 |
10 |
11 | hello world
12 | how are you
13 |
14 | hello world
15 | how are you
16 |
17 | hello world
18 | how are you
19 |
20 | hello world
21 |
22 |
23 | hello world
24 | how are you
25 |
26 | hello world
27 | how are you
28 |
29 | hello world
30 |
31 |
32 | hello
33 |
34 | hello
35 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/toplevel_paragraphs.gfm.text:
--------------------------------------------------------------------------------
1 | hello world
2 | how are you
3 | how are you
4 |
5 | hello world
6 | ```
7 | how are you
8 | ```
9 |
10 | hello world
11 | * * *
12 |
13 | hello world
14 | # how are you
15 |
16 | hello world
17 | how are you
18 | ===========
19 |
20 | hello world
21 | > how are you
22 |
23 | hello world
24 | * how are you
25 |
26 | hello world
27 | how are you
28 |
29 | hello world
30 | how are you
31 |
32 | hello [world][how]
33 | [how]: /are/you
34 |
35 | hello
36 |
37 | hello
38 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/tricky_list.html:
--------------------------------------------------------------------------------
1 | hello world
2 |
3 |
6 |
7 | hello world
8 |
9 |
12 |
13 | hello world
14 |
15 |
18 |
19 | hello world
20 |
21 |
24 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/tricky_list.text:
--------------------------------------------------------------------------------
1 | **hello** _world_
2 |
3 | * hello world
4 |
5 | **hello** _world_
6 |
7 | * hello world
8 |
9 | **hello** _world_
10 |
11 | * Hello world
12 |
13 | **hello** _world_
14 |
15 | * hello world
16 |
--------------------------------------------------------------------------------
/app/bower_components/normalize-css/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "normalize-css",
3 | "version": "3.0.1",
4 | "main": "normalize.css",
5 | "author": "Nicolas Gallagher",
6 | "ignore": [
7 | "CHANGELOG.md",
8 | "CONTRIBUTING.md",
9 | "component.json",
10 | "package.json",
11 | "test.html"
12 | ],
13 | "homepage": "https://github.com/necolas/normalize.css",
14 | "_release": "3.0.1",
15 | "_resolution": {
16 | "type": "version",
17 | "tag": "3.0.1",
18 | "commit": "e3c71c911b0c0ebc0ee14d2421543ce1476fd761"
19 | },
20 | "_source": "git://github.com/necolas/normalize.css.git",
21 | "_target": "~3.0.1",
22 | "_originalSource": "normalize-css",
23 | "_direct": true
24 | }
--------------------------------------------------------------------------------
/app/bower_components/normalize-css/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) Nicolas Gallagher and Jonathan Neal
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of
4 | this software and associated documentation files (the "Software"), to deal in
5 | the Software without restriction, including without limitation the rights to
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 | of the Software, and to permit persons to whom the Software is furnished to do
8 | so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/app/bower_components/normalize-css/README.md:
--------------------------------------------------------------------------------
1 | # normalize.css v3
2 |
3 | Normalize.css is a customisable CSS file that makes browsers render all
4 | elements more consistently and in line with modern standards.
5 |
6 | The project relies on researching the differences between default browser
7 | styles in order to precisely target only the styles that need or benefit from
8 | normalizing.
9 |
10 | [View the test file](http://necolas.github.io/normalize.css/latest/test.html)
11 |
12 | ## Install
13 |
14 | Download from the [project page](http://necolas.github.io/normalize.css/).
15 |
16 | Install with [Component(1)](https://github.com/component/component/): `component install necolas/normalize.css`
17 |
18 | Install with [npm](http://npmjs.org/): `npm install --save normalize.css`
19 |
20 | Install with [Bower](http://bower.io/): `bower install --save normalize.css`
21 |
22 | ## What does it do?
23 |
24 | * Preserves useful defaults, unlike many CSS resets.
25 | * Normalizes styles for a wide range of elements.
26 | * Corrects bugs and common browser inconsistencies.
27 | * Improves usability with subtle improvements.
28 | * Explains what code does using detailed comments.
29 |
30 | ## How to use it
31 |
32 | No other styles should come before Normalize.css.
33 |
34 | It is recommended that you include the `normalize.css` file as untouched
35 | library code.
36 |
37 | ## Browser support
38 |
39 | * Google Chrome (latest)
40 | * Mozilla Firefox (latest)
41 | * Mozilla Firefox 4
42 | * Opera (latest)
43 | * Apple Safari 6+
44 | * Internet Explorer 8+
45 |
46 | [Normalize.css v1 provides legacy browser
47 | support](https://github.com/necolas/normalize.css/tree/v1) (IE 6+, Safari 4+),
48 | but is no longer actively developed.
49 |
50 | ## Contributing
51 |
52 | Please read the CONTRIBUTING.md
53 |
54 | ## Acknowledgements
55 |
56 | Normalize.css is a project by [Nicolas Gallagher](https://github.com/necolas),
57 | co-created with [Jonathan Neal](https://github.com/jonathantneal).
58 |
--------------------------------------------------------------------------------
/app/bower_components/normalize-css/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "normalize-css",
3 | "version": "3.0.1",
4 | "main": "normalize.css",
5 | "author": "Nicolas Gallagher",
6 | "ignore": [
7 | "CHANGELOG.md",
8 | "CONTRIBUTING.md",
9 | "component.json",
10 | "package.json",
11 | "test.html"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/app/bower_components/normalize-css/normalize.css:
--------------------------------------------------------------------------------
1 | /*! normalize.css v3.0.1 | MIT License | git.io/normalize */
2 |
3 | /**
4 | * 1. Set default font family to sans-serif.
5 | * 2. Prevent iOS text size adjust after orientation change, without disabling
6 | * user zoom.
7 | */
8 |
9 | html {
10 | font-family: sans-serif; /* 1 */
11 | -ms-text-size-adjust: 100%; /* 2 */
12 | -webkit-text-size-adjust: 100%; /* 2 */
13 | }
14 |
15 | /**
16 | * Remove default margin.
17 | */
18 |
19 | body {
20 | margin: 0;
21 | }
22 |
23 | /* HTML5 display definitions
24 | ========================================================================== */
25 |
26 | /**
27 | * Correct `block` display not defined for any HTML5 element in IE 8/9.
28 | * Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox.
29 | * Correct `block` display not defined for `main` in IE 11.
30 | */
31 |
32 | article,
33 | aside,
34 | details,
35 | figcaption,
36 | figure,
37 | footer,
38 | header,
39 | hgroup,
40 | main,
41 | nav,
42 | section,
43 | summary {
44 | display: block;
45 | }
46 |
47 | /**
48 | * 1. Correct `inline-block` display not defined in IE 8/9.
49 | * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
50 | */
51 |
52 | audio,
53 | canvas,
54 | progress,
55 | video {
56 | display: inline-block; /* 1 */
57 | vertical-align: baseline; /* 2 */
58 | }
59 |
60 | /**
61 | * Prevent modern browsers from displaying `audio` without controls.
62 | * Remove excess height in iOS 5 devices.
63 | */
64 |
65 | audio:not([controls]) {
66 | display: none;
67 | height: 0;
68 | }
69 |
70 | /**
71 | * Address `[hidden]` styling not present in IE 8/9/10.
72 | * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
73 | */
74 |
75 | [hidden],
76 | template {
77 | display: none;
78 | }
79 |
80 | /* Links
81 | ========================================================================== */
82 |
83 | /**
84 | * Remove the gray background color from active links in IE 10.
85 | */
86 |
87 | a {
88 | background: transparent;
89 | }
90 |
91 | /**
92 | * Improve readability when focused and also mouse hovered in all browsers.
93 | */
94 |
95 | a:active,
96 | a:hover {
97 | outline: 0;
98 | }
99 |
100 | /* Text-level semantics
101 | ========================================================================== */
102 |
103 | /**
104 | * Address styling not present in IE 8/9/10/11, Safari, and Chrome.
105 | */
106 |
107 | abbr[title] {
108 | border-bottom: 1px dotted;
109 | }
110 |
111 | /**
112 | * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
113 | */
114 |
115 | b,
116 | strong {
117 | font-weight: bold;
118 | }
119 |
120 | /**
121 | * Address styling not present in Safari and Chrome.
122 | */
123 |
124 | dfn {
125 | font-style: italic;
126 | }
127 |
128 | /**
129 | * Address variable `h1` font-size and margin within `section` and `article`
130 | * contexts in Firefox 4+, Safari, and Chrome.
131 | */
132 |
133 | h1 {
134 | font-size: 2em;
135 | margin: 0.67em 0;
136 | }
137 |
138 | /**
139 | * Address styling not present in IE 8/9.
140 | */
141 |
142 | mark {
143 | background: #ff0;
144 | color: #000;
145 | }
146 |
147 | /**
148 | * Address inconsistent and variable font size in all browsers.
149 | */
150 |
151 | small {
152 | font-size: 80%;
153 | }
154 |
155 | /**
156 | * Prevent `sub` and `sup` affecting `line-height` in all browsers.
157 | */
158 |
159 | sub,
160 | sup {
161 | font-size: 75%;
162 | line-height: 0;
163 | position: relative;
164 | vertical-align: baseline;
165 | }
166 |
167 | sup {
168 | top: -0.5em;
169 | }
170 |
171 | sub {
172 | bottom: -0.25em;
173 | }
174 |
175 | /* Embedded content
176 | ========================================================================== */
177 |
178 | /**
179 | * Remove border when inside `a` element in IE 8/9/10.
180 | */
181 |
182 | img {
183 | border: 0;
184 | }
185 |
186 | /**
187 | * Correct overflow not hidden in IE 9/10/11.
188 | */
189 |
190 | svg:not(:root) {
191 | overflow: hidden;
192 | }
193 |
194 | /* Grouping content
195 | ========================================================================== */
196 |
197 | /**
198 | * Address margin not present in IE 8/9 and Safari.
199 | */
200 |
201 | figure {
202 | margin: 1em 40px;
203 | }
204 |
205 | /**
206 | * Address differences between Firefox and other browsers.
207 | */
208 |
209 | hr {
210 | -moz-box-sizing: content-box;
211 | box-sizing: content-box;
212 | height: 0;
213 | }
214 |
215 | /**
216 | * Contain overflow in all browsers.
217 | */
218 |
219 | pre {
220 | overflow: auto;
221 | }
222 |
223 | /**
224 | * Address odd `em`-unit font size rendering in all browsers.
225 | */
226 |
227 | code,
228 | kbd,
229 | pre,
230 | samp {
231 | font-family: monospace, monospace;
232 | font-size: 1em;
233 | }
234 |
235 | /* Forms
236 | ========================================================================== */
237 |
238 | /**
239 | * Known limitation: by default, Chrome and Safari on OS X allow very limited
240 | * styling of `select`, unless a `border` property is set.
241 | */
242 |
243 | /**
244 | * 1. Correct color not being inherited.
245 | * Known issue: affects color of disabled elements.
246 | * 2. Correct font properties not being inherited.
247 | * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
248 | */
249 |
250 | button,
251 | input,
252 | optgroup,
253 | select,
254 | textarea {
255 | color: inherit; /* 1 */
256 | font: inherit; /* 2 */
257 | margin: 0; /* 3 */
258 | }
259 |
260 | /**
261 | * Address `overflow` set to `hidden` in IE 8/9/10/11.
262 | */
263 |
264 | button {
265 | overflow: visible;
266 | }
267 |
268 | /**
269 | * Address inconsistent `text-transform` inheritance for `button` and `select`.
270 | * All other form control elements do not inherit `text-transform` values.
271 | * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
272 | * Correct `select` style inheritance in Firefox.
273 | */
274 |
275 | button,
276 | select {
277 | text-transform: none;
278 | }
279 |
280 | /**
281 | * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
282 | * and `video` controls.
283 | * 2. Correct inability to style clickable `input` types in iOS.
284 | * 3. Improve usability and consistency of cursor style between image-type
285 | * `input` and others.
286 | */
287 |
288 | button,
289 | html input[type="button"], /* 1 */
290 | input[type="reset"],
291 | input[type="submit"] {
292 | -webkit-appearance: button; /* 2 */
293 | cursor: pointer; /* 3 */
294 | }
295 |
296 | /**
297 | * Re-set default cursor for disabled elements.
298 | */
299 |
300 | button[disabled],
301 | html input[disabled] {
302 | cursor: default;
303 | }
304 |
305 | /**
306 | * Remove inner padding and border in Firefox 4+.
307 | */
308 |
309 | button::-moz-focus-inner,
310 | input::-moz-focus-inner {
311 | border: 0;
312 | padding: 0;
313 | }
314 |
315 | /**
316 | * Address Firefox 4+ setting `line-height` on `input` using `!important` in
317 | * the UA stylesheet.
318 | */
319 |
320 | input {
321 | line-height: normal;
322 | }
323 |
324 | /**
325 | * It's recommended that you don't attempt to style these elements.
326 | * Firefox's implementation doesn't respect box-sizing, padding, or width.
327 | *
328 | * 1. Address box sizing set to `content-box` in IE 8/9/10.
329 | * 2. Remove excess padding in IE 8/9/10.
330 | */
331 |
332 | input[type="checkbox"],
333 | input[type="radio"] {
334 | box-sizing: border-box; /* 1 */
335 | padding: 0; /* 2 */
336 | }
337 |
338 | /**
339 | * Fix the cursor style for Chrome's increment/decrement buttons. For certain
340 | * `font-size` values of the `input`, it causes the cursor style of the
341 | * decrement button to change from `default` to `text`.
342 | */
343 |
344 | input[type="number"]::-webkit-inner-spin-button,
345 | input[type="number"]::-webkit-outer-spin-button {
346 | height: auto;
347 | }
348 |
349 | /**
350 | * 1. Address `appearance` set to `searchfield` in Safari and Chrome.
351 | * 2. Address `box-sizing` set to `border-box` in Safari and Chrome
352 | * (include `-moz` to future-proof).
353 | */
354 |
355 | input[type="search"] {
356 | -webkit-appearance: textfield; /* 1 */
357 | -moz-box-sizing: content-box;
358 | -webkit-box-sizing: content-box; /* 2 */
359 | box-sizing: content-box;
360 | }
361 |
362 | /**
363 | * Remove inner padding and search cancel button in Safari and Chrome on OS X.
364 | * Safari (but not Chrome) clips the cancel button when the search input has
365 | * padding (and `textfield` appearance).
366 | */
367 |
368 | input[type="search"]::-webkit-search-cancel-button,
369 | input[type="search"]::-webkit-search-decoration {
370 | -webkit-appearance: none;
371 | }
372 |
373 | /**
374 | * Define consistent border, margin, and padding.
375 | */
376 |
377 | fieldset {
378 | border: 1px solid #c0c0c0;
379 | margin: 0 2px;
380 | padding: 0.35em 0.625em 0.75em;
381 | }
382 |
383 | /**
384 | * 1. Correct `color` not being inherited in IE 8/9/10/11.
385 | * 2. Remove padding so people aren't caught out if they zero out fieldsets.
386 | */
387 |
388 | legend {
389 | border: 0; /* 1 */
390 | padding: 0; /* 2 */
391 | }
392 |
393 | /**
394 | * Remove default vertical scrollbar in IE 8/9/10/11.
395 | */
396 |
397 | textarea {
398 | overflow: auto;
399 | }
400 |
401 | /**
402 | * Don't inherit the `font-weight` (applied by a rule above).
403 | * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
404 | */
405 |
406 | optgroup {
407 | font-weight: bold;
408 | }
409 |
410 | /* Tables
411 | ========================================================================== */
412 |
413 | /**
414 | * Remove most spacing between table cells.
415 | */
416 |
417 | table {
418 | border-collapse: collapse;
419 | border-spacing: 0;
420 | }
421 |
422 | td,
423 | th {
424 | padding: 0;
425 | }
426 |
--------------------------------------------------------------------------------
/config.js:
--------------------------------------------------------------------------------
1 | var CONFIG = {
2 | // your website's title
3 | document_title: "ECMAScript 6入门",
4 |
5 | // index page
6 | index: "README.md",
7 |
8 | // sidebar file
9 | sidebar_file: "sidebar.md",
10 |
11 | // where the docs are actually stored on github - so you can edit
12 | base_url: "https://github.com/ruanyf/es6tutorial/edit/gh-pages",
13 | };
14 |
15 | // **************************
16 | // DON'T EDIT FOLLOWING CODES
17 | // **************************
18 |
19 | addConfig(ditto, CONFIG);
20 |
21 | function addConfig(obj, conf) {
22 | Object.keys(conf).forEach(function (key) {
23 | obj[key] = conf[key];
24 | });
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/css/app.css:
--------------------------------------------------------------------------------
1 | /* General Setting */
2 |
3 | /* Small screens (default) */
4 | html { font-size: 100%; }
5 |
6 | /* Medium screens (640px) */
7 | @media (min-width: 40rem) {
8 | html { font-size: 112%; }
9 | }
10 |
11 | /* Large screens (1024px) */
12 | @media (min-width: 64rem) {
13 | html { font-size: 120%; }
14 | }
15 |
16 | /* Grid */
17 |
18 | /* Ditto */
19 |
20 | body {
21 | color: #333;
22 | margin: 0;
23 | padding: 0;
24 |
25 | font-family: Verdana, Arial;
26 | font-size: 0.8rem;
27 | }
28 |
29 | #sidebar {
30 | margin-top: 0;
31 | padding-left: 25px;
32 | padding-bottom:25px;
33 | padding-top: 25px;
34 |
35 | box-shadow: 0 0 40px #CCC;
36 | -webkit-box-shadow: 0 0 40px #CCC;
37 | -moz-box-shadow: 0 0 40px #CCC;
38 | border-right: 1px solid #BBB;
39 | }
40 |
41 | @media (min-width: 40rem) {
42 | #sidebar {
43 | width: 280px;
44 | position: fixed;
45 | height: 100%;
46 | margin-right: 20px;
47 | padding-bottom:0px;
48 | padding-top: 0px;
49 | overflow-y: scroll;
50 | overflow: -moz-scrollbars-vertical;
51 | }
52 | }
53 |
54 | #sidebar h1 {
55 | font-size: 25px;
56 | margin-bottom: 0px;
57 | padding-bottom: 0px;
58 | }
59 |
60 | #sidebar h1 a:link, #sidebar h1 a:visited {
61 | color: #333;
62 | }
63 |
64 | #sidebar h2 {
65 | font-size: 0.7rem;
66 | }
67 |
68 | #sidebar h5 {
69 | margin-top: 20px;
70 | margin-bottom: 0;
71 | }
72 |
73 | #sidebar a:visited, #sidebar a:link {
74 | color: #4682BE;
75 | text-decoration: none;
76 | }
77 |
78 | #sidebar ul {
79 | list-style-type: none;
80 | margin: 0;
81 | padding-left: 10px;
82 | padding-top: 0;
83 | }
84 |
85 | #sidebar ol {
86 | margin: 0;
87 | padding-left: 30px;
88 | padding-top: 0;
89 | }
90 |
91 | #sidebar ul li:before { /* a hack to have dashes as a list style */
92 | content: "-";
93 | position: relative;
94 | left: -5px;
95 | }
96 |
97 | #sidebar ul li,
98 | #sidebar ol li {
99 | margin-top: 0;
100 | margin-bottom: 0.2rem;
101 | margin-left: 10px;
102 | padding: 0;
103 |
104 | text-indent: -5px; /* to compensate for the padding for the dash */
105 | font-size: 0.7rem;
106 | }
107 |
108 | form.searchBox {
109 | width: 180px;
110 | border: 1px solid #4682BE;
111 | height:20px;
112 | position: relative;
113 | }
114 |
115 | input[type=search] {
116 | position: absolute;
117 | top: 0;
118 | left: 0;
119 | width: 160px;
120 | height: 18px;
121 | text-align: left;
122 | border: none;
123 | }
124 |
125 | input.searchButton {
126 | position: absolute;
127 | top: 0;
128 | left: 160px;
129 | height: 18px;
130 | }
131 |
132 | #content {
133 | padding-top: 10px;
134 | padding-bottom: 150px;
135 | margin-left: 20px;
136 | margin-right: 20px;
137 | font-size: 0.8rem;
138 | line-height:1.3rem;
139 |
140 | /* border: 1px solid black; */
141 |
142 | counter-reset: section;
143 | }
144 |
145 | @media (min-width: 40rem) {
146 | #content {
147 | width: 580px;
148 | padding-left:330px;
149 | margin-left: 0px;
150 | margin-right: 0px;
151 | }
152 | }
153 |
154 | #content pre{
155 | margin-left: auto;
156 | margin-right: auto;
157 | padding-top: 10px;
158 | padding-bottom: 10px;
159 | padding-left: 0.7rem;
160 | line-height: 1.2;
161 |
162 | color: #FFF;
163 |
164 | background: #111;
165 | border-radius: 5px;
166 | }
167 |
168 | #content code {
169 | color: #a6e22e;
170 | font-size: 0.7rem;
171 | font-weight: normal;
172 | font-family: Consolas,"Courier New",Courier,FreeMono,monospace;
173 |
174 | background: #111;
175 | border-radius: 2px;
176 | }
177 |
178 | #content p code,
179 | #content li>code,
180 | #content h2>code,
181 | #content h3>code{
182 | padding-left: 3px;
183 | padding-right: 3px;
184 | color: #c7254e;
185 | background: #f9f2f4;
186 | }
187 |
188 | #content h2 {
189 | margin-top: 50px;
190 | margin-bottom: 0px;
191 |
192 | padding-top: 20px;
193 | padding-bottom: 0px;
194 |
195 | font-size: 18px;
196 | text-align: left;
197 |
198 | border-top: 2px solid #666;
199 |
200 | counter-increment: section;
201 | }
202 |
203 | #content h2:before {
204 | content: counter(section) ". ";
205 | }
206 |
207 | #content h3 {
208 | margin-top: 50px;
209 | margin-bottom: 0px;
210 |
211 | padding-top: 20px;
212 | padding-bottom: 0px;
213 |
214 | text-align: left;
215 | border-top: 1px dotted #777;
216 | }
217 |
218 | #content h2:hover,
219 | #content h3:hover {
220 | color: #ED1C24;
221 | }
222 |
223 | #content img {
224 | max-width: 90%;
225 | display: block;
226 |
227 | margin-left: auto;
228 | margin-right: auto;
229 | margin-top: 40px;
230 | margin-bottom: 40px;
231 |
232 | border-radius: 5px;
233 | }
234 |
235 | #content ul {
236 | display: block;
237 | list-style-type: none;
238 | padding-top: 0.5rem;
239 | padding-bottom:0.5rem;
240 | }
241 |
242 | #content ol {
243 | display: block;
244 | padding-top: 0.5rem;
245 | padding-bottom:0.5rem;
246 | }
247 |
248 |
249 | #content ul li:before { /* a hack to have dashes as a list style */
250 | content: "-";
251 | position: relative;
252 | left: -5px;
253 | }
254 |
255 | #content ul li,
256 | #content ol li{
257 | text-indent: -5px; /* to compensate for the padding for the dash */
258 | font-size: 0.8rem;
259 | }
260 |
261 | #content ul li.link,
262 | #content ol li.link {
263 | color: #2980b9;
264 | text-decoration: none;
265 | font-size: 0.7rem;
266 | font-weight: bold;
267 | cursor: pointer;
268 | }
269 |
270 | #content a:link, #content a:visited {
271 | color: #4682BE;
272 | text-decoration: none;
273 | }
274 |
275 | #content .content-toc{
276 | background: #bdc3c7;
277 | border-radius: 5px;
278 | }
279 |
280 | #content table{display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}
281 |
282 | #content table th{font-weight:bold}
283 |
284 | #content table th,
285 | #content table td{padding:6px 13px;border:1px solid #ddd}
286 |
287 | #content table tr{background-color:#fff;border-top:1px solid #ccc}
288 | #content table tr:nth-child(2n){background-color:#f8f8f8}
289 |
290 | #back_to_top {
291 | display: none;
292 | position: fixed;
293 |
294 | height: 20px;
295 | width: 70px;
296 | top: 20px;
297 |
298 | margin-left: 930px;
299 | margin-top: 0px;
300 |
301 | color: #FFF;
302 | line-height: 20px;
303 | text-align: center;
304 | font-size: 10px;
305 |
306 |
307 | border-radius: 5px;
308 | background-color: #AAA;
309 | }
310 |
311 | #back_to_top:hover {
312 | background-color: #444;
313 | cursor: pointer;
314 | }
315 |
316 | #edit {
317 | display: none;
318 | position: fixed;
319 |
320 | height: 17px;
321 | width: 70px;
322 | top: 45px;
323 |
324 | margin-left: 930px;
325 | margin-top: 0px;
326 |
327 | color: #FFF;
328 | line-height: 17px;
329 | text-align: center;
330 | font-size: 10px;
331 |
332 |
333 | border-radius: 5px;
334 | background-color: #AAA;
335 | }
336 |
337 | #edit:hover {
338 | background-color: #444;
339 | cursor: pointer;
340 | }
341 |
342 | #loading, #error {
343 | display: none;
344 | position: fixed;
345 |
346 | top: 0;
347 | height: 17px;
348 |
349 | font-size: 14px;
350 | }
351 |
352 | @media (min-width: 40rem) {
353 | #loading, #error {
354 | display: none;
355 | position: fixed;
356 |
357 | height: 17px;
358 | top: 45%;
359 |
360 | margin-left: 560px;
361 |
362 | font-size: 14px;
363 | }
364 | }
365 |
366 | #flip{
367 | position:fixed;
368 | height:20px;
369 | width:100%;
370 | bottom:10px;
371 | font-size:10px;
372 | text-align:center;
373 | }
374 |
375 | #pageup,#pagedown{
376 | height:20px;
377 | width:70px;
378 | display:inline-block;
379 | border-radius: 5px;
380 | background-color: #AAA;
381 | text-align: center;
382 | line-height:20px;
383 | color: #FFF;
384 | }
385 |
386 | #pageup{
387 | margin-right:5px;
388 | }
389 |
390 | #pageup:hover,
391 | #pagedown:hover{
392 | background-color: #444;
393 | cursor: pointer;
394 | }
395 |
396 | #pagedown{
397 | margin-left:5px;
398 | }
399 |
400 | @media (min-width: 40rem) {
401 | #flip{
402 | margin-left:545px;
403 | width:150px;
404 | }
405 | }
406 |
407 | .progress-indicator-2 {
408 | position: fixed;
409 | top: 0;
410 | left: 0;
411 | height: 3px;
412 | background-color: #0A74DA;
413 | }
414 |
415 | /**
416 | * okaidia theme for JavaScript, CSS and HTML
417 | * Loosely based on Monokai textmate theme by http://www.monokai.nl/
418 | * @author ocodia
419 | */
420 |
421 | code[class*="language-"],
422 | pre[class*="language-"] {
423 | color: #a6e22e;
424 | text-shadow: 0 1px rgba(0,0,0,0.3);
425 | font-family: Consolas, Monaco, 'Andale Mono', monospace;
426 | direction: ltr;
427 | text-align: left;
428 | white-space: pre;
429 | word-spacing: normal;
430 | word-break: normal;
431 |
432 | -moz-tab-size: 4;
433 | -o-tab-size: 4;
434 | tab-size: 4;
435 |
436 | -webkit-hyphens: none;
437 | -moz-hyphens: none;
438 | -ms-hyphens: none;
439 | hyphens: none;
440 | }
441 |
442 | /* Code blocks */
443 | pre[class*="language-"] {
444 | padding: 1em;
445 | margin: .5em 0;
446 | overflow: auto;
447 | border-radius: 0.3em;
448 | }
449 |
450 | :not(pre) > code[class*="language-"],
451 | pre[class*="language-"] {
452 | background: #272822;
453 | }
454 |
455 | /* Inline code */
456 | :not(pre) > code[class*="language-"] {
457 | padding: .1em;
458 | border-radius: .3em;
459 | }
460 |
461 | .token.comment,
462 | .token.prolog,
463 | .token.doctype,
464 | .token.cdata {
465 | color: #75715e;
466 | }
467 |
468 | .token.punctuation {
469 | color: #f8f8f2;
470 | }
471 |
472 | .namespace {
473 | opacity: .7;
474 | }
475 |
476 | .token.property,
477 | .token.tag,
478 | .token.constant,
479 | .token.symbol {
480 | color: #f92672;
481 | }
482 |
483 | .token.boolean,
484 | .token.number{
485 | color: #ae81ff;
486 | }
487 |
488 | .token.selector,
489 | .token.attr-name,
490 | .token.string,
491 | .token.builtin {
492 | color: #a6e22e;
493 | }
494 |
495 |
496 | .token.operator,
497 | .token.entity,
498 | .token.url,
499 | .language-css .token.string,
500 | .style .token.string,
501 | .token.variable {
502 | color: #f92672;
503 | }
504 |
505 | .token.atrule,
506 | .token.attr-value
507 | {
508 | color: #e6db74;
509 | }
510 |
511 |
512 | .token.keyword{
513 | color: #66d9ef;
514 | }
515 |
516 | .token.regex,
517 | .token.important {
518 | color: #fd971f;
519 | }
520 |
521 | .token.important {
522 | font-weight: bold;
523 | }
524 |
525 | .token.entity {
526 | cursor: help;
527 | }
528 |
--------------------------------------------------------------------------------
/css/normalize.css:
--------------------------------------------------------------------------------
1 | ../app/bower_components/normalize-css/normalize.css
--------------------------------------------------------------------------------
/docs/fp.md:
--------------------------------------------------------------------------------
1 | # 函数式编程
2 |
3 | JavaScript语言从一诞生,就具有函数式编程的烙印。它将函数作为一种独立的数据类型,与其他数据类型处于完全平等的地位。在JavaScript语言中,你可以采用面向对象编程,也可以采用函数式编程。有人甚至说,JavaScript是有史以来第一种被大规模采用的函数式编程语言。
4 |
5 | ES6的种种新增功能,使得函数式编程变得更方便、更强大。本章介绍ES6如何进行函数式编程。
6 |
7 | ## 柯里化
8 |
9 | 柯里化(currying)指的是将一个多参数的函数拆分成一系列函数,每个拆分后的函数都只接受一个参数(unary)。
10 |
11 | ```javascript
12 | function add (a, b) {
13 | return a + b;
14 | }
15 |
16 | add(1, 1) // 2
17 | ```
18 |
19 | 上面代码中,函数`add`接受两个参数`a`和`b`。
20 |
21 | 柯里化就是将上面的函数拆分成两个函数,每个函数都只接受一个参数。
22 |
23 | ```javascript
24 | function add (a) {
25 | return function (b) {
26 | return a + b;
27 | }
28 | }
29 | // 或者采用箭头函数写法
30 | const add = x => y => x + y;
31 |
32 | const f = add(1);
33 | f(1) // 2
34 | ```
35 |
36 | 上面代码中,函数`add`只接受一个参数`a`,返回一个函数`f`。函数`f`也只接受一个参数`b`。
37 |
38 | ## 函数合成
39 |
40 | 函数合成(function composition)指的是,将多个函数合成一个函数。
41 |
42 | ```javascript
43 | const compose = f => g => x => f(g(x));
44 |
45 | const f = compose (x => x * 4) (x => x + 3);
46 | f(2) // 20
47 | ```
48 |
49 | 上面代码中,`compose`就是一个函数合成器,用于将两个函数合成一个函数。
50 |
51 | 可以发现,柯里化与函数合成有着密切的联系。前者用于将一个函数拆成多个函数,后者用于将多个函数合并成一个函数。
52 |
53 | ## 参数倒置
54 |
55 | 参数倒置(flip)指的是改变函数前两个参数的顺序。
56 |
57 | ```javascript
58 | var divide = (a, b) => a / b;
59 | var flip = f.flip(divide);
60 |
61 | flip(10, 5) // 0.5
62 | flip(1, 10) // 10
63 |
64 | var three = (a, b, c) => [a, b, c];
65 | var flip = f.flip(three);
66 | flip(1, 2, 3); // => [2, 1, 3]
67 | ```
68 |
69 | 上面代码中,如果按照正常的参数顺序,10除以5等于2。但是,参数倒置以后得到的新函数,结果就是5除以10,结果得到0.5。如果原函数有3个参数,则只颠倒前两个参数的位置。
70 |
71 | 参数倒置的代码非常简单。
72 |
73 | ```javascript
74 | let f = {};
75 | f.flip =
76 | fn =>
77 | (a, b, ...args) => fn(b, a, ...args.reverse());
78 | ```
79 |
80 | ## 执行边界
81 |
82 | 执行边界(until)指的是函数执行到满足条件为止。
83 |
84 | ```javascript
85 | let condition = x => x > 100;
86 | let inc = x => x + 1;
87 | let until = f.until(condition, inc);
88 |
89 | until(0) // 101
90 |
91 | condition = x => x === 5;
92 | until = f.until(condition, inc);
93 |
94 | until(3) // 5
95 | ```
96 |
97 | 上面代码中,第一段的条件是执行到`x`大于100为止,所以`x`初值为0时,会一直执行到101。第二段的条件是执行到等于5为止,所以`x`最后的值是5。
98 |
99 | 执行边界的实现如下。
100 |
101 | ```javascript
102 | let f = {};
103 | f.until = (condition, f) =>
104 | (...args) => {
105 | var r = f.apply(null, args);
106 | return condition(r) ? r : f.until(condition, f)(r);
107 | };
108 | ```
109 |
110 | 上面代码的关键就是,如果满足条件就返回结果,否则不断递归执行。
111 |
112 | ## 队列操作
113 |
114 | 队列(list)操作包括以下几种。
115 |
116 | - `head`: 取出队列的第一个非空成员。
117 | - `last`: 取出有限队列的最后一个非空成员。
118 | - `tail`: 取出除了“队列头”以外的其他非空成员。
119 | - `init`: 取出除了“队列尾”以外的其他非空成员。
120 |
121 | 下面是例子。
122 |
123 | ```javascript
124 | f.head(5, 27, 3, 1) // 5
125 | f.last(5, 27, 3, 1) // 1
126 | f.tail(5, 27, 3, 1) // [27, 3, 1]
127 | f.init(5, 27, 3, 1) // [5, 27, 3]
128 | ```
129 |
130 | 这些方法的实现如下。
131 |
132 | ```javascript
133 | let f = {};
134 | f.head = (...xs) => xs[0];
135 | f.last = (...xs) => xs.slice(-1);
136 | f.tail = (...xs) => Array.prototype.slice.call(xs, 1);
137 | f.init = (...xs) => xs.slice(0, -1);
138 | ```
139 |
140 | ## 合并操作
141 |
142 | 合并操作分为`concat`和`concatMap`两种。前者就是将多个数组合成一个,后者则是先处理一下参数,然后再将处理结果合成一个数组。
143 |
144 | ```javascript
145 | f.concat([5], [27], [3]) // [5, 27, 3]
146 | f.concatMap(x => 'hi ' + x, 1, [[2]], 3) // ['hi 1', 'hi 2', 'hi 3']
147 | ```
148 |
149 | 这两种方法的实现代码如下。
150 |
151 | ```javascript
152 | let f = {};
153 | f.concat =
154 | (...xs) => xs.reduce((a, b) => a.concat(b));
155 | f.concatMap =
156 | (f, ...xs) => f.concat(xs.map(f));
157 | ```
158 |
159 | ## 配对操作
160 |
161 | 配对操作分为`zip`和`zipWith`两种方法。`zip`操作将两个队列的成员,一一配对,合成一个新的队列。如果两个队列不等长,较长的那个队列多出来的成员,会被忽略。`zipWith`操作的第一个参数是一个函数,然后会将后面的队列成员一一配对,输入该函数,返回值就组成一个新的队列。
162 |
163 | 下面是例子。
164 |
165 | ```javascript
166 | let a = [0, 1, 2];
167 | let b = [3, 4, 5];
168 | let c = [6, 7, 8];
169 |
170 | f.zip(a, b) // [[0, 3], [1, 4], [2, 5]]
171 | f.zipWith((a, b) => a + b, a, b, c) // [9, 12, 15]
172 | ```
173 |
174 | 上面代码中,`zipWith`方法的第一个参数是一个求和函数,它将后面三个队列的成员,一一配对进行相加。
175 |
176 | 这两个方法的实现如下。
177 |
178 | ```javascript
179 | let f = {};
180 |
181 | f.zip = (...xs) => {
182 | let r = [];
183 | let nple = [];
184 | let length = Math.min.apply(null, xs.map(x => x.length));
185 |
186 | for (var i = 0; i < length; i++) {
187 | xs.forEach(
188 | x => nple.push(x[i])
189 | );
190 |
191 | r.push(nple);
192 | nple = [];
193 | }
194 |
195 | return r;
196 | };
197 |
198 | f.zipWith = (op, ...xs) =>
199 | f.zip.apply(null, xs).map(
200 | (x) => x.reduce(op)
201 | );
202 | ```
203 |
204 | ## 参考链接
205 |
206 | - Mateo Gianolio, [Haskell in ES6: Part 1](http://casualjavascript.com/?1)
207 |
--------------------------------------------------------------------------------
/docs/mixin.md:
--------------------------------------------------------------------------------
1 | # Mixin
2 |
3 | JavaScript语言的设计是单一继承,即子类只能继承一个父类,不允许继承多个父类。这种设计保证了对象继承的层次结构是树状的,而不是复杂的[网状结构](https://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem)。
4 |
5 | 但是,这大大降低了编程的灵活性。因为实际开发中,有时不可避免,子类需要继承多个父类。举例来说,“猫”可以继承“哺乳类动物”,也可以继承“宠物”。
6 |
7 | 各种单一继承的编程语言,有不同的多重继承解决方案。比如,Java语言也是子类只能继承一个父类,但是还允许继承多个界面(interface),这样就间接实现了多重继承。Interface与父类一样,也是一个类,只不过它只定义接口(method signature),不定义实现,因此又被称为“抽象类”。凡是继承于Interface的方法,都必须自己定义实现,否则就会报错。这样就避免了多重继承的最大问题:多个父类的同名方法的碰撞(naming collision)。
8 |
9 | JavaScript语言没有采用Interface的方案,而是通过代理(delegation)实现了从其他类引入方法。
10 |
11 | ```javascript
12 | var Enumerable_first = function () {
13 | this.first = function () {
14 | return this[0];
15 | };
16 | };
17 |
18 | var list = ["foo", "bar", "baz"];
19 | Enumerable_first.call(list); // explicit delegation
20 | list.first() // "foo"
21 | ```
22 |
23 | 上面代码中,`list`是一个数组,本身并没有`first`方法。通过`call`方法,可以把`Enumerable_first`里面的方法,绑定到`list`,从而`list`就具有`first`方法。这就叫做“代理”(delegation),`list`对象代理了`Enumerable_first`的`first`方法。
24 |
25 | ## 含义
26 |
27 | Mixin这个名字来自于冰淇淋,在基本口味的冰淇淋上面混入其他口味,这就叫做Mix-in。
28 |
29 | 它允许向一个类里面注入一些代码,使得一个类的功能能够“混入”另一个类。实质上是多重继承的一种解决方案,但是避免了多重继承的复杂性,而且有利于代码复用。
30 |
31 | Mixin就是一个正常的类,不仅定义了接口,还定义了接口的实现。
32 |
33 | 子类通过在`this`对象上面绑定方法,达到多重继承的目的。
34 |
35 | 很多库提供了Mixin功能。下面以Lodash为例。
36 |
37 | ```javascript
38 | function vowels(string) {
39 | return /[aeiou]/i.test(this.value);
40 | }
41 |
42 | var obj = { value: 'hello' };
43 | _.mixin(obj, {vowels: vowels})
44 | obj.vowels() // true
45 | ```
46 |
47 | 上面代码通过Lodash库的`_.mixin`方法,让`obj`对象继承了`vowels`方法。
48 |
49 | Underscore的类似方法是`_.extend`。
50 |
51 | ```javascript
52 | var Person = function (fName, lName) {
53 | this.firstName = fName;
54 | this.lastName = lName;
55 | }
56 |
57 | var sam = new Person('Sam', 'Lowry');
58 |
59 | var NameMixin = {
60 | fullName: function () {
61 | return this.firstName + ' ' + this.lastName;
62 | },
63 | rename: function(first, last) {
64 | this.firstName = first;
65 | this.lastName = last;
66 | return this;
67 | }
68 | };
69 | _.extend(Person.prototype, NameMixin);
70 | sam.rename('Samwise', 'Gamgee');
71 | sam.fullName() // "Samwise Gamgee"
72 | ```
73 |
74 | 上面代码通过`_.extend`方法,在`sam`对象上面(准确说是它的原型对象`Person.prototype`上面),混入了`NameMixin`类。
75 |
76 | `extend`方法的实现非常简单。
77 |
78 | ```javascript
79 | function extend(destination, source) {
80 | for (var k in source) {
81 | if (source.hasOwnProperty(k)) {
82 | destination[k] = source[k];
83 | }
84 | }
85 | return destination;
86 | }
87 | ```
88 |
89 | 上面代码将`source`对象的所有方法,添加到`destination`对象。
90 |
91 | ## Trait
92 |
93 | Trait是另外一种多重继承的解决方案。它与Mixin很相似,但是有一些细微的差别。
94 |
95 | - Mixin可以包含状态(state),Trait不包含,即Trait里面的方法都是互不相干,可以线性包含的。比如,`Trait1`包含方法`A`和`B`,`Trait2`继承了`Trait1`,同时还包含一个自己的方法`C`,实际上就等同于直接包含方法`A`、`B`、`C`。
96 | - 对于同名方法的碰撞,Mixin包含了解决规则,Trait则是报错。
97 |
--------------------------------------------------------------------------------
/docs/spec.md:
--------------------------------------------------------------------------------
1 | # 读懂 ECMAScript 规格
2 |
3 | ## 概述
4 |
5 | 规格文件是计算机语言的官方标准,详细描述语法规则和实现方法。
6 |
7 | 一般来说,没有必要阅读规格,除非你要写编译器。因为规格写得非常抽象和精炼,又缺乏实例,不容易理解,而且对于解决实际的应用问题,帮助不大。但是,如果你遇到疑难的语法问题,实在找不到答案,这时可以去查看规格文件,了解语言标准是怎么说的。规格是解决问题的“最后一招”。
8 |
9 | 这对JavaScript语言很有必要。因为它的使用场景复杂,语法规则不统一,例外很多,各种运行环境的行为不一致,导致奇怪的语法问题层出不穷,任何语法书都不可能囊括所有情况。查看规格,不失为一种解决语法问题的最可靠、最权威的终极方法。
10 |
11 | 本章介绍如何读懂ECMAScript 6的规格文件。
12 |
13 | ECMAScript 6的规格,可以在ECMA国际标准组织的官方网站([www.ecma-international.org/ecma-262/6.0/](http://www.ecma-international.org/ecma-262/6.0/))免费下载和在线阅读。
14 |
15 | 这个规格文件相当庞大,一共有26章,A4打印的话,足足有545页。它的特点就是规定得非常细致,每一个语法行为、每一个函数的实现都做了详尽的清晰的描述。基本上,编译器作者只要把每一步翻译成代码就可以了。这很大程度上,保证了所有ES6实现都有一致的行为。
16 |
17 | ECMAScript 6规格的26章之中,第1章到第3章是对文件本身的介绍,与语言关系不大。第4章是对这门语言总体设计的描述,有兴趣的读者可以读一下。第5章到第8章是语言宏观层面的描述。第5章是规格的名词解释和写法的介绍,第6章介绍数据类型,第7章介绍语言内部用到的抽象操作,第8章介绍代码如何运行。第9章到第26章介绍具体的语法。
18 |
19 | 对于一般用户来说,除了第4章,其他章节都涉及某一方面的细节,不用通读,只要在用到的时候,查阅相关章节即可。下面通过一些例子,介绍如何使用这份规格。
20 |
21 | ## 相等运算符
22 |
23 | 相等运算符(`==`)是一个很让人头痛的运算符,它的语法行为多变,不符合直觉。这个小节就看看规格怎么规定它的行为。
24 |
25 | 请看下面这个表达式,请问它的值是多少。
26 |
27 | ```javascript
28 | 0 == null
29 | ```
30 |
31 | 如果你不确定答案,或者想知道语言内部怎么处理,就可以去查看规格,[7.2.12小节](http://www.ecma-international.org/ecma-262/6.0/#sec-7.2.12)是对相等运算符(`==`)的描述。
32 |
33 | 规格对每一种语法行为的描述,都分成两部分:先是总体的行为描述,然后是实现的算法细节。相等运算符的总体描述,只有一句话。
34 |
35 | > “The comparison `x == y`, where `x` and `y` are values, produces `true` or `false`.”
36 |
37 | 上面这句话的意思是,相等运算符用于比较两个值,返回`true`或`false`。
38 |
39 | 下面是算法细节。
40 |
41 | > 1. ReturnIfAbrupt(x).
42 | > 1. ReturnIfAbrupt(y).
43 | > 1. If `Type(x)` is the same as `Type(y)`, then
44 | > Return the result of performing Strict Equality Comparison `x === y`.
45 | > 1. If `x` is `null` and `y` is `undefined`, return `true`.
46 | > 1. If `x` is `undefined` and `y` is `null`, return `true`.
47 | > 1. If `Type(x)` is Number and `Type(y)` is String,
48 | > return the result of the comparison `x == ToNumber(y)`.
49 | > 1. If `Type(x)` is String and `Type(y)` is Number,
50 | > return the result of the comparison `ToNumber(x) == y`.
51 | > 1. If `Type(x)` is Boolean, return the result of the comparison `ToNumber(x) == y`.
52 | > 1. If `Type(y)` is Boolean, return the result of the comparison `x == ToNumber(y)`.
53 | > 1. If `Type(x)` is either String, Number, or Symbol and `Type(y)` is Object, then
54 | > return the result of the comparison `x == ToPrimitive(y)`.
55 | > 1. If `Type(x)` is Object and `Type(y)` is either String, Number, or Symbol, then
56 | > return the result of the comparison `ToPrimitive(x) == y`.
57 | > 1. Return `false`.
58 |
59 | 上面这段算法,一共有12步,翻译如下。
60 |
61 | > 1. 如果`x`不是正常值(比如抛出一个错误),中断执行。
62 | > 1. 如果`y`不是正常值,中断执行。
63 | > 1. 如果`Type(x)`与`Type(y)`相同,执行严格相等运算`x === y`。
64 | > 1. 如果`x`是`null`,`y`是`undefined`,返回`true`。
65 | > 1. 如果`x`是`undefined`,`y`是`null`,返回`true`。
66 | > 1. 如果`Type(x)`是数值,`Type(y)`是字符串,返回`x == ToNumber(y)`的结果。
67 | > 1. 如果`Type(x)`是字符串,`Type(y)`是数值,返回`ToNumber(x) == y`的结果。
68 | > 1. 如果`Type(x)`是布尔值,返回`ToNumber(x) == y`的结果。
69 | > 1. 如果`Type(y)`是布尔值,返回`x == ToNumber(y)`的结果。
70 | > 1. 如果`Type(x)`是字符串或数值或`Symbol`值,`Type(y)`是对象,返回`x == ToPrimitive(y)`的结果。
71 | > 1. 如果`Type(x)`是对象,`Type(y)`是字符串或数值或`Symbol`值,返回`ToPrimitive(x) == y`的结果。
72 | > 1. 返回`false`。
73 |
74 | 由于`0`的类型是数值,`null`的类型是Null(这是规格[4.3.13小节](http://www.ecma-international.org/ecma-262/6.0/#sec-4.3.13)的规定,是内部Type运算的结果,跟`typeof`运算符无关)。因此上面的前11步都得不到结果,要到第12步才能得到`false`。
75 |
76 | ```javascript
77 | 0 == null // false
78 | ```
79 |
80 | ## 数组的空位
81 |
82 | 下面再看另一个例子。
83 |
84 | ```javascript
85 | const a1 = [undefined, undefined, undefined];
86 | const a2 = [, , ,];
87 |
88 | a1.length // 3
89 | a2.length // 3
90 |
91 | a1[0] // undefined
92 | a2[0] // undefined
93 |
94 | a1[0] === a2[0] // true
95 | ```
96 |
97 | 上面代码中,数组`a1`的成员是三个`undefined`,数组`a2`的成员是三个空位。这两个数组很相似,长度都是3,每个位置的成员读取出来都是`undefined`。
98 |
99 | 但是,它们实际上存在重大差异。
100 |
101 | ```javascript
102 | 0 in a1 // true
103 | 0 in a2 // false
104 |
105 | a1.hasOwnProperty(0) // true
106 | a2.hasOwnProperty(0) // false
107 |
108 | Object.keys(a1) // ["0", "1", "2"]
109 | Object.keys(a2) // []
110 |
111 | a1.map(n => 1) // [1, 1, 1]
112 | a2.map(n => 1) // [, , ,]
113 | ```
114 |
115 | 上面代码一共列出了四种运算,数组`a1`和`a2`的结果都不一样。前三种运算(`in`运算符、数组的`hasOwnProperty`方法、`Object.keys`方法)都说明,数组`a2`取不到属性名。最后一种运算(数组的`map`方法)说明,数组`a2`没有发生遍历。
116 |
117 | 为什么`a1`与`a2`成员的行为不一致?数组的成员是`undefined`或空位,到底有什么不同?
118 |
119 | 规格的[12.2.5小节《数组的初始化》](http://www.ecma-international.org/ecma-262/6.0/#sec-12.2.5)给出了答案。
120 |
121 | > “Array elements may be elided at the beginning, middle or end of the element list. Whenever a comma in the element list is not preceded by an AssignmentExpression (i.e., a comma at the beginning or after another comma), the missing array element contributes to the length of the Array and increases the index of subsequent elements. Elided array elements are not defined. If an element is elided at the end of an array, that element does not contribute to the length of the Array.”
122 |
123 | 翻译如下。
124 |
125 | > "数组成员可以省略。只要逗号前面没有任何表达式,数组的`length`属性就会加1,并且相应增加其后成员的位置索引。被省略的成员不会被定义。如果被省略的成员是数组最后一个成员,则不会导致数组`length`属性增加。”
126 |
127 | 上面的规格说得很清楚,数组的空位会反映在`length`属性,也就是说空位有自己的位置,但是这个位置的值是未定义,即这个值是不存在的。如果一定要读取,结果就是`undefined`(因为`undefined`在JavaScript语言中表示不存在)。
128 |
129 | 这就解释了为什么`in`运算符、数组的`hasOwnProperty`方法、`Object.keys`方法,都取不到空位的属性名。因为这个属性名根本就不存在,规格里面没说要为空位分配属性名(位置索引),只说要为下一个元素的位置索引加1。
130 |
131 | 至于为什么数组的`map`方法会跳过空位,请看下一节。
132 |
133 | ## 数组的map方法
134 |
135 | 规格的[22.1.3.15小节](http://www.ecma-international.org/ecma-262/6.0/#sec-22.1.3.15)定义了数组的`map`方法。该小节先是总体描述`map`方法的行为,里面没有提到数组空位。
136 |
137 | 后面的算法描述是这样的。
138 |
139 | > 1. Let `O` be `ToObject(this value)`.
140 | > 1. `ReturnIfAbrupt(O)`.
141 | > 1. Let `len` be `ToLength(Get(O, "length"))`.
142 | > 1. `ReturnIfAbrupt(len)`.
143 | > 1. If `IsCallable(callbackfn)` is `false`, throw a TypeError exception.
144 | > 1. If `thisArg` was supplied, let `T` be `thisArg`; else let `T` be `undefined`.
145 | > 1. Let `A` be `ArraySpeciesCreate(O, len)`.
146 | > 1. `ReturnIfAbrupt(A)`.
147 | > 1. Let `k` be 0.
148 | > 1. Repeat, while `k` < `len`
149 | > a. Let `Pk` be `ToString(k)`.
150 | > b. Let `kPresent` be `HasProperty(O, Pk)`.
151 | > c. `ReturnIfAbrupt(kPresent)`.
152 | > d. If `kPresent` is `true`, then
153 | > d-1. Let `kValue` be `Get(O, Pk)`.
154 | > d-2. `ReturnIfAbrupt(kValue)`.
155 | > d-3. Let `mappedValue` be `Call(callbackfn, T, «kValue, k, O»)`.
156 | > d-4. `ReturnIfAbrupt(mappedValue)`.
157 | > d-5. Let `status` be `CreateDataPropertyOrThrow (A, Pk, mappedValue)`.
158 | > d-6. `ReturnIfAbrupt(status)`.
159 | > e. Increase `k` by 1.
160 | > 1. Return `A`.
161 |
162 | 翻译如下。
163 |
164 | > 1. 得到当前数组的`this`对象
165 | > 1. 如果报错就返回
166 | > 1. 求出当前数组的`length`属性
167 | > 1. 如果报错就返回
168 | > 1. 如果map方法的参数`callbackfn`不可执行,就报错
169 | > 1. 如果map方法的参数之中,指定了`this`,就让`T`等于该参数,否则`T`为`undefined`
170 | > 1. 生成一个新的数组`A`,跟当前数组的`length`属性保持一致
171 | > 1. 如果报错就返回
172 | > 1. 设定`k`等于0
173 | > 1. 只要`k`小于当前数组的`length`属性,就重复下面步骤
174 | > a. 设定`Pk`等于`ToString(k)`,即将`K`转为字符串
175 | > b. 设定`kPresent`等于`HasProperty(O, Pk)`,即求当前数组有没有指定属性
176 | > c. 如果报错就返回
177 | > d. 如果`kPresent`等于`true`,则进行下面步骤
178 | > d-1. 设定`kValue`等于`Get(O, Pk)`,取出当前数组的指定属性
179 | > d-2. 如果报错就返回
180 | > d-3. 设定`mappedValue`等于`Call(callbackfn, T, «kValue, k, O»)`,即执行回调函数
181 | > d-4. 如果报错就返回
182 | > d-5. 设定`status`等于`CreateDataPropertyOrThrow (A, Pk, mappedValue)`,即将回调函数的值放入`A`数组的指定位置
183 | > d-6. 如果报错就返回
184 | > e. `k`增加1
185 | > 1. 返回`A`
186 |
187 | 仔细查看上面的算法,可以发现,当处理一个全是空位的数组时,前面步骤都没有问题。进入第10步的b时,`kpresent`会报错,因为空位对应的属性名,对于数组来说是不存在的,因此就会返回,不会进行后面的步骤。
188 |
189 | ```javascript
190 | const arr = [, , ,];
191 | arr.map(n => {
192 | console.log(n);
193 | return 1;
194 | }) // [, , ,]
195 | ```
196 |
197 | 上面代码中,`arr`是一个全是空位的数组,`map`方法遍历成员时,发现是空位,就直接跳过,不会进入回调函数。因此,回调函数里面的`console.log`语句根本不会执行,整个`map`方法返回一个全是空位的新数组。
198 |
199 | V8引擎对`map`方法的[实现](https://github.com/v8/v8/blob/44c44521ae11859478b42004f57ea93df52526ee/src/js/array.js#L1347)如下,可以看到跟规格的算法描述完全一致。
200 |
201 | ```javascript
202 | function ArrayMap(f, receiver) {
203 | CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map");
204 |
205 | // Pull out the length so that modifications to the length in the
206 | // loop will not affect the looping and side effects are visible.
207 | var array = TO_OBJECT(this);
208 | var length = TO_LENGTH_OR_UINT32(array.length);
209 | return InnerArrayMap(f, receiver, array, length);
210 | }
211 |
212 | function InnerArrayMap(f, receiver, array, length) {
213 | if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
214 |
215 | var accumulator = new InternalArray(length);
216 | var is_array = IS_ARRAY(array);
217 | var stepping = DEBUG_IS_STEPPING(f);
218 | for (var i = 0; i < length; i++) {
219 | if (HAS_INDEX(array, i, is_array)) {
220 | var element = array[i];
221 | // Prepare break slots for debugger step in.
222 | if (stepping) %DebugPrepareStepInIfStepping(f);
223 | accumulator[i] = %_Call(f, receiver, element, i, array);
224 | }
225 | }
226 | var result = new GlobalArray();
227 | %MoveArrayContents(accumulator, result);
228 | return result;
229 | }
230 | ```
231 |
--------------------------------------------------------------------------------
/docs/style.md:
--------------------------------------------------------------------------------
1 | # 编程风格
2 |
3 | 本章探讨如何将ES6的新语法,运用到编码实践之中,与传统的JavaScript语法结合在一起,写出合理的、易于阅读和维护的代码。
4 |
5 | 多家公司和组织已经公开了它们的风格规范,具体可参阅[jscs.info](http://jscs.info/),下面的内容主要参考了[Airbnb](https://github.com/airbnb/javascript)的JavaScript风格规范。
6 |
7 | ## 块级作用域
8 |
9 | **(1)let 取代 var**
10 |
11 | ES6提出了两个新的声明变量的命令:`let`和`const`。其中,`let`完全可以取代`var`,因为两者语义相同,而且`let`没有副作用。
12 |
13 | ```javascript
14 | 'use strict';
15 |
16 | if (true) {
17 | let x = 'hello';
18 | }
19 |
20 | for (let i = 0; i < 10; i++) {
21 | console.log(i);
22 | }
23 | ```
24 |
25 | 上面代码如果用`var`替代`let`,实际上就声明了两个全局变量,这显然不是本意。变量应该只在其声明的代码块内有效,`var`命令做不到这一点。
26 |
27 | `var`命令存在变量提升效用,`let`命令没有这个问题。
28 |
29 | ```javascript
30 | 'use strict';
31 |
32 | if(true) {
33 | console.log(x); // ReferenceError
34 | let x = 'hello';
35 | }
36 | ```
37 |
38 | 上面代码如果使用`var`替代`let`,`console.log`那一行就不会报错,而是会输出`undefined`,因为变量声明提升到代码块的头部。这违反了变量先声明后使用的原则。
39 |
40 | 所以,建议不再使用`var`命令,而是使用`let`命令取代。
41 |
42 | **(2)全局常量和线程安全**
43 |
44 | 在`let`和`const`之间,建议优先使用`const`,尤其是在全局环境,不应该设置变量,只应设置常量。
45 |
46 | `const`优于`let`有几个原因。一个是`const`可以提醒阅读程序的人,这个变量不应该改变;另一个是`const`比较符合函数式编程思想,运算不改变值,只是新建值,而且这样也有利于将来的分布式运算;最后一个原因是 JavaScript 编译器会对`const`进行优化,所以多使用`const`,有利于提供程序的运行效率,也就是说`let`和`const`的本质区别,其实是编译器内部的处理不同。
47 |
48 | ```javascript
49 | // bad
50 | var a = 1, b = 2, c = 3;
51 |
52 | // good
53 | const a = 1;
54 | const b = 2;
55 | const c = 3;
56 |
57 | // best
58 | const [a, b, c] = [1, 2, 3];
59 | ```
60 |
61 | `const`声明常量还有两个好处,一是阅读代码的人立刻会意识到不应该修改这个值,二是防止了无意间修改变量值所导致的错误。
62 |
63 | 所有的函数都应该设置为常量。
64 |
65 | 长远来看,JavaScript可能会有多线程的实现(比如Intel的River Trail那一类的项目),这时`let`表示的变量,只应出现在单线程运行的代码中,不能是多线程共享的,这样有利于保证线程安全。
66 |
67 | ## 字符串
68 |
69 | 静态字符串一律使用单引号或反引号,不使用双引号。动态字符串使用反引号。
70 |
71 | ```javascript
72 | // bad
73 | const a = "foobar";
74 | const b = 'foo' + a + 'bar';
75 |
76 | // acceptable
77 | const c = `foobar`;
78 |
79 | // good
80 | const a = 'foobar';
81 | const b = `foo${a}bar`;
82 | const c = 'foobar';
83 | ```
84 |
85 | ## 解构赋值
86 |
87 | 使用数组成员对变量赋值时,优先使用解构赋值。
88 |
89 | ```javascript
90 | const arr = [1, 2, 3, 4];
91 |
92 | // bad
93 | const first = arr[0];
94 | const second = arr[1];
95 |
96 | // good
97 | const [first, second] = arr;
98 | ```
99 |
100 | 函数的参数如果是对象的成员,优先使用解构赋值。
101 |
102 | ```javascript
103 | // bad
104 | function getFullName(user) {
105 | const firstName = user.firstName;
106 | const lastName = user.lastName;
107 | }
108 |
109 | // good
110 | function getFullName(obj) {
111 | const { firstName, lastName } = obj;
112 | }
113 |
114 | // best
115 | function getFullName({ firstName, lastName }) {
116 | }
117 | ```
118 |
119 | 如果函数返回多个值,优先使用对象的解构赋值,而不是数组的解构赋值。这样便于以后添加返回值,以及更改返回值的顺序。
120 |
121 | ```javascript
122 | // bad
123 | function processInput(input) {
124 | return [left, right, top, bottom];
125 | }
126 |
127 | // good
128 | function processInput(input) {
129 | return { left, right, top, bottom };
130 | }
131 |
132 | const { left, right } = processInput(input);
133 | ```
134 |
135 | ## 对象
136 |
137 | 单行定义的对象,最后一个成员不以逗号结尾。多行定义的对象,最后一个成员以逗号结尾。
138 |
139 | ```javascript
140 | // bad
141 | const a = { k1: v1, k2: v2, };
142 | const b = {
143 | k1: v1,
144 | k2: v2
145 | };
146 |
147 | // good
148 | const a = { k1: v1, k2: v2 };
149 | const b = {
150 | k1: v1,
151 | k2: v2,
152 | };
153 | ```
154 |
155 | 对象尽量静态化,一旦定义,就不得随意添加新的属性。如果添加属性不可避免,要使用`Object.assign`方法。
156 |
157 | ```javascript
158 | // bad
159 | const a = {};
160 | a.x = 3;
161 |
162 | // if reshape unavoidable
163 | const a = {};
164 | Object.assign(a, { x: 3 });
165 |
166 | // good
167 | const a = { x: null };
168 | a.x = 3;
169 | ```
170 |
171 | 如果对象的属性名是动态的,可以在创造对象的时候,使用属性表达式定义。
172 |
173 | ```javascript
174 | // bad
175 | const obj = {
176 | id: 5,
177 | name: 'San Francisco',
178 | };
179 | obj[getKey('enabled')] = true;
180 |
181 | // good
182 | const obj = {
183 | id: 5,
184 | name: 'San Francisco',
185 | [getKey('enabled')]: true,
186 | };
187 | ```
188 |
189 | 上面代码中,对象`obj`的最后一个属性名,需要计算得到。这时最好采用属性表达式,在新建`obj`的时候,将该属性与其他属性定义在一起。这样一来,所有属性就在一个地方定义了。
190 |
191 | 另外,对象的属性和方法,尽量采用简洁表达法,这样易于描述和书写。
192 |
193 | ```javascript
194 | var ref = 'some value';
195 |
196 | // bad
197 | const atom = {
198 | ref: ref,
199 |
200 | value: 1,
201 |
202 | addValue: function (value) {
203 | return atom.value + value;
204 | },
205 | };
206 |
207 | // good
208 | const atom = {
209 | ref,
210 |
211 | value: 1,
212 |
213 | addValue(value) {
214 | return atom.value + value;
215 | },
216 | };
217 | ```
218 |
219 | ## 数组
220 |
221 | 使用扩展运算符(...)拷贝数组。
222 |
223 | ```javascript
224 | // bad
225 | const len = items.length;
226 | const itemsCopy = [];
227 | let i;
228 |
229 | for (i = 0; i < len; i++) {
230 | itemsCopy[i] = items[i];
231 | }
232 |
233 | // good
234 | const itemsCopy = [...items];
235 | ```
236 |
237 | 使用Array.from方法,将类似数组的对象转为数组。
238 |
239 | ```javascript
240 | const foo = document.querySelectorAll('.foo');
241 | const nodes = Array.from(foo);
242 | ```
243 |
244 | ## 函数
245 |
246 | 立即执行函数可以写成箭头函数的形式。
247 |
248 | ```javascript
249 | (() => {
250 | console.log('Welcome to the Internet.');
251 | })();
252 | ```
253 |
254 | 那些需要使用函数表达式的场合,尽量用箭头函数代替。因为这样更简洁,而且绑定了this。
255 |
256 | ```javascript
257 | // bad
258 | [1, 2, 3].map(function (x) {
259 | return x * x;
260 | });
261 |
262 | // good
263 | [1, 2, 3].map((x) => {
264 | return x * x;
265 | });
266 |
267 | // best
268 | [1, 2, 3].map(x => x * x);
269 | ```
270 |
271 | 箭头函数取代`Function.prototype.bind`,不应再用self/\_this/that绑定 this。
272 |
273 | ```javascript
274 | // bad
275 | const self = this;
276 | const boundMethod = function(...params) {
277 | return method.apply(self, params);
278 | }
279 |
280 | // acceptable
281 | const boundMethod = method.bind(this);
282 |
283 | // best
284 | const boundMethod = (...params) => method.apply(this, params);
285 | ```
286 |
287 | 简单的、单行的、不会复用的函数,建议采用箭头函数。如果函数体较为复杂,行数较多,还是应该采用传统的函数写法。
288 |
289 | 所有配置项都应该集中在一个对象,放在最后一个参数,布尔值不可以直接作为参数。
290 |
291 | ```javascript
292 | // bad
293 | function divide(a, b, option = false ) {
294 | }
295 |
296 | // good
297 | function divide(a, b, { option = false } = {}) {
298 | }
299 | ```
300 |
301 | 不要在函数体内使用arguments变量,使用rest运算符(...)代替。因为rest运算符显式表明你想要获取参数,而且arguments是一个类似数组的对象,而rest运算符可以提供一个真正的数组。
302 |
303 | ```javascript
304 | // bad
305 | function concatenateAll() {
306 | const args = Array.prototype.slice.call(arguments);
307 | return args.join('');
308 | }
309 |
310 | // good
311 | function concatenateAll(...args) {
312 | return args.join('');
313 | }
314 | ```
315 |
316 | 使用默认值语法设置函数参数的默认值。
317 |
318 | ```javascript
319 | // bad
320 | function handleThings(opts) {
321 | opts = opts || {};
322 | }
323 |
324 | // good
325 | function handleThings(opts = {}) {
326 | // ...
327 | }
328 | ```
329 |
330 | ## Map结构
331 |
332 | 注意区分Object和Map,只有模拟现实世界的实体对象时,才使用Object。如果只是需要`key: value`的数据结构,使用Map结构。因为Map有内建的遍历机制。
333 |
334 | ```javascript
335 | let map = new Map(arr);
336 |
337 | for (let key of map.keys()) {
338 | console.log(key);
339 | }
340 |
341 | for (let value of map.values()) {
342 | console.log(value);
343 | }
344 |
345 | for (let item of map.entries()) {
346 | console.log(item[0], item[1]);
347 | }
348 | ```
349 |
350 | ## Class
351 |
352 | 总是用Class,取代需要prototype的操作。因为Class的写法更简洁,更易于理解。
353 |
354 | ```javascript
355 | // bad
356 | function Queue(contents = []) {
357 | this._queue = [...contents];
358 | }
359 | Queue.prototype.pop = function() {
360 | const value = this._queue[0];
361 | this._queue.splice(0, 1);
362 | return value;
363 | }
364 |
365 | // good
366 | class Queue {
367 | constructor(contents = []) {
368 | this._queue = [...contents];
369 | }
370 | pop() {
371 | const value = this._queue[0];
372 | this._queue.splice(0, 1);
373 | return value;
374 | }
375 | }
376 | ```
377 |
378 | 使用`extends`实现继承,因为这样更简单,不会有破坏`instanceof`运算的危险。
379 |
380 | ```javascript
381 | // bad
382 | const inherits = require('inherits');
383 | function PeekableQueue(contents) {
384 | Queue.apply(this, contents);
385 | }
386 | inherits(PeekableQueue, Queue);
387 | PeekableQueue.prototype.peek = function() {
388 | return this._queue[0];
389 | }
390 |
391 | // good
392 | class PeekableQueue extends Queue {
393 | peek() {
394 | return this._queue[0];
395 | }
396 | }
397 | ```
398 |
399 | ## 模块
400 |
401 | 首先,Module语法是JavaScript模块的标准写法,坚持使用这种写法。使用`import`取代`require`。
402 |
403 | ```javascript
404 | // bad
405 | const moduleA = require('moduleA');
406 | const func1 = moduleA.func1;
407 | const func2 = moduleA.func2;
408 |
409 | // good
410 | import { func1, func2 } from 'moduleA';
411 | ```
412 |
413 | 使用`export`取代`module.exports`。
414 |
415 | ```javascript
416 | // commonJS的写法
417 | var React = require('react');
418 |
419 | var Breadcrumbs = React.createClass({
420 | render() {
421 | return ;
422 | }
423 | });
424 |
425 | module.exports = Breadcrumbs;
426 |
427 | // ES6的写法
428 | import React from 'react';
429 |
430 | const Breadcrumbs = React.createClass({
431 | render() {
432 | return ;
433 | }
434 | });
435 |
436 | export default Breadcrumbs
437 | ```
438 |
439 | 如果模块只有一个输出值,就使用`export default`,如果模块有多个输出值,就不使用`export default`,不要`export default`与普通的`export`同时使用。
440 |
441 | 不要在模块输入中使用通配符。因为这样可以确保你的模块之中,有一个默认输出(export default)。
442 |
443 | ```javascript
444 | // bad
445 | import * as myObject './importModule';
446 |
447 | // good
448 | import myObject from './importModule';
449 | ```
450 |
451 | 如果模块默认输出一个函数,函数名的首字母应该小写。
452 |
453 | ```javascript
454 | function makeStyleGuide() {
455 | }
456 |
457 | export default makeStyleGuide;
458 | ```
459 |
460 | 如果模块默认输出一个对象,对象名的首字母应该大写。
461 |
462 | ```javascript
463 | const StyleGuide = {
464 | es6: {
465 | }
466 | };
467 |
468 | export default StyleGuide;
469 | ```
470 |
471 | ## ESLint的使用
472 |
473 | ESLint是一个语法规则和代码风格的检查工具,可以用来保证写出语法正确、风格统一的代码。
474 |
475 | 首先,安装ESLint。
476 |
477 | ```bash
478 | $ npm i -g eslint
479 | ```
480 |
481 | 然后,安装Airbnb语法规则。
482 |
483 | ```bash
484 | $ npm i -g eslint-config-airbnb
485 | ```
486 |
487 | 最后,在项目的根目录下新建一个`.eslintrc`文件,配置ESLint。
488 |
489 | ```javascript
490 | {
491 | "extends": "eslint-config-airbnb"
492 | }
493 | ```
494 |
495 | 现在就可以检查,当前项目的代码是否符合预设的规则。
496 |
497 | `index.js`文件的代码如下。
498 |
499 | ```javascript
500 | var unusued = 'I have no purpose!';
501 |
502 | function greet() {
503 | var message = 'Hello, World!';
504 | alert(message);
505 | }
506 |
507 | greet();
508 | ```
509 |
510 | 使用ESLint检查这个文件。
511 |
512 | ```bash
513 | $ eslint index.js
514 | index.js
515 | 1:5 error unusued is defined but never used no-unused-vars
516 | 4:5 error Expected indentation of 2 characters but found 4 indent
517 | 5:5 error Expected indentation of 2 characters but found 4 indent
518 |
519 | ✖ 3 problems (3 errors, 0 warnings)
520 | ```
521 |
522 | 上面代码说明,原文件有三个错误,一个是定义了变量,却没有使用,另外两个是行首缩进为4个空格,而不是规定的2个空格。
523 |
--------------------------------------------------------------------------------
/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microzz/es6tutorial/e5b32087c96ba8272ee3b633f16ee649c0b4ff13/favicon.ico
--------------------------------------------------------------------------------
/images/copyright.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microzz/es6tutorial/e5b32087c96ba8272ee3b633f16ee649c0b4ff13/images/copyright.png
--------------------------------------------------------------------------------
/images/cover-2nd.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microzz/es6tutorial/e5b32087c96ba8272ee3b633f16ee649c0b4ff13/images/cover-2nd.jpg
--------------------------------------------------------------------------------
/images/cover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microzz/es6tutorial/e5b32087c96ba8272ee3b633f16ee649c0b4ff13/images/cover.jpg
--------------------------------------------------------------------------------
/images/cover_thumbnail.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microzz/es6tutorial/e5b32087c96ba8272ee3b633f16ee649c0b4ff13/images/cover_thumbnail.jpg
--------------------------------------------------------------------------------
/images/magnifier.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microzz/es6tutorial/e5b32087c96ba8272ee3b633f16ee649c0b4ff13/images/magnifier.jpg
--------------------------------------------------------------------------------
/images/page1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microzz/es6tutorial/e5b32087c96ba8272ee3b633f16ee649c0b4ff13/images/page1.png
--------------------------------------------------------------------------------
/images/page2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microzz/es6tutorial/e5b32087c96ba8272ee3b633f16ee649c0b4ff13/images/page2.png
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | ECMAScript 6入门
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | back to top
24 | edit
25 | Loading ...
26 | Opps! ... File not found!
27 |
28 |
29 |
30 |
31 |
34 |
35 | 《ECMAScript 6入门》是一本开源的JavaScript语言教程,全面介绍ECMAScript 6新增的语法特性。
36 | 本书力争覆盖ES6与ES5的所有不同之处,对涉及的语法知识给予详细介绍,并给出大量简洁易懂的示例代码。
37 | 本书为中级难度,适合已有一定JavaScript语言基础的读者,了解这门语言的最新进展;也可当作参考手册,查寻新增的语法点。
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/js/prism.js:
--------------------------------------------------------------------------------
1 | var self=typeof window!="undefined"?window:{},Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var r={};for(var i in e)e.hasOwnProperty(i)&&(r[i]=t.util.clone(e[i]));return r;case"Array":return e.slice()}return e}},languages:{extend:function(e,n){var r=t.util.clone(t.languages[e]);for(var i in n)r[i]=n[i];return r},insertBefore:function(e,n,r,i){i=i||t.languages;var s=i[e],o={};for(var u in s)if(s.hasOwnProperty(u)){if(u==n)for(var a in r)r.hasOwnProperty(a)&&(o[a]=r[a]);o[u]=s[u]}return i[e]=o},DFS:function(e,n){for(var r in e){n.call(e,r,e[r]);t.util.type(e)==="Object"&&t.languages.DFS(e[r],n)}}},highlightAll:function(e,n){var r=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');for(var i=0,s;s=r[i++];)t.highlightElement(s,e===!0,n)},highlightElement:function(r,i,s){var o,u,a=r;while(a&&!e.test(a.className))a=a.parentNode;if(a){o=(a.className.match(e)||[,""])[1];u=t.languages[o]}if(!u)return;r.className=r.className.replace(e,"").replace(/\s+/g," ")+" language-"+o;a=r.parentNode;/pre/i.test(a.nodeName)&&(a.className=a.className.replace(e,"").replace(/\s+/g," ")+" language-"+o);var f=r.textContent;if(!f)return;f=f.replace(/&/g,"&").replace(/e.length)break e;if(p instanceof i)continue;a.lastIndex=0;var d=a.exec(p);if(d){l&&(c=d[1].length);var v=d.index-1+c,d=d[0].slice(c),m=d.length,g=v+m,y=p.slice(0,v+1),b=p.slice(g+1),w=[h,1];y&&w.push(y);var E=new i(u,f?t.tokenize(d,f):d);w.push(E);b&&w.push(b);Array.prototype.splice.apply(s,w)}}}return s},hooks:{all:{},add:function(e,n){var r=t.hooks.all;r[e]=r[e]||[];r[e].push(n)},run:function(e,n){var r=t.hooks.all[e];if(!r||!r.length)return;for(var i=0,s;s=r[i++];)s(n)}}},n=t.Token=function(e,t){this.type=e;this.content=t};n.stringify=function(e,r,i){if(typeof e=="string")return e;if(Object.prototype.toString.call(e)=="[object Array]")return e.map(function(t){return n.stringify(t,r,e)}).join("");var s={type:e.type,content:n.stringify(e.content,r,i),tag:"span",classes:["token",e.type],attributes:{},language:r,parent:i};s.type=="comment"&&(s.attributes.spellcheck="true");t.hooks.run("wrap",s);var o="";for(var u in s.attributes)o+=u+'="'+(s.attributes[u]||"")+'"';return"<"+s.tag+' class="'+s.classes.join(" ")+'" '+o+">"+s.content+""+s.tag+">"};if(!self.document){if(!self.addEventListener)return self.Prism;self.addEventListener("message",function(e){var n=JSON.parse(e.data),r=n.language,i=n.code;self.postMessage(JSON.stringify(t.tokenize(i,t.languages[r])));self.close()},!1);return self.Prism}var r=document.getElementsByTagName("script");r=r[r.length-1];if(r){t.filename=r.src;document.addEventListener&&!r.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)}return self.Prism}();typeof module!="undefined"&&module.exports&&(module.exports=Prism);;
2 | Prism.languages.markup={comment:/<!--[\w\W]*?-->/g,prolog:/<\?.+?\?>/,doctype:/<!DOCTYPE.+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,inside:{punctuation:/=|>|"/g}},punctuation:/\/?>/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/&#?[\da-z]{1,8};/gi};Prism.hooks.add("wrap",function(e){e.type==="entity"&&(e.attributes.title=e.content.replace(/&/,"&"))});;
3 | Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*{))/gi,inside:{punctuation:/[;:]/g}},url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/g,property:/(\b|\B)[\w-]+(?=\s*:)/ig,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,ignore:/&(lt|gt|amp);/gi,punctuation:/[\{\};:]/g};Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{style:{pattern:/(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/ig,inside:{tag:{pattern:/(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css}}});;
4 | Prism.languages.clike={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g,lookbehind:!0},string:/("|')(\\?.)*?\1/g,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/ig,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,"function":{pattern:/[a-z0-9_]+\(/ig,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%/g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g};;
5 | Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(var|let|if|else|while|do|for|return|in|instanceof|function|get|set|new|with|typeof|try|throw|catch|finally|null|break|continue|this)\b/g,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?|NaN|-?Infinity)\b/g});Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,lookbehind:!0}});Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/ig,inside:{tag:{pattern:/(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript}}});;
6 | Prism.languages.bash=Prism.languages.extend("clike",{comment:{pattern:/(^|[^"{\\])(#.*?(\r?\n|$))/g,lookbehind:!0},string:{pattern:/("|')(\\?[\s\S])*?\1/g,inside:{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^\}]+\})/g}},keyword:/\b(if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)\b/g});Prism.languages.insertBefore("bash","keyword",{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^}]+\})/g});Prism.languages.insertBefore("bash","comment",{important:/(^#!\s*\/bin\/bash)|(^#!\s*\/bin\/sh)/g});;
7 | Prism.languages.http={"request-line":{pattern:/^(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b\shttps?:\/\/\S+\sHTTP\/[0-9.]+/g,inside:{property:/^\b(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/g,"attr-name":/:\w+/g}},"response-status":{pattern:/^HTTP\/1.[01] [0-9]+.*/g,inside:{property:/[0-9]+[A-Z\s-]+$/g}},keyword:/^[\w-]+:(?=.+)/gm};var httpLanguages={"application/json":Prism.languages.javascript,"application/xml":Prism.languages.markup,"text/xml":Prism.languages.markup,"text/html":Prism.languages.markup};for(var contentType in httpLanguages)if(httpLanguages[contentType]){var options={};options[contentType]={pattern:new RegExp("(content-type:\\s*"+contentType+"[\\w\\W]*?)\\n\\n[\\w\\W]*","gi"),lookbehind:!0,inside:{rest:httpLanguages[contentType]}};Prism.languages.insertBefore("http","keyword",options)};;
8 |
--------------------------------------------------------------------------------
/js/store.js:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2010-2013 Marcus Westin */
2 | this.JSON||(this.JSON={}),function(){function f(e){return e<10?"0"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return typeof t=="string"?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a=="object"&&typeof a.toJSON=="function"&&(a=a.toJSON(e)),typeof rep=="function"&&(a=rep.call(t,e,a));switch(typeof a){case"string":return quote(a);case"number":return isFinite(a)?String(a):"null";case"boolean":case"null":return String(a);case"object":if(!a)return"null";gap+=indent,u=[];if(Object.prototype.toString.apply(a)==="[object Array]"){s=a.length;for(n=0;ndocument.w=window"+i+'>'),a.close(),u=a.w.frames[0].document,s=u.createElement("div")}catch(f){s=n.createElement("div"),u=n.body}function l(e){return function(){var n=Array.prototype.slice.call(arguments,0);n.unshift(s),u.appendChild(s),s.addBehavior("#default#userData"),s.load(r);var i=e.apply(t,n);return u.removeChild(s),i}}var c=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");function h(e){return e.replace(/^d/,"___$&").replace(c,"___")}t.set=l(function(e,n,i){return n=h(n),i===undefined?t.remove(n):(e.setAttribute(n,t.serialize(i)),e.save(r),i)}),t.get=l(function(e,n){return n=h(n),t.deserialize(e.getAttribute(n))}),t.remove=l(function(e,t){t=h(t),e.removeAttribute(t),e.save(r)}),t.clear=l(function(e){var t=e.XMLDocument.documentElement.attributes;e.load(r);for(var n=0,i;i=t[n];n++)e.removeAttribute(i.name);e.save(r)}),t.getAll=function(e){var n={};return t.forEach(function(e,t){n[e]=t}),n},t.forEach=l(function(e,n){var r=e.XMLDocument.documentElement.attributes;for(var i=0,s;s=r[i];++i)n(s.name,t.deserialize(e.getAttribute(s.name)))})}try{var p="__storejs__";t.set(p,p),t.get(p)!=p&&(t.disabled=!0),t.remove(p)}catch(f){t.disabled=!0}t.enabled=!t.disabled,typeof module!="undefined"&&module.exports&&this.module!==module?module.exports=t:typeof define=="function"&&define.amd?define(t):e.store=t}(Function("return this")())
--------------------------------------------------------------------------------
/sidebar.md:
--------------------------------------------------------------------------------
1 | # [ECMAScript 6 入门]()
2 |
3 | 作者:[阮一峰](http://www.ruanyifeng.com)
4 |
5 | 授权:署名-非商用许可证
6 |
7 | ## 目录
8 | 1. [前言](#README)
9 | 1. [ECMAScript 6简介](#docs/intro)
10 | 1. [let和const命令](#docs/let)
11 | 1. [变量的解构赋值](#docs/destructuring)
12 | 1. [字符串的扩展](#docs/string)
13 | 1. [正则的扩展](#docs/regex)
14 | 1. [数值的扩展](#docs/number)
15 | 1. [数组的扩展](#docs/array)
16 | 1. [函数的扩展](#docs/function)
17 | 1. [对象的扩展](#docs/object)
18 | 1. [Symbol](#docs/symbol)
19 | 1. [Set和Map数据结构](#docs/set-map)
20 | 1. [Proxy和Reflect](#docs/proxy)
21 | 1. [Iterator和for...of循环](#docs/iterator)
22 | 1. [Generator函数](#docs/generator)
23 | 1. [Promise对象](#docs/promise)
24 | 1. [异步操作和Async函数](#docs/async)
25 | 1. [Class](#docs/class)
26 | 1. [Decorator](#docs/decorator)
27 | 1. [Module](#docs/module)
28 | 1. [编程风格](#docs/style)
29 | 1. [读懂规格](#docs/spec)
30 | 1. [二进制数组](#docs/arraybuffer)
31 | 1. [SIMD](#docs/simd)
32 | 1. [参考链接](#docs/reference)
33 |
34 | ## 其他
35 | - [源码](http://github.com/ruanyf/es6tutorial/)
36 | - [修订历史](https://github.com/ruanyf/es6tutorial/commits/gh-pages)
37 | - [反馈意见](https://github.com/ruanyf/es6tutorial/issues)
38 |
--------------------------------------------------------------------------------