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 |
--------------------------------------------------------------------------------
/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 | #content {
109 | padding-top: 10px;
110 | padding-bottom: 150px;
111 | margin-left: 20px;
112 | margin-right: 20px;
113 | font-size: 0.8rem;
114 | line-height:1.3rem;
115 |
116 | /* border: 1px solid black; */
117 |
118 | counter-reset: section;
119 | }
120 |
121 | @media (min-width: 40rem) {
122 | #content {
123 | width: 580px;
124 | padding-left:330px;
125 | margin-left: 0px;
126 | margin-right: 0px;
127 | }
128 | }
129 |
130 | #content pre{
131 | margin-left: auto;
132 | margin-right: auto;
133 | padding-top: 10px;
134 | padding-bottom: 10px;
135 | padding-left: 0.7rem;
136 | line-height: 1.2;
137 |
138 | color: #FFF;
139 |
140 | background: #111;
141 | border-radius: 5px;
142 | }
143 |
144 | #content code {
145 | padding-right: 5px;
146 |
147 | color: #a6e22e;
148 | font-size: 0.7rem;
149 | font-weight: normal;
150 | font-family: Consolas,"Courier New",Courier,FreeMono,monospace;
151 |
152 | background: #111;
153 | border-radius: 2px;
154 | }
155 |
156 | #content p>code,
157 | #content li>code,
158 | #content h2>code,
159 | #content h3>code{
160 | color: #c7254e;
161 | background: #f9f2f4;
162 | }
163 |
164 | #content h2 {
165 | margin-top: 50px;
166 | margin-bottom: 0px;
167 |
168 | padding-top: 20px;
169 | padding-bottom: 0px;
170 |
171 | font-size: 18px;
172 | text-align: left;
173 |
174 | border-top: 2px solid #666;
175 |
176 | counter-increment: section;
177 | }
178 |
179 | #content h2:before {
180 | content: counter(section) ". ";
181 | }
182 |
183 | #content h3 {
184 | margin-top: 50px;
185 | margin-bottom: 0px;
186 |
187 | padding-top: 20px;
188 | padding-bottom: 0px;
189 |
190 | text-align: left;
191 | border-top: 1px dotted #777;
192 | }
193 |
194 | #content img {
195 | max-width: 90%;
196 | display: block;
197 |
198 | margin-left: auto;
199 | margin-right: auto;
200 | margin-top: 40px;
201 | margin-bottom: 40px;
202 |
203 | border-radius: 5px;
204 | }
205 |
206 | #content ul {
207 | display: block;
208 | list-style-type: none;
209 | padding-top: 0.5rem;
210 | padding-bottom:0.5rem;
211 | }
212 |
213 | #content ol {
214 | display: block;
215 | padding-top: 0.5rem;
216 | padding-bottom:0.5rem;
217 | }
218 |
219 |
220 | #content ul li:before { /* a hack to have dashes as a list style */
221 | content: "-";
222 | position: relative;
223 | left: -5px;
224 | }
225 |
226 | #content ul li,
227 | #content ol li{
228 | text-indent: -5px; /* to compensate for the padding for the dash */
229 | font-size: 0.8rem;
230 | }
231 |
232 | #content ul li.link,
233 | #content ol li.link {
234 | color: #2980b9;
235 | text-decoration: none;
236 | font-size: 0.7rem;
237 | font-weight: bold;
238 | cursor: pointer;
239 | }
240 |
241 | #content a:link, #content a:visited {
242 | color: #4682BE;
243 | text-decoration: none;
244 | }
245 |
246 | #content .content-toc{
247 | background: #bdc3c7;
248 | border-radius: 5px;
249 | }
250 |
251 | #content table{display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}
252 |
253 | #content table th{font-weight:bold}
254 |
255 | #content table th,
256 | #content table td{padding:6px 13px;border:1px solid #ddd}
257 |
258 | #content table tr{background-color:#fff;border-top:1px solid #ccc}
259 | #content table tr:nth-child(2n){background-color:#f8f8f8}
260 |
261 | #back_to_top {
262 | display: none;
263 | position: fixed;
264 |
265 | height: 20px;
266 | width: 70px;
267 | top: 20px;
268 |
269 | margin-left: 930px;
270 | margin-top: 0px;
271 |
272 | color: #FFF;
273 | line-height: 20px;
274 | text-align: center;
275 | font-size: 10px;
276 |
277 |
278 | border-radius: 5px;
279 | background-color: #AAA;
280 | }
281 |
282 | #back_to_top:hover {
283 | background-color: #444;
284 | cursor: pointer;
285 | }
286 |
287 | #edit {
288 | display: none;
289 | position: fixed;
290 |
291 | height: 17px;
292 | width: 70px;
293 | top: 45px;
294 |
295 | margin-left: 930px;
296 | margin-top: 0px;
297 |
298 | color: #FFF;
299 | line-height: 17px;
300 | text-align: center;
301 | font-size: 10px;
302 |
303 |
304 | border-radius: 5px;
305 | background-color: #AAA;
306 | }
307 |
308 | #edit:hover {
309 | background-color: #444;
310 | cursor: pointer;
311 | }
312 |
313 | #loading, #error {
314 | display: none;
315 | position: fixed;
316 |
317 | top: 0;
318 | height: 17px;
319 |
320 | font-size: 14px;
321 | }
322 |
323 | @media (min-width: 40rem) {
324 | #loading, #error {
325 | display: none;
326 | position: fixed;
327 |
328 | height: 17px;
329 | top: 45%;
330 |
331 | margin-left: 560px;
332 |
333 | font-size: 14px;
334 | }
335 | }
336 |
337 | #flip{
338 | position:fixed;
339 | height:20px;
340 | width:100%;
341 | bottom:10px;
342 | font-size:10px;
343 | text-align:center;
344 | }
345 |
346 | #pageup,#pagedown{
347 | height:20px;
348 | width:70px;
349 | display:inline-block;
350 | border-radius: 5px;
351 | background-color: #AAA;
352 | text-align: center;
353 | line-height:20px;
354 | color: #FFF;
355 | }
356 |
357 | #pageup{
358 | margin-right:5px;
359 | }
360 |
361 | #pageup:hover,
362 | #pagedown:hover{
363 | background-color: #444;
364 | cursor: pointer;
365 | }
366 |
367 | #pagedown{
368 | margin-left:5px;
369 | }
370 |
371 | @media (min-width: 40rem) {
372 | #flip{
373 | margin-left:545px;
374 | width:150px;
375 | }
376 | }
377 |
378 | .progress-indicator-2 {
379 | position: fixed;
380 | top: 0;
381 | left: 0;
382 | height: 3px;
383 | background-color: #0A74DA;
384 | }
385 |
386 | /**
387 | * okaidia theme for JavaScript, CSS and HTML
388 | * Loosely based on Monokai textmate theme by http://www.monokai.nl/
389 | * @author ocodia
390 | */
391 |
392 | code[class*="language-"],
393 | pre[class*="language-"] {
394 | color: #a6e22e;
395 | text-shadow: 0 1px rgba(0,0,0,0.3);
396 | font-family: Consolas, Monaco, 'Andale Mono', monospace;
397 | direction: ltr;
398 | text-align: left;
399 | white-space: pre;
400 | word-spacing: normal;
401 | word-break: normal;
402 |
403 | -moz-tab-size: 4;
404 | -o-tab-size: 4;
405 | tab-size: 4;
406 |
407 | -webkit-hyphens: none;
408 | -moz-hyphens: none;
409 | -ms-hyphens: none;
410 | hyphens: none;
411 | }
412 |
413 | /* Code blocks */
414 | pre[class*="language-"] {
415 | padding: 1em;
416 | margin: .5em 0;
417 | overflow: auto;
418 | border-radius: 0.3em;
419 | }
420 |
421 | :not(pre) > code[class*="language-"],
422 | pre[class*="language-"] {
423 | background: #272822;
424 | }
425 |
426 | /* Inline code */
427 | :not(pre) > code[class*="language-"] {
428 | padding: .1em;
429 | border-radius: .3em;
430 | }
431 |
432 | .token.comment,
433 | .token.prolog,
434 | .token.doctype,
435 | .token.cdata {
436 | color: #75715e;
437 | }
438 |
439 | .token.punctuation {
440 | color: #f8f8f2;
441 | }
442 |
443 | .namespace {
444 | opacity: .7;
445 | }
446 |
447 | .token.property,
448 | .token.tag,
449 | .token.constant,
450 | .token.symbol {
451 | color: #f92672;
452 | }
453 |
454 | .token.boolean,
455 | .token.number{
456 | color: #ae81ff;
457 | }
458 |
459 | .token.selector,
460 | .token.attr-name,
461 | .token.string,
462 | .token.builtin {
463 | color: #a6e22e;
464 | }
465 |
466 |
467 | .token.operator,
468 | .token.entity,
469 | .token.url,
470 | .language-css .token.string,
471 | .style .token.string,
472 | .token.variable {
473 | color: #f92672;
474 | }
475 |
476 | .token.atrule,
477 | .token.attr-value
478 | {
479 | color: #e6db74;
480 | }
481 |
482 |
483 | .token.keyword{
484 | color: #66d9ef;
485 | }
486 |
487 | .token.regex,
488 | .token.important {
489 | color: #fd971f;
490 | }
491 |
492 | .token.important {
493 | font-weight: bold;
494 | }
495 |
496 | .token.entity {
497 | cursor: help;
498 | }
499 |
--------------------------------------------------------------------------------
/css/normalize.css:
--------------------------------------------------------------------------------
1 | ../app/bower_components/normalize-css/normalize.css
--------------------------------------------------------------------------------
/docs/let.md:
--------------------------------------------------------------------------------
1 | # let和const命令
2 |
3 | ## let命令
4 |
5 | ### 基本用法
6 |
7 | ES6新增了`let`命令,用来声明变量。它的用法类似于`var`,但是所声明的变量,只在`let`命令所在的代码块内有效。
8 |
9 | ```javascript
10 | {
11 | let a = 10;
12 | var b = 1;
13 | }
14 |
15 | a // ReferenceError: a is not defined.
16 | b // 1
17 | ```
18 |
19 | 上面代码在代码块之中,分别用`let`和`var`声明了两个变量。然后在代码块之外调用这两个变量,结果`let`声明的变量报错,`var`声明的变量返回了正确的值。这表明,`let`声明的变量只在它所在的代码块有效。
20 |
21 | `for`循环的计数器,就很合适使用let命令。
22 |
23 | ```javascript
24 | for(let i = 0; i < arr.length; i++){}
25 |
26 | console.log(i)
27 | //ReferenceError: i is not defined
28 | ```
29 |
30 | 上面代码的计数器`i`,只在`for`循环体内有效。
31 |
32 | 下面的代码如果使用`var`,最后输出的是10。
33 |
34 | ```javascript
35 | var a = [];
36 | for (var i = 0; i < 10; i++) {
37 | a[i] = function () {
38 | console.log(i);
39 | };
40 | }
41 | a[6](); // 10
42 | ```
43 |
44 | 如果使用`let`,声明的变量仅在块级作用域内有效,最后输出的是6。
45 |
46 | ```javascript
47 | var a = [];
48 | for (let i = 0; i < 10; i++) {
49 | a[i] = function () {
50 | console.log(i);
51 | };
52 | }
53 | a[6](); // 6
54 | ```
55 |
56 | ### 不存在变量提升
57 |
58 | `let`不像`var`那样,会发生“变量提升”现象。
59 |
60 | ```javascript
61 | console.log(foo); // ReferenceError
62 | let foo = 2;
63 | ```
64 |
65 | 上面代码在声明`foo`之前,就使用这个变量,结果会抛出一个错误。
66 |
67 | 这也意味着`typeof`不再是一个百分之百安全的操作。
68 |
69 | ```javascript
70 | typeof x; // ReferenceError
71 | let x;
72 | ```
73 |
74 | 上面代码中,由于块级作用域内`typeof`运行时,`x`还没有值,所以会抛出一个`ReferenceError`。
75 |
76 | ### 暂时性死区
77 |
78 | 只要块级作用域内存在`let`命令,它所声明的变量就“绑定”(binding)这个区域,不再受外部的影响。
79 |
80 | ```javascript
81 | var tmp = 123;
82 |
83 | if (true) {
84 | tmp = 'abc'; // ReferenceError
85 | let tmp;
86 | }
87 | ```
88 |
89 | 上面代码中,存在全局变量`tmp`,但是块级作用域内`let`又声明了一个局部变量`tmp`,导致后者绑定这个块级作用域,所以在`let`声明变量前,对`tmp`赋值会报错。
90 |
91 | ES6明确规定,如果区块中存在`let`和`const`命令,这个区块对这些命令声明的变量,从一开始就形成了封闭作用域。凡是在声明之前就使用这些命令,就会报错。
92 |
93 | 总之,在代码块内,使用let命令声明变量之前,该变量都是不可用的。这在语法上,称为“暂时性死区”(temporal dead zone,简称TDZ)。
94 |
95 | ```javascript
96 | if (true) {
97 | // TDZ开始
98 | tmp = 'abc'; // ReferenceError
99 | console.log(tmp); // ReferenceError
100 |
101 | let tmp; // TDZ结束
102 | console.log(tmp); // undefined
103 |
104 | tmp = 123;
105 | console.log(tmp); // 123
106 | }
107 | ```
108 |
109 | 上面代码中,在`let`命令声明变量`tmp`之前,都属于变量`tmp`的“死区”。
110 |
111 | 有些“死区”比较隐蔽,不太容易发现。
112 |
113 | ```javascript
114 | function bar(x = y, y = 2) {
115 | return [x, y];
116 | }
117 |
118 | bar(); // 报错
119 | ```
120 |
121 | 上面代码中,调用`bar`函数之所以报错,是因为参数`x`默认值等于另一个参数`y`,而此时`y`还没有声明,属于”死区“。如果`y`的默认值是`x`,就不会报错,因为此时`x`已经声明了。
122 |
123 | ```javascript
124 | function bar(x = 2, y = x) {
125 | return [x, y];
126 | }
127 | bar(); // [2, 2]
128 | ```
129 |
130 | ES6规定暂时性死区和不存在变量提升,主要是为了减少运行时错误,防止在变量声明前就使用这个变量,从而导致意料之外的行为。这样的错误在ES5是很常见的,现在有了这种规定,避免此类错误就很容易了。
131 |
132 | 总之,暂时性死区的本质就是,只要一进入当前作用域,所要使用的变量就已经存在了,但是不可获取,只有等到声明变量的那一行代码出现,才可以获取和使用该变量。
133 |
134 | ### 不允许重复声明
135 |
136 | let不允许在相同作用域内,重复声明同一个变量。
137 |
138 | ```javascript
139 | // 报错
140 | function () {
141 | let a = 10;
142 | var a = 1;
143 | }
144 |
145 | // 报错
146 | function () {
147 | let a = 10;
148 | let a = 1;
149 | }
150 | ```
151 |
152 | 因此,不能在函数内部重新声明参数。
153 |
154 | ```javascript
155 | function func(arg) {
156 | let arg; // 报错
157 | }
158 |
159 | function func(arg) {
160 | {
161 | let arg; // 不报错
162 | }
163 | }
164 | ```
165 |
166 | ## 块级作用域
167 |
168 | ### 为什么需要块级作用域?
169 |
170 | ES5只有全局作用域和函数作用域,没有块级作用域,这带来很多不合理的场景。
171 |
172 | 第一种场景,内层变量可能会覆盖外层变量。
173 |
174 | ```javascript
175 | var tmp = new Date();
176 |
177 | function f(){
178 | console.log(tmp);
179 | if (false){
180 | var tmp = "hello world";
181 | }
182 | }
183 |
184 | f() // undefined
185 | ```
186 |
187 | 上面代码中,函数f执行后,输出结果为`undefined`,原因在于变量提升,导致内层的tmp变量覆盖了外层的tmp变量。
188 |
189 | 第二种场景,用来计数的循环变量泄露为全局变量。
190 |
191 | ```javascript
192 | var s = 'hello';
193 |
194 | for (var i = 0; i < s.length; i++){
195 | console.log(s[i]);
196 | }
197 |
198 | console.log(i); // 5
199 | ```
200 |
201 | 上面代码中,变量i只用来控制循环,但是循环结束后,它并没有消失,泄露成了全局变量。
202 |
203 | ### ES6的块级作用域
204 |
205 | `let`实际上为JavaScript新增了块级作用域。
206 |
207 | ```javascript
208 | function f1() {
209 | let n = 5;
210 | if (true) {
211 | let n = 10;
212 | }
213 | console.log(n); // 5
214 | }
215 | ```
216 |
217 | 上面的函数有两个代码块,都声明了变量`n`,运行后输出5。这表示外层代码块不受内层代码块的影响。如果使用`var`定义变量`n`,最后输出的值就是10。
218 |
219 | ES6允许块级作用域的任意嵌套。
220 |
221 | ```javascript
222 | {{{{{let insane = 'Hello World'}}}}};
223 | ```
224 |
225 | 上面代码使用了一个五层的块级作用域。外层作用域无法读取内层作用域的变量。
226 |
227 | ```javascript
228 | {{{{
229 | {let insane = 'Hello World'}
230 | console.log(insane); // 报错
231 | }}}};
232 | ```
233 |
234 | 内层作用域可以定义外层作用域的同名变量。
235 |
236 | ```javascript
237 | {{{{
238 | let insane = 'Hello World';
239 | {let insane = 'Hello World';}
240 | }}}};
241 | ```
242 |
243 | 块级作用域的出现,实际上使得获得广泛应用的立即执行匿名函数(IIFE)不再必要了。
244 |
245 | ```javascript
246 | // IIFE写法
247 | (function () {
248 | var tmp = ...;
249 | ...
250 | }());
251 |
252 | // 块级作用域写法
253 | {
254 | let tmp = ...;
255 | ...
256 | }
257 | ```
258 |
259 | 另外,ES6也规定,函数本身的作用域,在其所在的块级作用域之内。
260 |
261 | ```javascript
262 | function f() { console.log('I am outside!'); }
263 | (function () {
264 | if(false) {
265 | // 重复声明一次函数f
266 | function f() { console.log('I am inside!'); }
267 | }
268 |
269 | f();
270 | }());
271 | ```
272 |
273 | 上面代码在ES5中运行,会得到“I am inside!”,但是在ES6中运行,会得到“I am outside!”。这是因为ES5存在函数提升,不管会不会进入 `if`代码块,函数声明都会提升到当前作用域的顶部,得到执行;而ES6支持块级作用域,不管会不会进入if代码块,其内部声明的函数皆不会影响到作用域的外部。
274 |
275 | ```javascript
276 | {
277 | let a = 'secret';
278 | function f() {
279 | return a;
280 | }
281 | }
282 | f() // 报错
283 | ```
284 |
285 | 上面代码中,块级作用域外部,无法调用块级作用域内部定义的函数。如果确实需要调用,就要像下面这样处理。
286 |
287 | ```javascript
288 | let f;
289 | {
290 | let a = 'secret';
291 | f = function () {
292 | return a;
293 | }
294 | }
295 | f() // "secret"
296 | ```
297 |
298 | 需要注意的是,如果在严格模式下,函数只能在顶层作用域和函数内声明,其他情况(比如if代码块、循环代码块)的声明都会报错。
299 |
300 | ## const命令
301 |
302 | const也用来声明变量,但是声明的是常量。一旦声明,常量的值就不能改变。
303 |
304 | ```javascript
305 | const PI = 3.1415;
306 | PI // 3.1415
307 |
308 | PI = 3;
309 | // TypeError: "PI" is read-only
310 | ```
311 |
312 | 上面代码表明改变常量的值会报错。
313 |
314 | const声明的变量不得改变值,这意味着,const一旦声明变量,就必须立即初始化,不能留到以后赋值。
315 |
316 | ```javascript
317 | const foo;
318 | // SyntaxError: missing = in const declaration
319 | ```
320 |
321 | 上面代码表示,对于const来说,只声明不赋值,就会报错。
322 |
323 | const的作用域与let命令相同:只在声明所在的块级作用域内有效。
324 |
325 | ```javascript
326 | if (true) {
327 | const MAX = 5;
328 | }
329 |
330 | MAX // Uncaught ReferenceError: MAX is not defined
331 | ```
332 |
333 | const命令声明的常量也是不提升,同样存在暂时性死区,只能在声明的位置后面使用。
334 |
335 | ```javascript
336 | if (true) {
337 | console.log(MAX); // ReferenceError
338 | const MAX = 5;
339 | }
340 | ```
341 |
342 | 上面代码在常量`MAX`声明之前就调用,结果报错。
343 |
344 | const声明的常量,也与`let`一样不可重复声明。
345 |
346 | ```javascript
347 | var message = "Hello!";
348 | let age = 25;
349 |
350 | // 以下两行都会报错
351 | const message = "Goodbye!";
352 | const age = 30;
353 | ```
354 |
355 | 对于复合类型的变量,变量名不指向数据,而是指向数据所在的地址。const命令只是保证变量名指向的地址不变,并不保证该地址的数据不变,所以将一个对象声明为常量必须非常小心。
356 |
357 | ```javascript
358 | const foo = {};
359 | foo.prop = 123;
360 |
361 | foo.prop
362 | // 123
363 |
364 | foo = {} // TypeError: "foo" is read-only不起作用
365 | ```
366 |
367 | 上面代码中,常量`foo`储存的是一个地址,这个地址指向一个对象。不可变的只是这个地址,即不能把`foo`指向另一个地址,但对象本身是可变的,所以依然可以为其添加新属性。
368 |
369 | 下面是另一个例子。
370 |
371 | ```js
372 | const a = [];
373 | a.push("Hello"); // 可执行
374 | a.length = 0; // 可执行
375 | a = ["Dave"]; // 报错
376 | ```
377 |
378 | 上面代码中,常量`a`是一个数组,这个数组本身是可写的,但是如果将另一个数组赋值给`a`,就会报错。
379 |
380 | 如果真的想将对象冻结,应该使用`Object.freeze`方法。
381 |
382 | ```javascript
383 | const foo = Object.freeze({});
384 | foo.prop = 123; // 不起作用
385 | ```
386 |
387 | 上面代码中,常量`foo`指向一个冻结的对象,所以添加新属性不起作用。
388 |
389 | 除了将对象本身冻结,对象的属性也应该冻结。下面是一个将对象彻底冻结的函数。
390 |
391 | ```javascript
392 | var constantize = (obj) => {
393 | Object.freeze(obj);
394 | Object.keys(obj).forEach( (key, value) => {
395 | if ( typeof obj[key] === 'object' ) {
396 | constantize( obj[key] );
397 | }
398 | });
399 | };
400 | ```
401 |
402 | ES5只有两种声明变量的方法:var命令和function命令。ES6除了添加let和const命令,后面章节还会提到,另外两种声明变量的方法:import命令和class命令。所以,ES6一共有6种声明变量的方法。
403 |
404 | ## 跨模块常量
405 |
406 | 上面说过,const声明的常量只在当前代码块有效。如果想设置跨模块的常量,可以采用下面的写法。
407 |
408 | ```javascript
409 | // constants.js 模块
410 | export const A = 1;
411 | export const B = 3;
412 | export const C = 4;
413 |
414 | // test1.js 模块
415 | import * as constants from './constants';
416 | console.log(constants.A); // 1
417 | console.log(constants.B); // 3
418 |
419 | // test2.js 模块
420 | import {A, B} from './constants';
421 | console.log(A); // 1
422 | console.log(B); // 3
423 | ```
424 |
425 | ## 全局对象的属性
426 |
427 | 全局对象是最顶层的对象,在浏览器环境指的是`window`象,在Node.js指的是`global`对象。ES5之中,全局对象的属性与全局变量是等价的。
428 |
429 | ```javascript
430 | window.a = 1;
431 | a // 1
432 |
433 | a = 2;
434 | window.a // 2
435 | ```
436 |
437 | 上面代码中,全局对象的属性赋值与全局变量的赋值,是同一件事。(对于Node来说,这一条只对REPL环境适用,模块环境之中,全局变量必须显式声明成`global`对象的属性。)
438 |
439 | 这种规定被视为JavaScript语言的一大问题,因为很容易不知不觉就创建了全局变量。ES6为了改变这一点,一方面规定,var命令和function命令声明的全局变量,依旧是全局对象的属性;另一方面规定,let命令、const命令、class命令声明的全局变量,不属于全局对象的属性。
440 |
441 | ```javascript
442 | var a = 1;
443 | // 如果在Node的REPL环境,可以写成global.a
444 | // 或者采用通用方法,写成this.a
445 | window.a // 1
446 |
447 | let b = 1;
448 | window.b // undefined
449 | ```
450 |
451 | 上面代码中,全局变量`a`由`var`命令声明,所以它是全局对象的属性;全局变量`b`由`let`命令声明,所以它不是全局对象的属性,返回`undefined`。
452 |
--------------------------------------------------------------------------------
/docs/regex.md:
--------------------------------------------------------------------------------
1 | # 正则的扩展
2 |
3 | ## RegExp构造函数
4 |
5 | 在ES5中,RegExp构造函数只能接受字符串作为参数。
6 |
7 | ```javascript
8 | var regex = new RegExp("xyz", "i");
9 | // 等价于
10 | var regex = /xyz/i;
11 | ```
12 |
13 | ES6允许RegExp构造函数接受正则表达式作为参数,这时会返回一个原有正则表达式的拷贝。
14 |
15 | ```javascript
16 | var regex = new RegExp(/xyz/i);
17 | ```
18 |
19 | 如果使用RegExp构造函数的第二个参数指定修饰符,则返回的正则表达式会忽略原有的正则表达式的修饰符,只使用新指定的修饰符。
20 |
21 | ```javascript
22 | new RegExp(/abc/ig, 'i').flags
23 | // "i"
24 | ```
25 |
26 | ## 字符串的正则方法
27 |
28 | 字符串对象共有4个方法,可以使用正则表达式:match()、replace()、search()和split()。
29 |
30 | ES6将这4个方法,在语言内部全部调用RegExp的实例方法,从而做到所有与正则相关的方法,全都定义在RegExp对象上。
31 |
32 | - String.prototype.match 调用 RegExp.prototype[Symbol.match]
33 | - String.prototype.replace 调用 RegExp.prototype[Symbol.replace]
34 | - String.prototype.search 调用 RegExp.prototype[Symbol.search]
35 | - String.prototype.split 调用 RegExp.prototype[Symbol.split]
36 |
37 | ## u修饰符
38 |
39 | ES6对正则表达式添加了u修饰符,含义为“Unicode模式”,用来正确处理大于`\uFFFF`的Unicode字符。也就是说,会正确处理四个字节的UTF-16编码。
40 |
41 | ```javascript
42 | /^\uD83D/u.test('\uD83D\uDC2A')
43 | // false
44 | /^\uD83D/.test('\uD83D\uDC2A')
45 | // true
46 | ```
47 |
48 | 上面代码中,“\uD83D\uDC2A”是一个四个字节的UTF-16编码,代表一个字符。但是,ES5不支持四个字节的UTF-16编码,会将其识别为两个字符,导致第二行代码结果为true。加了u修饰符以后,ES6就会识别其为一个字符,所以第一行代码结果为false。
49 |
50 | 一旦加上u修饰符号,就会修改下面这些正则表达式的行为。
51 |
52 | **(1)点字符**
53 |
54 | 点(.)字符在正则表达式中,含义是除了换行符以外的任意单个字符。对于码点大于`0xFFFF`的Unicode字符,点字符不能识别,必须加上u修饰符。
55 |
56 | ```javascript
57 | var s = "𠮷";
58 |
59 | /^.$/.test(s) // false
60 | /^.$/u.test(s) // true
61 | ```
62 |
63 | 上面代码表示,如果不添加u修饰符,正则表达式就会认为字符串为两个字符,从而匹配失败。
64 |
65 | **(2)Unicode字符表示法**
66 |
67 | ES6新增了使用大括号表示Unicode字符,这种表示法在正则表达式中必须加上u修饰符,才能识别。
68 |
69 | ```javascript
70 | /\u{61}/.test('a') // false
71 | /\u{61}/u.test('a') // true
72 | /\u{20BB7}/u.test('𠮷') // true
73 | ```
74 |
75 | 上面代码表示,如果不加u修饰符,正则表达式无法识别`\u{61}`这种表示法,只会认为这匹配61个连续的u。
76 |
77 | **(3)量词**
78 |
79 | 使用u修饰符后,所有量词都会正确识别大于码点大于`0xFFFF`的Unicode字符。
80 |
81 | ```javascript
82 | /a{2}/.test('aa') // true
83 | /a{2}/u.test('aa') // true
84 | /𠮷{2}/.test('𠮷𠮷') // false
85 | /𠮷{2}/u.test('𠮷𠮷') // true
86 | ```
87 |
88 | 另外,只有在使用u修饰符的情况下,Unicode表达式当中的大括号才会被正确解读,否则会被解读为量词。
89 |
90 | ```javascript
91 | /^\u{3}$/.test('uuu') // true
92 | ```
93 |
94 | 上面代码中,由于正则表达式没有u修饰符,所以大括号被解读为量词。加上u修饰符,就会被解读为Unicode表达式。
95 |
96 | **(4)预定义模式**
97 |
98 | u修饰符也影响到预定义模式,能否正确识别码点大于`0xFFFF`的Unicode字符。
99 |
100 | ```javascript
101 | /^\S$/.test('𠮷') // false
102 | /^\S$/u.test('𠮷') // true
103 | ```
104 |
105 | 上面代码的`\S`是预定义模式,匹配所有不是空格的字符。只有加了u修饰符,它才能正确匹配码点大于0xFFFF的Unicode字符。
106 |
107 | 利用这一点,可以写出一个正确返回字符串长度的函数。
108 |
109 | ```javascript
110 | function codePointLength(text) {
111 | var result = text.match(/[\s\S]/gu);
112 | return result ? result.length : 0;
113 | }
114 |
115 | var s = "𠮷𠮷";
116 |
117 | s.length // 4
118 | codePointLength(s) // 2
119 | ```
120 |
121 | **(5)i修饰符**
122 |
123 | 有些Unicode字符的编码不同,但是字型很相近,比如,\u004B与\u212A都是大写的K。
124 |
125 | ```javascript
126 | /[a-z]/i.test('\u212A') // false
127 | /[a-z]/iu.test('\u212A') // true
128 | ```
129 |
130 | 上面代码中,不加u修饰符,就无法识别非规范的K字符。
131 |
132 | ## y修饰符
133 |
134 | 除了u修饰符,ES6还为正则表达式添加了y修饰符,叫做“粘连”(sticky)修饰符。
135 |
136 | y修饰符的作用与g修饰符类似,也是全局匹配,后一次匹配都从上一次匹配成功的下一个位置开始。不同之处在于,g修饰符只要剩余位置中存在匹配就可,而y修饰符确保匹配必须从剩余的第一个位置开始,这也就是“粘连”的涵义。
137 |
138 | ```javascript
139 | var s = "aaa_aa_a";
140 | var r1 = /a+/g;
141 | var r2 = /a+/y;
142 |
143 | r1.exec(s) // ["aaa"]
144 | r2.exec(s) // ["aaa"]
145 |
146 | r1.exec(s) // ["aa"]
147 | r2.exec(s) // null
148 | ```
149 |
150 | 上面代码有两个正则表达式,一个使用g修饰符,另一个使用y修饰符。这两个正则表达式各执行了两次,第一次执行的时候,两者行为相同,剩余字符串都是“_aa_a”。由于g修饰没有位置要求,所以第二次执行会返回结果,而y修饰符要求匹配必须从头部开始,所以返回null。
151 |
152 | 如果改一下正则表达式,保证每次都能头部匹配,y修饰符就会返回结果了。
153 |
154 | ```javascript
155 | var s = "aaa_aa_a";
156 | var r = /a+_/y;
157 |
158 | r.exec(s) // ["aaa_"]
159 | r.exec(s) // ["aa_"]
160 | ```
161 |
162 | 上面代码每次匹配,都是从剩余字符串的头部开始。
163 |
164 | 使用lastIndex属性,可以更好地说明y修饰符。
165 |
166 | ```javascript
167 | const REGEX = /a/g;
168 |
169 | REGEX.lastIndex = 2; // 指定从第三个位置y开始搜索
170 | const match = REGEX.exec('xaya');
171 |
172 | match.index
173 | // 3
174 | REGEX.lastIndex
175 | // 4
176 | REGEX.exec('xaxa')
177 | // null
178 | ```
179 |
180 | 上面代码中,lastIndex属性指定每次搜索的开始位置,g修饰符从这个位置开始向后搜索,直到发现匹配为止。
181 |
182 | y修饰符同样遵守lastIndex属性,但是要求必须在lastIndex指定的位置发现匹配。
183 |
184 | ```javascript
185 | const REGEX = /a/y;
186 |
187 | // 第三个位置y不匹配
188 | REGEX.lastIndex = 2;
189 | console.log(REGEX.exec('xaya')); // null
190 |
191 | // 第四个位置出现匹配
192 | REGEX.lastIndex = 3;
193 | const match = REGEX.exec('xaxa');
194 | match.index // 3
195 | REGEX.lastIndex // 4
196 | ```
197 |
198 | 进一步说,y修饰符号隐含了头部匹配的标志ˆ。
199 |
200 | ```javascript
201 | /b/y.exec("aba")
202 | // null
203 | ```
204 |
205 | 上面代码由于不能保证头部匹配,所以返回null。y修饰符的设计本意,就是让头部匹配的标志ˆ在全局匹配中都有效。
206 |
207 | 在split方法中使用y修饰符,原字符串必须以分隔符开头。这也意味着,只要匹配成功,数组的第一个成员肯定是空字符串。
208 |
209 | ```javascript
210 | // 没有找到匹配
211 | 'x##'.split(/#/y)
212 | // [ 'x##' ]
213 |
214 | // 找到两个匹配
215 | '##x'.split(/#/y)
216 | // [ '', '', 'x' ]
217 | ```
218 |
219 | 后续的分隔符只有紧跟前面的分隔符,才会被识别。
220 |
221 | ```javascript
222 | '#x#'.split(/#/y)
223 | // [ '', 'x#' ]
224 |
225 | '##'.split(/#/y)
226 | // [ '', '', '' ]
227 | ```
228 |
229 | 下面是字符串对象的replace方法的例子。
230 |
231 | ```javascript
232 | const REGEX = /a/gy;
233 | 'aaxa'.replace(REGEX, '-') // '--xa'
234 | ```
235 |
236 | 上面代码中,最后一个a因为不是出现下一次匹配的头部,所以不会被替换。
237 |
238 | 如果同时使用g修饰符和y修饰符,则y修饰符覆盖g修饰符。
239 |
240 | y修饰符的主要作用,是从字符串提取token(词元),y修饰符确保了匹配之间不会有漏掉的字符。
241 |
242 | ```javascript
243 | function tokenize(TOKEN_REGEX, str) {
244 | let result = [];
245 | let match;
246 | while (match = TOKEN_REGEX.exec(str)) {
247 | result.push(match[1]);
248 | }
249 | return result;
250 | }
251 |
252 | const TOKEN_Y = /\s*(\+|[0-9]+)\s*/y;
253 | const TOKEN_G = /\s*(\+|[0-9]+)\s*/g;
254 |
255 | tokenize(TOKEN_Y, '3 + 4')
256 | // [ '3', '+', '4' ]
257 | tokenize(TOKEN_G, '3 + 4')
258 | // [ '3', '+', '4' ]
259 | ```
260 |
261 | 上面代码中,如果字符串里面没有非法字符,y修饰符与g修饰符的提取结果是一样的。但是,一旦出现非法字符,两者的行为就不一样了。
262 |
263 | ```javascript
264 | tokenize(TOKEN_Y, '3x + 4')
265 | // [ '3' ]
266 | tokenize(TOKEN_G, '3x + 4')
267 | // [ '3', '+', '4' ]
268 | ```
269 |
270 | 上面代码中,g修饰符会忽略非法字符,而y修饰符不会,这样就很容易发现错误。
271 |
272 | ## sticky属性
273 |
274 | 与y修饰符相匹配,ES6的正则对象多了sticky属性,表示是否设置了y修饰符。
275 |
276 | ```javascript
277 | var r = /hello\d/y;
278 | r.sticky // true
279 | ```
280 |
281 | ## flags属性
282 |
283 | ES6为正则表达式新增了flags属性,会返回正则表达式的修饰符。
284 |
285 | ```javascript
286 | // ES5的source属性
287 | // 返回正则表达式的正文
288 | /abc/ig.source
289 | // "abc"
290 |
291 | // ES6的flags属性
292 | // 返回正则表达式的修饰符
293 | /abc/ig.flags
294 | // 'gi'
295 | ```
296 |
297 | ## RegExp.escape()
298 |
299 | 字符串必须转义,才能作为正则模式。
300 |
301 | ```javascript
302 | function escapeRegExp(str) {
303 | return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
304 | }
305 |
306 | let str = '/path/to/resource.html?search=query';
307 | escapeRegExp(str)
308 | // "\/path\/to\/resource\.html\?search=query"
309 | ```
310 |
311 | 上面代码中,str是一个正常字符串,必须使用反斜杠对其中的特殊字符转义,才能用来作为一个正则匹配的模式。
312 |
313 | 已经有[提议](https://esdiscuss.org/topic/regexp-escape)将这个需求标准化,作为RegExp对象的静态方法[RegExp.escape()](https://github.com/benjamingr/RexExp.escape),放入ES7。2015年7月31日,TC39认为,这个方法有安全风险,又不愿这个方法变得过于复杂,没有同意将其列入ES7,但这不失为一个真实的需求。
314 |
315 | ```javascript
316 | RegExp.escape("The Quick Brown Fox");
317 | // "The Quick Brown Fox"
318 |
319 | RegExp.escape("Buy it. use it. break it. fix it.")
320 | // "Buy it\. use it\. break it\. fix it\."
321 |
322 | RegExp.escape("(*.*)");
323 | // "\(\*\.\*\)"
324 | ```
325 |
326 | 字符串转义以后,可以使用RegExp构造函数生成正则模式。
327 |
328 | ```javascript
329 | var str = 'hello. how are you?';
330 | var regex = new RegExp(RegExp.escape(str), 'g');
331 | assert.equal(String(regex), '/hello\. how are you\?/g');
332 | ```
333 |
334 | 目前,该方法可以用上文的escapeRegExp函数或者垫片模块[regexp.escape](https://github.com/ljharb/regexp.escape)实现。
335 |
336 | ```javascript
337 | var escape = require('regexp.escape');
338 | escape('hi. how are you?')
339 | "hi\\. how are you\\?"
340 | ```
341 |
342 |
--------------------------------------------------------------------------------
/docs/style.md:
--------------------------------------------------------------------------------
1 | # 编程风格
2 |
3 | 本章探讨如何将ES6的新语法,运用到编码实践之中,与传统的JavaScript语法结合在一起,写出合理的、易于阅读和维护的代码。多家公司和组织已经公开了它们的风格规范,具体可参阅[jscs.info](http://jscs.info/),下面的内容主要参考了[Airbnb](https://github.com/airbnb/javascript)的JavaScript风格规范。
4 |
5 | ## 块级作用域
6 |
7 | **(1)let取代var**
8 |
9 | ES6提出了两个新的声明变量的命令:let和const。其中,let完全可以取代var,因为两者语义相同,而且let没有副作用。
10 |
11 | ```javascript
12 | "use strict";
13 |
14 | if(true) {
15 | let x = 'hello';
16 | }
17 |
18 | for (let i = 0; i < 10; i++) {
19 | console.log(i);
20 | }
21 | ```
22 |
23 | 上面代码如果用var替代let,实际上就声明了一个全局变量,这显然不是本意。变量应该只在其声明的代码块内有效,var命令做不到这一点。
24 |
25 | var命令存在变量提升效用,let命令没有这个问题。
26 |
27 | ```javascript
28 | "use strict";
29 |
30 | if(true) {
31 | console.log(x); // ReferenceError
32 | let x = 'hello';
33 | }
34 | ```
35 |
36 | 上面代码如果使用var替代let,console.log那一行就不会报错,而是会输出undefined,因为变量声明提升到代码块的头部。这违反了变量先声明后使用的原则。
37 |
38 | 所以,建议不再使用var命令,而是使用let命令取代。
39 |
40 | **(2)全局常量和线程安全**
41 |
42 | 在let和const之间,建议优先使用const,尤其是在全局环境,不应该设置变量,只应设置常量。这符合函数式编程思想,有利于将来的分布式运算。
43 |
44 | ```javascript
45 | // bad
46 | var a = 1, b = 2, c = 3;
47 |
48 | // good
49 | const a = 1;
50 | const b = 2;
51 | const c = 3;
52 |
53 | // best
54 | const [a, b, c] = [1, 2, 3];
55 | ```
56 |
57 | const声明常量还有两个好处,一是阅读代码的人立刻会意识到不应该修改这个值,二是防止了无意间修改变量值所导致的错误。
58 |
59 | 所有的函数都应该设置为常量。
60 |
61 | let表示的变量,只应出现在单线程运行的代码中,不能是多线程共享的,这样有利于保证线程安全。
62 |
63 | **(3)严格模式**
64 |
65 | V8引擎只在严格模式之下,支持let和const。结合前两点,这实际上意味着,将来所有的编程都是针对严格模式的。
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 |
268 | 箭头函数取代Function.prototype.bind,不应再用self/\_this/that绑定 this。
269 |
270 | ```javascript
271 | // bad
272 | const self = this;
273 | const boundMethod = function(...params) {
274 | return method.apply(self, params);
275 | }
276 |
277 | // acceptable
278 | const boundMethod = method.bind(this);
279 |
280 | // best
281 | const boundMethod = (...params) => method.apply(this, params);
282 | ```
283 |
284 | 所有配置项都应该集中在一个对象,放在最后一个参数,布尔值不可以直接作为参数。
285 |
286 | ```bash
287 | // bad
288 | function divide(a, b, option = false ) {
289 | }
290 |
291 | // good
292 | function divide(a, b, { option = false } = {}) {
293 | }
294 | ```
295 |
296 | 不要在函数体内使用arguments变量,使用rest运算符(...)代替。因为rest运算符显式表明你想要获取参数,而且arguments是一个类似数组的对象,而rest运算符可以提供一个真正的数组。
297 |
298 | ```javascript
299 | // bad
300 | function concatenateAll() {
301 | const args = Array.prototype.slice.call(arguments);
302 | return args.join('');
303 | }
304 |
305 | // good
306 | function concatenateAll(...args) {
307 | return args.join('');
308 | }
309 | ```
310 |
311 | 使用默认值语法设置函数参数的默认值。
312 |
313 | ```javascript
314 | // bad
315 | function handleThings(opts) {
316 | opts = opts || {};
317 | }
318 |
319 | // good
320 | function handleThings(opts = {}) {
321 | // ...
322 | }
323 | ```
324 |
325 | ## Map结构
326 |
327 | 注意区分Object和Map,只有模拟实体对象时,才使用Object。如果只是需要key:value的数据结构,使用Map。因为Map有内建的遍历机制。
328 |
329 | ```javascript
330 | let map = new Map(arr);
331 |
332 | for (let key of map.keys()) {
333 | console.log(key);
334 | }
335 |
336 | for (let value of map.values()) {
337 | console.log(value);
338 | }
339 |
340 | for (let item of map.entries()) {
341 | console.log(item[0], item[1]);
342 | }
343 | ```
344 |
345 | ## Class
346 |
347 | 总是用class,取代需要prototype操作。因为class的写法更简洁,更易于理解。
348 |
349 | ```javascript
350 | // bad
351 | function Queue(contents = []) {
352 | this._queue = [...contents];
353 | }
354 | Queue.prototype.pop = function() {
355 | const value = this._queue[0];
356 | this._queue.splice(0, 1);
357 | return value;
358 | }
359 |
360 | // good
361 | class Queue {
362 | constructor(contents = []) {
363 | this._queue = [...contents];
364 | }
365 | pop() {
366 | const value = this._queue[0];
367 | this._queue.splice(0, 1);
368 | return value;
369 | }
370 | }
371 | ```
372 |
373 | 使用extends实现继承,因为这样更简单,不会有破坏instanceof运算的危险。
374 |
375 | ```javascript
376 | // bad
377 | const inherits = require('inherits');
378 | function PeekableQueue(contents) {
379 | Queue.apply(this, contents);
380 | }
381 | inherits(PeekableQueue, Queue);
382 | PeekableQueue.prototype.peek = function() {
383 | return this._queue[0];
384 | }
385 |
386 | // good
387 | class PeekableQueue extends Queue {
388 | peek() {
389 | return this._queue[0];
390 | }
391 | }
392 | ```
393 |
394 | ## 模块
395 |
396 | 首先,Module语法是JavaScript模块的标准写法,坚持使用这种写法。使用import取代require。
397 |
398 | ```javascript
399 | // bad
400 | const moduleA = require('moduleA');
401 | const func1 = moduleA.func1;
402 | const func2 = moduleA.func2;
403 |
404 | // good
405 | import { func1, func2 } from 'moduleA';
406 | ```
407 |
408 | 使用export取代module.exports。
409 |
410 | ```javascript
411 | // commonJS的写法
412 | var React = require('react');
413 |
414 | var Breadcrumbs = React.createClass({
415 | render() {
416 | return ;
417 | }
418 | });
419 |
420 | module.exports = Breadcrumbs;
421 |
422 | // ES6的写法
423 | import React from 'react';
424 |
425 | const Breadcrumbs = React.createClass({
426 | render() {
427 | return ;
428 | }
429 | });
430 |
431 | export default Breadcrumbs
432 | ```
433 |
434 | 不要在模块输入中使用通配符。因为这样可以确保你的模块之中,有一个默认输出(export default)。
435 |
436 | ```javascript
437 | // bad
438 | import * as myObject './importModule';
439 |
440 | // good
441 | import myObject from './importModule';
442 | ```
443 |
444 | 如果模块默认输出一个函数,函数名的首字母应该小写。
445 |
446 | ```javascript
447 | function makeStyleGuide() {
448 | }
449 |
450 | export default makeStyleGuide;
451 | ```
452 |
453 | 如果模块默认输出一个对象,对象名的首字母应该大写。
454 |
455 | ```javascript
456 | const StyleGuide = {
457 | es6: {
458 | }
459 | };
460 |
461 | export default StyleGuide;
462 | ```
463 |
464 | ## ESLint的使用
465 |
466 | ESLint是一个语法规则和代码风格的检查工具,可以用来保证写出语法正确、风格统一的代码。
467 |
468 | 首先,安装ESLint。
469 |
470 | ```bash
471 | $ npm i -g eslint
472 | ```
473 |
474 | 然后,安装Airbnb语法规则。
475 |
476 | ```bash
477 | $ npm i -g eslint-config-airbnb
478 | ```
479 |
480 | 最后,在项目的根目录下新建一个`.eslintrc`文件,配置ESLint。
481 |
482 | ```javascript
483 | {
484 | "extends": "eslint-config-airbnb"
485 | }
486 | ```
487 |
488 | 现在就可以检查,当前项目的代码是否符合预设的规则。
489 |
490 | `index.js`文件的代码如下。
491 |
492 | ```javascript
493 | var unusued = 'I have no purpose!';
494 |
495 | function greet() {
496 | var message = 'Hello, World!';
497 | alert(message);
498 | }
499 |
500 | greet();
501 | ```
502 |
503 | 使用ESLint检查这个文件。
504 |
505 | ```bash
506 | $ eslint index.js
507 | index.js
508 | 1:5 error unusued is defined but never used no-unused-vars
509 | 4:5 error Expected indentation of 2 characters but found 4 indent
510 | 5:5 error Expected indentation of 2 characters but found 4 indent
511 |
512 | ✖ 3 problems (3 errors, 0 warnings)
513 | ```
514 |
515 | 上面代码说明,原文件有三个错误,一个是定义了变量,却没有使用,另外两个是行首缩进为4个空格,而不是规定的2个空格。
516 |
--------------------------------------------------------------------------------
/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windiest/es6tutorial/56cd64119dd0ed2468c365a17465fbccfa322602/favicon.ico
--------------------------------------------------------------------------------
/images/copyright.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windiest/es6tutorial/56cd64119dd0ed2468c365a17465fbccfa322602/images/copyright.png
--------------------------------------------------------------------------------
/images/cover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windiest/es6tutorial/56cd64119dd0ed2468c365a17465fbccfa322602/images/cover.jpg
--------------------------------------------------------------------------------
/images/cover_thumbnail.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windiest/es6tutorial/56cd64119dd0ed2468c365a17465fbccfa322602/images/cover_thumbnail.jpg
--------------------------------------------------------------------------------
/images/page1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windiest/es6tutorial/56cd64119dd0ed2468c365a17465fbccfa322602/images/page1.png
--------------------------------------------------------------------------------
/images/page2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windiest/es6tutorial/56cd64119dd0ed2468c365a17465fbccfa322602/images/page2.png
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | ECMAScript 6入门
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | back to top
25 | edit
26 | Loading ...
27 | Opps! ... File not found!
28 |
29 |
30 |
31 |
42 |
43 | 《ECMAScript 6入门》是一本开源的JavaScript语言教程,全面介绍ECMAScript 6新增的语法特性。
44 | 本书力争覆盖ES6与ES5的所有不同之处,对涉及的语法知识给予详细介绍,并给出大量简洁易懂的示例代码。
45 | 本书为中级难度,适合已有一定JavaScript语言基础的读者,了解这门语言的最新进展;也可当作参考手册,查寻新增的语法点。
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/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. [Proxy和Reflect](#docs/proxy)
20 | 1. [二进制数组](#docs/arraybuffer)
21 | 1. [Set和Map数据结构](#docs/set-map)
22 | 1. [Iterator和for...of循环](#docs/iterator)
23 | 1. [Generator函数](#docs/generator)
24 | 1. [Promise对象](#docs/promise)
25 | 1. [异步操作和Async函数](#docs/async)
26 | 1. [Class](#docs/class)
27 | 1. [Decorator](#docs/decorator)
28 | 1. [Module](#docs/module)
29 | 1. [编程风格](#docs/style)
30 | 1. [参考链接](#docs/reference)
31 |
32 | ## 其他
33 | - [源码](http://github.com/ruanyf/es6tutorial/)
34 | - [修订历史](https://github.com/ruanyf/es6tutorial/commits/gh-pages)
35 | - [反馈意见](https://github.com/ruanyf/es6tutorial/issues)
36 |
--------------------------------------------------------------------------------