4 |
5 | * In a list?
6 | *
7 | * It should.
8 |
9 | > Blockquoted:
10 |
11 | Auto-links should not occur here: ` `
12 |
13 | or here:
14 |
--------------------------------------------------------------------------------
/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/new/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/original/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/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/new/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.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/code_blocks.html:
--------------------------------------------------------------------------------
1 | code block on the first line
2 |
3 |
4 | Regular text.
5 |
6 | code block indented by spaces
7 |
8 |
9 | Regular text.
10 |
11 | the lines in this block
12 | all contain trailing spaces
13 |
14 |
15 | Regular Text.
16 |
17 | code block on the last line
18 |
19 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/original/code_blocks.html:
--------------------------------------------------------------------------------
1 | code block on the first line
2 |
3 |
4 | Regular text.
5 |
6 | code block indented by spaces
7 |
8 |
9 | Regular text.
10 |
11 | the lines in this block
12 | all contain trailing spaces
13 |
14 |
15 | Regular Text.
16 |
17 | code block on the last line
18 |
19 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/original/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/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/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/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "marked",
3 | "homepage": "https://github.com/chjj/marked",
4 | "version": "0.3.2",
5 | "_release": "0.3.2",
6 | "_resolution": {
7 | "type": "version",
8 | "tag": "v0.3.2",
9 | "commit": "43db549e31af5ff6e4a3b12e41a23513b9f88c99"
10 | },
11 | "_source": "git://github.com/chjj/marked.git",
12 | "_target": "~0.3.2",
13 | "_originalSource": "marked",
14 | "_direct": true
15 | }
--------------------------------------------------------------------------------
/app/bower_components/marked/test/original/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/new/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.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 |
--------------------------------------------------------------------------------
/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | ES6标准参考教程
4 |
14 |
15 |
16 | redirecting...
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/amps_and_angles_encoding.text:
--------------------------------------------------------------------------------
1 | AT&T has an ampersand in their name.
2 |
3 | AT&T is another way to write it.
4 |
5 | This & that.
6 |
7 | 4 < 5.
8 |
9 | 6 > 5.
10 |
11 | Here's a [link] [1] with an ampersand in the URL.
12 |
13 | Here's a link with an amersand in the link text: [AT&T] [2].
14 |
15 | Here's an inline [link](/script?foo=1&bar=2).
16 |
17 | Here's an inline [link]().
18 |
19 |
20 | [1]: http://example.com/?foo=1&bar=2
21 | [2]: http://att.com/ "AT&T"
22 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/original/amps_and_angles_encoding.text:
--------------------------------------------------------------------------------
1 | AT&T has an ampersand in their name.
2 |
3 | AT&T is another way to write it.
4 |
5 | This & that.
6 |
7 | 4 < 5.
8 |
9 | 6 > 5.
10 |
11 | Here's a [link] [1] with an ampersand in the URL.
12 |
13 | Here's a link with an amersand in the link text: [AT&T] [2].
14 |
15 | Here's an inline [link](/script?foo=1&bar=2).
16 |
17 | Here's an inline [link]().
18 |
19 |
20 | [1]: http://example.com/?foo=1&bar=2
21 | [2]: http://att.com/ "AT&T"
22 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/new/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/new/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/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/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/original/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/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/original/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.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/original/amps_and_angles_encoding.html:
--------------------------------------------------------------------------------
1 | AT&T has an ampersand in their name.
2 |
3 | AT&T is another way to write it.
4 |
5 | This & that.
6 |
7 | 4 < 5.
8 |
9 | 6 > 5.
10 |
11 | Here's a link with an ampersand in the URL.
12 |
13 | Here's a link with an amersand in the link text: AT&T .
14 |
15 | Here's an inline link .
16 |
17 | Here's an inline link .
18 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/new/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/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/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/original/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/amps_and_angles_encoding.html:
--------------------------------------------------------------------------------
1 | AT&T has an ampersand in their name.
2 |
3 | AT&T is another way to write it.
4 |
5 | This & that.
6 |
7 | 4 < 5.
8 |
9 | 6 > 5.
10 |
11 | Here's a link with an ampersand in the URL.
12 |
13 | Here's a link with an amersand in the link text: AT&T .
14 |
15 | Here's an inline link .
16 |
17 | Here's an inline link .
18 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/auto_links.html:
--------------------------------------------------------------------------------
1 | Link: http://example.com/ .
2 |
3 | With an ampersand: http://example.com/?foo=1&bar=2
4 |
5 |
10 |
11 |
12 | Blockquoted: http://example.com/
13 |
14 |
15 | Auto-links should not occur here: <http://example.com/>
16 |
17 | or here: <http://example.com/>
18 |
19 |
--------------------------------------------------------------------------------
/config.js:
--------------------------------------------------------------------------------
1 | var CONFIG = {
2 | // your website's title
3 | document_title: "ECMAScript 6入门",
4 |
5 | // index page
6 | index: "README.md",
7 |
8 | // sidebar file
9 | sidebar_file: "sidebar.md",
10 |
11 | // where the docs are actually stored on github - so you can edit
12 | base_url: "https://github.com/ruanyf/es6tutorial/edit/gh-pages",
13 | };
14 |
15 | // **************************
16 | // DON'T EDIT FOLLOWING CODES
17 | // **************************
18 |
19 | addConfig(ditto, CONFIG);
20 |
21 | function addConfig(obj, conf) {
22 | Object.keys(conf).forEach(function (key) {
23 | obj[key] = conf[key];
24 | });
25 | }
26 |
27 | ditto.run();
28 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/original/auto_links.html:
--------------------------------------------------------------------------------
1 | Link: http://example.com/ .
2 |
3 | With an ampersand: http://example.com/?foo=1&bar=2
4 |
5 |
10 |
11 |
12 | Blockquoted: http://example.com/
13 |
14 |
15 | Auto-links should not occur here: <http://example.com/>
16 |
17 | or here: <http://example.com/>
18 |
19 |
--------------------------------------------------------------------------------
/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/marked/test/new/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.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/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/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "marked",
3 | "description": "A markdown parser built for speed",
4 | "author": "Christopher Jeffrey",
5 | "version": "0.3.2",
6 | "main": "./lib/marked.js",
7 | "bin": "./bin/marked",
8 | "man": "./man/marked.1",
9 | "preferGlobal": true,
10 | "repository": "git://github.com/chjj/marked.git",
11 | "homepage": "https://github.com/chjj/marked",
12 | "bugs": { "url": "http://github.com/chjj/marked/issues" },
13 | "license": "MIT",
14 | "keywords": ["markdown", "markup", "html"],
15 | "tags": ["markdown", "markup", "html"],
16 | "devDependencies": {
17 | "markdown": "*",
18 | "showdown": "*",
19 | "robotskirt": "*"
20 | },
21 | "scripts": { "test": "node test", "bench": "node test --bench" }
22 | }
23 |
--------------------------------------------------------------------------------
/book.json:
--------------------------------------------------------------------------------
1 | {
2 | "author": "阮一峰",
3 | "description": "《ECMAScript 6 入门》是一本开源的 JavaScript 语言教程,全面介绍 ECMAScript 6 新引入的语法特性。",
4 | "extension": null,
5 | "generator": "site",
6 | "isbn": "9787121324758",
7 | "links": {
8 | "sharing": {
9 | "all": null,
10 | "facebook": null,
11 | "google": null,
12 | "twitter": null,
13 | "weibo": null
14 | },
15 | "sidebar": {
16 | "阮一峰的个人网站": "https://www.ruanyifeng.com/blog/"
17 | }
18 | },
19 | "output": null,
20 | "pdf": {
21 | "fontSize": 12,
22 | "footerTemplate": null,
23 | "headerTemplate": null,
24 | "margin": {
25 | "bottom": 36,
26 | "left": 62,
27 | "right": 62,
28 | "top": 36
29 | },
30 | "pageNumbers": false,
31 | "paperSize": "a4"
32 | },
33 | "plugins": [],
34 | "title": "ECMAScript 6 入门",
35 | "variables": {}
36 | }
--------------------------------------------------------------------------------
/app/bower_components/marked/test/original/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/new/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_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/new/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/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/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/original/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/new/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.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/browser/index.js:
--------------------------------------------------------------------------------
1 | var fs = require('fs');
2 |
3 | var test = require('../')
4 | , runTests = test.runTests
5 | , load = test.load;
6 |
7 | var express = require('express')
8 | , app = express();
9 |
10 | app.use(function(req, res, next) {
11 | var setHeader = res.setHeader;
12 | res.setHeader = function(name) {
13 | switch (name) {
14 | case 'Cache-Control':
15 | case 'Last-Modified':
16 | case 'ETag':
17 | return;
18 | }
19 | return setHeader.apply(res, arguments);
20 | };
21 | next();
22 | });
23 |
24 | var dir = __dirname + '/../tests'
25 | , files = {};
26 |
27 | app.get('/test.js', function(req, res, next) {
28 | var test = fs.readFileSync(__dirname + '/test.js', 'utf8')
29 | , files = load();
30 |
31 | test = test.replace('__TESTS__', JSON.stringify(files));
32 | test = test.replace('__MAIN__', runTests + '');
33 |
34 | res.contentType('.js');
35 | res.send(test);
36 | });
37 |
38 | app.use(express.static(__dirname + '/../../lib'));
39 | app.use(express.static(__dirname));
40 |
41 | app.listen(8080);
42 |
--------------------------------------------------------------------------------
/SUMMARY.md:
--------------------------------------------------------------------------------
1 | # Summary
2 |
3 | * [0. 前言](README.md)
4 | * [1. ECMAScript 6简介](docs/intro.md)
5 | * [2. let 和 const 命令](docs/let.md)
6 | * [3. 变量的解构赋值](docs/destructuring.md)
7 | * [4. 字符串的扩展](docs/string.md)
8 | * [5. 正则的扩展](docs/regex.md)
9 | * [6. 数值的扩展](docs/number.md)
10 | * [7. 函数的扩展](docs/function.md)
11 | * [8. 数组的扩展](docs/array.md)
12 | * [9. 对象的扩展](docs/object.md)
13 | * [10. Symbol](docs/symbol.md)
14 | * [11. Set 和 Map 数据结构](docs/set-map.md)
15 | * [12. Proxy](docs/proxy.md)
16 | * [13. Reflect](docs/reflect.md)
17 | * [14. Promise 对象](docs/promise.md)
18 | * [15. Iterator 和 for...of 循环](docs/iterator.md)
19 | * [16. Generator 函数的语法](docs/generator.md)
20 | * [17. Generator 函数的异步应用](docs/generator-async.md)
21 | * [18. async 函数](docs/async.md)
22 | * [19. Class 的基本语法](docs/class.md)
23 | * [20. Class 的继承](docs/class-extends.md)
24 | * [21. Decorator](docs/decorator.md)
25 | * [22. Module 的语法](docs/module.md)
26 | * [23. Module 的加载实现](docs/module-loader.md)
27 | * [24. 编程风格](docs/style.md)
28 | * [25. 读懂规格](docs/spec.md)
29 | * [26. ArrayBuffer](docs/arraybuffer.md)
30 | * [27. 最新提案](docs/proposals.md)
31 | * [28. 参考链接](docs/reference.md)
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ES6 入门教程
2 |
3 | - [官方镜像](https://wangdoc.com/es6/)
4 | - [JavaScript 教程](https://wangdoc.com/javascript)
5 | - [TypeScript 教程](https://wangdoc.com/typescript)
6 |
7 | 《ECMAScript 6 入门教程》是一本开源的 JavaScript 语言教程,全面介绍 ECMAScript 6 新引入的语法特性。
8 |
9 | [](images/cover-3rd.jpg)
10 |
11 | 本书覆盖 ES6 与上一个版本 ES5 的所有不同之处,对涉及的语法知识给予详细介绍,并给出大量简洁易懂的示例代码。
12 |
13 | 本书为中级难度,适合已经掌握 ES5 的读者,用来了解这门语言的最新发展;也可当作参考手册,查寻新增的语法点。如果你是 JavaScript 语言的初学者,建议先学完[《JavaScript 语言教程》](https://wangdoc.com/javascript/),再来看本书。
14 |
15 | 全书已由电子工业出版社出版,2017年9月推出了第三版,书名为《ES6 标准入门》。纸版内容截止到出版时,网站内容一直在修订。
16 |
17 | - [淘宝](https://s.taobao.com/search?q=ES6%E6%A0%87%E5%87%86%E5%85%A5%E9%97%A8+%E7%AC%AC3%E7%89%88)
18 | - [京东](https://search.jd.com/Search?keyword=ES6%E6%A0%87%E5%87%86%E5%85%A5%E9%97%A8%20%E7%AC%AC3%E7%89%88&enc=utf-8&wq=ES6%E6%A0%87%E5%87%86%E5%85%A5%E9%97%A8%20%E7%AC%AC3%E7%89%88)
19 | - [当当](https://product.dangdang.com/25156888.html)
20 |
21 | ### 版权许可
22 |
23 | 本书采用“保持署名—非商用”创意共享4.0许可证。
24 |
25 | 只要保持原作者署名和非商用,您可以自由地阅读、分享、修改本书。
26 |
27 | 详细的法律条文请参见[创意共享](http://creativecommons.org/licenses/by-nc/4.0/)网站。
28 |
29 |
--------------------------------------------------------------------------------
/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/original/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/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/original/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/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/marked/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011-2014, Christopher Jeffrey (https://github.com/chjj/)
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all 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
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/new/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/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/new/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.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 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | # Creative Commons Attribution-NonCommercial 4.0 International License
2 |
3 | Disclaimer: This is a human-readable summary of (and not a substitute for) the [license](http://creativecommons.org/licenses/by-nc/4.0/legalcode).
4 |
5 | You are free to:
6 |
7 | - Share — copy and redistribute the material in any medium or format
8 | - Adapt — remix, transform, and build upon the material
9 |
10 | The licensor cannot revoke these freedoms as long as you follow the license terms.
11 |
12 | Under the following terms:
13 |
14 | - Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
15 | - NonCommercial — You may not use the material for commercial purposes.
16 | - No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
17 |
18 | Notices:
19 |
20 | You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
21 |
22 | No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
23 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/original/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.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/browser/test.js:
--------------------------------------------------------------------------------
1 | ;(function() {
2 |
3 | var console = {}
4 | , files = __TESTS__;
5 |
6 | console.log = function(text) {
7 | var args = Array.prototype.slice.call(arguments, 1)
8 | , i = 0;
9 |
10 | text = text.replace(/%\w/g, function() {
11 | return args[i++] || '';
12 | });
13 |
14 | if (window.console) window.console.log(text);
15 | document.body.innerHTML += '' + escape(text) + ' ';
16 | };
17 |
18 | if (!Object.keys) {
19 | Object.keys = function(obj) {
20 | var out = []
21 | , key;
22 |
23 | for (key in obj) {
24 | if (Object.prototype.hasOwnProperty.call(obj, key)) {
25 | out.push(key);
26 | }
27 | }
28 |
29 | return out;
30 | };
31 | }
32 |
33 | if (!Array.prototype.forEach) {
34 | Array.prototype.forEach = function(callback, context) {
35 | for (var i = 0; i < this.length; i++) {
36 | callback.call(context || null, this[i], i, obj);
37 | }
38 | };
39 | }
40 |
41 | if (!String.prototype.trim) {
42 | String.prototype.trim = function() {
43 | return this.replace(/^\s+|\s+$/g, '');
44 | };
45 | }
46 |
47 | function load() {
48 | return files;
49 | }
50 |
51 | function escape(html, encode) {
52 | return html
53 | .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
54 | .replace(//g, '>')
56 | .replace(/"/g, '"')
57 | .replace(/'/g, ''');
58 | }
59 |
60 | (__MAIN__)();
61 |
62 | }).call(this);
63 |
--------------------------------------------------------------------------------
/sidebar.md:
--------------------------------------------------------------------------------
1 | # [ECMAScript 6 入门]()
2 |
3 | 作者:[阮一峰](https://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/string-methods)
14 | 1. [正则的扩展](#docs/regex)
15 | 1. [数值的扩展](#docs/number)
16 | 1. [函数的扩展](#docs/function)
17 | 1. [数组的扩展](#docs/array)
18 | 1. [对象的扩展](#docs/object)
19 | 1. [对象的新增方法](#docs/object-methods)
20 | 1. [运算符的扩展](#docs/operator)
21 | 1. [Symbol](#docs/symbol)
22 | 1. [Set 和 Map 数据结构](#docs/set-map)
23 | 1. [Proxy](#docs/proxy)
24 | 1. [Reflect](#docs/reflect)
25 | 1. [Promise 对象](#docs/promise)
26 | 1. [Iterator 和 for...of 循环](#docs/iterator)
27 | 1. [Generator 函数的语法](#docs/generator)
28 | 1. [Generator 函数的异步应用](#docs/generator-async)
29 | 1. [async 函数](#docs/async)
30 | 1. [Class 的基本语法](#docs/class)
31 | 1. [Class 的继承](#docs/class-extends)
32 | 1. [Module 的语法](#docs/module)
33 | 1. [Module 的加载实现](#docs/module-loader)
34 | 1. [编程风格](#docs/style)
35 | 1. [读懂规格](#docs/spec)
36 | 1. [异步遍历器](#docs/async-iterator)
37 | 1. [ArrayBuffer](#docs/arraybuffer)
38 | 1. [最新提案](#docs/proposals)
39 | 1. [Decorator](#docs/decorator)
40 | 1. [参考链接](#docs/reference)
41 |
42 | ## 其他
43 | - [源码](https://github.com/ruanyf/es6tutorial/)
44 | - [修订历史](https://github.com/ruanyf/es6tutorial/commits/gh-pages)
45 | - [反馈意见](https://github.com/ruanyf/es6tutorial/issues)
46 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/new/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.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 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | ES6 入门教程
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | back to top
24 | edit
25 | theme
26 | Loading ...
27 | Oops! ... File not found!
28 |
29 |
30 |
31 |
32 |
33 |
34 | 《ECMAScript 6 入门教程》是一本开源的JavaScript语言教程,全面介绍ECMAScript 6新增的语法特性。
35 | 本书力争覆盖ES6与ES5的所有不同之处,对涉及的语法知识给予详细介绍,并给出大量简洁易懂的示例代码。
36 | 本书为中级难度,适合已有一定JavaScript语言基础的读者,了解这门语言的最新进展;也可当作参考手册,查寻新增的语法点。
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/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/original/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/backslash_escapes.text:
--------------------------------------------------------------------------------
1 | These should all get escaped:
2 |
3 | Backslash: \\
4 |
5 | Backtick: \`
6 |
7 | Asterisk: \*
8 |
9 | Underscore: \_
10 |
11 | Left brace: \{
12 |
13 | Right brace: \}
14 |
15 | Left bracket: \[
16 |
17 | Right bracket: \]
18 |
19 | Left paren: \(
20 |
21 | Right paren: \)
22 |
23 | Greater-than: \>
24 |
25 | Hash: \#
26 |
27 | Period: \.
28 |
29 | Bang: \!
30 |
31 | Plus: \+
32 |
33 | Minus: \-
34 |
35 |
36 |
37 | These should not, because they occur within a code block:
38 |
39 | Backslash: \\
40 |
41 | Backtick: \`
42 |
43 | Asterisk: \*
44 |
45 | Underscore: \_
46 |
47 | Left brace: \{
48 |
49 | Right brace: \}
50 |
51 | Left bracket: \[
52 |
53 | Right bracket: \]
54 |
55 | Left paren: \(
56 |
57 | Right paren: \)
58 |
59 | Greater-than: \>
60 |
61 | Hash: \#
62 |
63 | Period: \.
64 |
65 | Bang: \!
66 |
67 | Plus: \+
68 |
69 | Minus: \-
70 |
71 |
72 | Nor should these, which occur in code spans:
73 |
74 | Backslash: `\\`
75 |
76 | Backtick: `` \` ``
77 |
78 | Asterisk: `\*`
79 |
80 | Underscore: `\_`
81 |
82 | Left brace: `\{`
83 |
84 | Right brace: `\}`
85 |
86 | Left bracket: `\[`
87 |
88 | Right bracket: `\]`
89 |
90 | Left paren: `\(`
91 |
92 | Right paren: `\)`
93 |
94 | Greater-than: `\>`
95 |
96 | Hash: `\#`
97 |
98 | Period: `\.`
99 |
100 | Bang: `\!`
101 |
102 | Plus: `\+`
103 |
104 | Minus: `\-`
105 |
106 |
107 | These should get escaped, even though they're matching pairs for
108 | other Markdown constructs:
109 |
110 | \*asterisks\*
111 |
112 | \_underscores\_
113 |
114 | \`backticks\`
115 |
116 | This is a code span with a literal backslash-backtick sequence: `` \` ``
117 |
118 | This is a tag with unescaped backticks bar .
119 |
120 | This is a tag with backslashes bar .
121 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/original/backslash_escapes.text:
--------------------------------------------------------------------------------
1 | These should all get escaped:
2 |
3 | Backslash: \\
4 |
5 | Backtick: \`
6 |
7 | Asterisk: \*
8 |
9 | Underscore: \_
10 |
11 | Left brace: \{
12 |
13 | Right brace: \}
14 |
15 | Left bracket: \[
16 |
17 | Right bracket: \]
18 |
19 | Left paren: \(
20 |
21 | Right paren: \)
22 |
23 | Greater-than: \>
24 |
25 | Hash: \#
26 |
27 | Period: \.
28 |
29 | Bang: \!
30 |
31 | Plus: \+
32 |
33 | Minus: \-
34 |
35 |
36 |
37 | These should not, because they occur within a code block:
38 |
39 | Backslash: \\
40 |
41 | Backtick: \`
42 |
43 | Asterisk: \*
44 |
45 | Underscore: \_
46 |
47 | Left brace: \{
48 |
49 | Right brace: \}
50 |
51 | Left bracket: \[
52 |
53 | Right bracket: \]
54 |
55 | Left paren: \(
56 |
57 | Right paren: \)
58 |
59 | Greater-than: \>
60 |
61 | Hash: \#
62 |
63 | Period: \.
64 |
65 | Bang: \!
66 |
67 | Plus: \+
68 |
69 | Minus: \-
70 |
71 |
72 | Nor should these, which occur in code spans:
73 |
74 | Backslash: `\\`
75 |
76 | Backtick: `` \` ``
77 |
78 | Asterisk: `\*`
79 |
80 | Underscore: `\_`
81 |
82 | Left brace: `\{`
83 |
84 | Right brace: `\}`
85 |
86 | Left bracket: `\[`
87 |
88 | Right bracket: `\]`
89 |
90 | Left paren: `\(`
91 |
92 | Right paren: `\)`
93 |
94 | Greater-than: `\>`
95 |
96 | Hash: `\#`
97 |
98 | Period: `\.`
99 |
100 | Bang: `\!`
101 |
102 | Plus: `\+`
103 |
104 | Minus: `\-`
105 |
106 |
107 | These should get escaped, even though they're matching pairs for
108 | other Markdown constructs:
109 |
110 | \*asterisks\*
111 |
112 | \_underscores\_
113 |
114 | \`backticks\`
115 |
116 | This is a code span with a literal backslash-backtick sequence: `` \` ``
117 |
118 | This is a tag with unescaped backticks bar .
119 |
120 | This is a tag with backslashes bar .
121 |
--------------------------------------------------------------------------------
/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/marked/test/original/backslash_escapes.html:
--------------------------------------------------------------------------------
1 | These should all get escaped:
2 |
3 | Backslash: \
4 |
5 | Backtick: `
6 |
7 | Asterisk: *
8 |
9 | Underscore: _
10 |
11 | Left brace: {
12 |
13 | Right brace: }
14 |
15 | Left bracket: [
16 |
17 | Right bracket: ]
18 |
19 | Left paren: (
20 |
21 | Right paren: )
22 |
23 | Greater-than: >
24 |
25 | Hash: #
26 |
27 | Period: .
28 |
29 | Bang: !
30 |
31 | Plus: +
32 |
33 | Minus: -
34 |
35 | These should not, because they occur within a code block:
36 |
37 | Backslash: \\
38 |
39 | Backtick: \`
40 |
41 | Asterisk: \*
42 |
43 | Underscore: \_
44 |
45 | Left brace: \{
46 |
47 | Right brace: \}
48 |
49 | Left bracket: \[
50 |
51 | Right bracket: \]
52 |
53 | Left paren: \(
54 |
55 | Right paren: \)
56 |
57 | Greater-than: \>
58 |
59 | Hash: \#
60 |
61 | Period: \.
62 |
63 | Bang: \!
64 |
65 | Plus: \+
66 |
67 | Minus: \-
68 |
69 |
70 | Nor should these, which occur in code spans:
71 |
72 | Backslash: \\
73 |
74 | Backtick: \`
75 |
76 | Asterisk: \*
77 |
78 | Underscore: \_
79 |
80 | Left brace: \{
81 |
82 | Right brace: \}
83 |
84 | Left bracket: \[
85 |
86 | Right bracket: \]
87 |
88 | Left paren: \(
89 |
90 | Right paren: \)
91 |
92 | Greater-than: \>
93 |
94 | Hash: \#
95 |
96 | Period: \.
97 |
98 | Bang: \!
99 |
100 | Plus: \+
101 |
102 | Minus: \-
103 |
104 |
105 | These should get escaped, even though they're matching pairs for
106 | other Markdown constructs:
107 |
108 | *asterisks*
109 |
110 | _underscores_
111 |
112 | `backticks`
113 |
114 | This is a code span with a literal backslash-backtick sequence: \`
115 |
116 | This is a tag with unescaped backticks bar .
117 |
118 | This is a tag with backslashes bar .
119 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/tests/backslash_escapes.html:
--------------------------------------------------------------------------------
1 | These should all get escaped:
2 |
3 | Backslash: \
4 |
5 | Backtick: `
6 |
7 | Asterisk: *
8 |
9 | Underscore: _
10 |
11 | Left brace: {
12 |
13 | Right brace: }
14 |
15 | Left bracket: [
16 |
17 | Right bracket: ]
18 |
19 | Left paren: (
20 |
21 | Right paren: )
22 |
23 | Greater-than: >
24 |
25 | Hash: #
26 |
27 | Period: .
28 |
29 | Bang: !
30 |
31 | Plus: +
32 |
33 | Minus: -
34 |
35 | These should not, because they occur within a code block:
36 |
37 | Backslash: \\
38 |
39 | Backtick: \`
40 |
41 | Asterisk: \*
42 |
43 | Underscore: \_
44 |
45 | Left brace: \{
46 |
47 | Right brace: \}
48 |
49 | Left bracket: \[
50 |
51 | Right bracket: \]
52 |
53 | Left paren: \(
54 |
55 | Right paren: \)
56 |
57 | Greater-than: \>
58 |
59 | Hash: \#
60 |
61 | Period: \.
62 |
63 | Bang: \!
64 |
65 | Plus: \+
66 |
67 | Minus: \-
68 |
69 |
70 | Nor should these, which occur in code spans:
71 |
72 | Backslash: \\
73 |
74 | Backtick: \`
75 |
76 | Asterisk: \*
77 |
78 | Underscore: \_
79 |
80 | Left brace: \{
81 |
82 | Right brace: \}
83 |
84 | Left bracket: \[
85 |
86 | Right bracket: \]
87 |
88 | Left paren: \(
89 |
90 | Right paren: \)
91 |
92 | Greater-than: \>
93 |
94 | Hash: \#
95 |
96 | Period: \.
97 |
98 | Bang: \!
99 |
100 | Plus: \+
101 |
102 | Minus: \-
103 |
104 |
105 | These should get escaped, even though they're matching pairs for
106 | other Markdown constructs:
107 |
108 | *asterisks*
109 |
110 | _underscores_
111 |
112 | `backticks`
113 |
114 | This is a code span with a literal backslash-backtick sequence: \`
115 |
116 | This is a tag with unescaped backticks bar .
117 |
118 | This is a tag with backslashes bar .
119 |
--------------------------------------------------------------------------------
/app/bower_components/marked/man/marked.1:
--------------------------------------------------------------------------------
1 | .ds q \N'34'
2 | .TH marked 1 "2014-01-31" "v0.3.1" "marked.js"
3 |
4 | .SH NAME
5 | marked \- a javascript markdown parser
6 |
7 | .SH SYNOPSIS
8 | .B marked
9 | [\-o \fI\fP] [\-i \fI \fP] [\-\-help]
10 | [\-\-tokens] [\-\-pedantic] [\-\-gfm]
11 | [\-\-breaks] [\-\-tables] [\-\-sanitize]
12 | [\-\-smart\-lists] [\-\-lang\-prefix \fI\fP]
13 | [\-\-no\-etc...] [\-\-silent] [\fIfilename\fP]
14 |
15 | .SH DESCRIPTION
16 | .B marked
17 | is a full-featured javascript markdown parser, built for speed. It also includes
18 | multiple GFM features.
19 |
20 | .SH EXAMPLES
21 | .TP
22 | cat in.md | marked > out.html
23 | .TP
24 | echo "hello *world*" | marked
25 | .TP
26 | marked \-o out.html in.md \-\-gfm
27 | .TP
28 | marked \-\-output="hello world.html" \-i in.md \-\-no-breaks
29 |
30 | .SH OPTIONS
31 | .TP
32 | .BI \-o,\ \-\-output\ [\fIoutput\fP]
33 | Specify file output. If none is specified, write to stdout.
34 | .TP
35 | .BI \-i,\ \-\-input\ [\fIinput\fP]
36 | Specify file input, otherwise use last argument as input file. If no input file
37 | is specified, read from stdin.
38 | .TP
39 | .BI \-t,\ \-\-tokens
40 | Output a token stream instead of html.
41 | .TP
42 | .BI \-\-pedantic
43 | Conform to obscure parts of markdown.pl as much as possible. Don't fix original
44 | markdown bugs.
45 | .TP
46 | .BI \-\-gfm
47 | Enable github flavored markdown.
48 | .TP
49 | .BI \-\-breaks
50 | Enable GFM line breaks. Only works with the gfm option.
51 | .TP
52 | .BI \-\-tables
53 | Enable GFM tables. Only works with the gfm option.
54 | .TP
55 | .BI \-\-sanitize
56 | Sanitize output. Ignore any HTML input.
57 | .TP
58 | .BI \-\-smart\-lists
59 | Use smarter list behavior than the original markdown.
60 | .TP
61 | .BI \-\-lang\-prefix\ [\fIprefix\fP]
62 | Set the prefix for code block classes.
63 | .TP
64 | .BI \-\-no\-sanitize,\ \-no-etc...
65 | The inverse of any of the marked options above.
66 | .TP
67 | .BI \-\-silent
68 | Silence error output.
69 | .TP
70 | .BI \-h,\ \-\-help
71 | Display help information.
72 |
73 | .SH CONFIGURATION
74 | For configuring and running programmatically.
75 |
76 | .B Example
77 |
78 | require('marked')('*foo*', { gfm: true });
79 |
80 | .SH BUGS
81 | Please report any bugs to https://github.com/chjj/marked.
82 |
83 | .SH LICENSE
84 | Copyright (c) 2011-2014, Christopher Jeffrey (MIT License).
85 |
86 | .SH "SEE ALSO"
87 | .BR markdown(1),
88 | .BR node.js(1)
89 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/original/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.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 |
--------------------------------------------------------------------------------
/docs/mixin.md:
--------------------------------------------------------------------------------
1 | # Mixin
2 |
3 | JavaScript 语言的设计是单一继承,即子类只能继承一个父类,不允许继承多个父类。这种设计保证了对象继承的层次结构是树状的,而不是复杂的[网状结构](https://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem)。
4 |
5 | 但是,这大大降低了编程的灵活性。因为实际开发中,有时不可避免,子类需要继承多个父类。举例来说,“猫”可以继承“哺乳类动物”,也可以继承“宠物”。
6 |
7 | 各种单一继承的编程语言,有不同的多重继承解决方案。比如,Java 语言也是子类只能继承一个父类,但是还允许继承多个界面(interface),这样就间接实现了多重继承。Interface 与父类一样,也是一个类,只不过它只定义接口(method signature),不定义实现,因此又被称为“抽象类”。凡是继承于 Interface 的方法,都必须自己定义实现,否则就会报错。这样就避免了多重继承的最大问题:多个父类的同名方法的碰撞(naming collision)。
8 |
9 | JavaScript 语言没有采用 Interface 的方案,而是通过代理(delegation)实现了从其他类引入方法。
10 |
11 | ```javascript
12 | var Enumerable_first = function () {
13 | this.first = function () {
14 | return this[0];
15 | };
16 | };
17 |
18 | var list = ["foo", "bar", "baz"];
19 | Enumerable_first.call(list); // explicit delegation
20 | list.first() // "foo"
21 | ```
22 |
23 | 上面代码中,`list`是一个数组,本身并没有`first`方法。通过`call`方法,可以把`Enumerable_first`里面的方法,绑定到`list`,从而`list`就具有`first`方法。这就叫做“代理”(delegation),`list`对象代理了`Enumerable_first`的`first`方法。
24 |
25 | ## 含义
26 |
27 | Mixin 这个名字来自于冰淇淋,在基本口味的冰淇淋上面混入其他口味,这就叫做 Mix-in。
28 |
29 | 它允许向一个类里面注入一些代码,使得一个类的功能能够“混入”另一个类。实质上是多重继承的一种解决方案,但是避免了多重继承的复杂性,而且有利于代码复用。
30 |
31 | Mixin 就是一个正常的类,不仅定义了接口,还定义了接口的实现。
32 |
33 | 子类通过在`this`对象上面绑定方法,达到多重继承的目的。
34 |
35 | 很多库提供了 Mixin 功能。下面以 Lodash 为例。
36 |
37 | ```javascript
38 | function vowels(string) {
39 | return /[aeiou]/i.test(this.value);
40 | }
41 |
42 | var obj = { value: 'hello' };
43 | _.mixin(obj, {vowels: vowels})
44 | obj.vowels() // true
45 | ```
46 |
47 | 上面代码通过 Lodash 库的`_.mixin`方法,让`obj`对象继承了`vowels`方法。
48 |
49 | Underscore 的类似方法是`_.extend`。
50 |
51 | ```javascript
52 | var Person = function (fName, lName) {
53 | this.firstName = fName;
54 | this.lastName = lName;
55 | }
56 |
57 | var sam = new Person('Sam', 'Lowry');
58 |
59 | var NameMixin = {
60 | fullName: function () {
61 | return this.firstName + ' ' + this.lastName;
62 | },
63 | rename: function(first, last) {
64 | this.firstName = first;
65 | this.lastName = last;
66 | return this;
67 | }
68 | };
69 | _.extend(Person.prototype, NameMixin);
70 | sam.rename('Samwise', 'Gamgee');
71 | sam.fullName() // "Samwise Gamgee"
72 | ```
73 |
74 | 上面代码通过`_.extend`方法,在`sam`对象上面(准确说是它的原型对象`Person.prototype`上面),混入了`NameMixin`类。
75 |
76 | `extend`方法的实现非常简单。
77 |
78 | ```javascript
79 | function extend(destination, source) {
80 | for (var k in source) {
81 | if (source.hasOwnProperty(k)) {
82 | destination[k] = source[k];
83 | }
84 | }
85 | return destination;
86 | }
87 | ```
88 |
89 | 上面代码将`source`对象的所有方法,添加到`destination`对象。
90 |
91 | ## Trait
92 |
93 | Trait 是另外一种多重继承的解决方案。它与 Mixin 很相似,但是有一些细微的差别。
94 |
95 | - Mixin 可以包含状态(state),Trait 不包含,即 Trait 里面的方法都是互不相干,可以线性包含的。比如,`Trait1`包含方法`A`和`B`,`Trait2`继承了`Trait1`,同时还包含一个自己的方法`C`,实际上就等同于直接包含方法`A`、`B`、`C`。
96 | - 对于同名方法的碰撞,Mixin 包含了解决规则,Trait 则是报错。
97 |
--------------------------------------------------------------------------------
/app/bower_components/marked/bin/marked:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | /**
4 | * Marked CLI
5 | * Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
6 | */
7 |
8 | var fs = require('fs')
9 | , util = require('util')
10 | , marked = require('../');
11 |
12 | /**
13 | * Man Page
14 | */
15 |
16 | function help() {
17 | var spawn = require('child_process').spawn;
18 |
19 | var options = {
20 | cwd: process.cwd(),
21 | env: process.env,
22 | setsid: false,
23 | customFds: [0, 1, 2]
24 | };
25 |
26 | spawn('man',
27 | [__dirname + '/../man/marked.1'],
28 | options);
29 | }
30 |
31 | /**
32 | * Main
33 | */
34 |
35 | function main(argv, callback) {
36 | var files = []
37 | , options = {}
38 | , input
39 | , output
40 | , arg
41 | , tokens
42 | , opt;
43 |
44 | function getarg() {
45 | var arg = argv.shift();
46 |
47 | if (arg.indexOf('--') === 0) {
48 | // e.g. --opt
49 | arg = arg.split('=');
50 | if (arg.length > 1) {
51 | // e.g. --opt=val
52 | argv.unshift(arg.slice(1).join('='));
53 | }
54 | arg = arg[0];
55 | } else if (arg[0] === '-') {
56 | if (arg.length > 2) {
57 | // e.g. -abc
58 | argv = arg.substring(1).split('').map(function(ch) {
59 | return '-' + ch;
60 | }).concat(argv);
61 | arg = argv.shift();
62 | } else {
63 | // e.g. -a
64 | }
65 | } else {
66 | // e.g. foo
67 | }
68 |
69 | return arg;
70 | }
71 |
72 | while (argv.length) {
73 | arg = getarg();
74 | switch (arg) {
75 | case '--test':
76 | return require('../test').main(process.argv.slice());
77 | case '-o':
78 | case '--output':
79 | output = argv.shift();
80 | break;
81 | case '-i':
82 | case '--input':
83 | input = argv.shift();
84 | break;
85 | case '-t':
86 | case '--tokens':
87 | tokens = true;
88 | break;
89 | case '-h':
90 | case '--help':
91 | return help();
92 | default:
93 | if (arg.indexOf('--') === 0) {
94 | opt = camelize(arg.replace(/^--(no-)?/, ''));
95 | if (!marked.defaults.hasOwnProperty(opt)) {
96 | continue;
97 | }
98 | if (arg.indexOf('--no-') === 0) {
99 | options[opt] = typeof marked.defaults[opt] !== 'boolean'
100 | ? null
101 | : false;
102 | } else {
103 | options[opt] = typeof marked.defaults[opt] !== 'boolean'
104 | ? argv.shift()
105 | : true;
106 | }
107 | } else {
108 | files.push(arg);
109 | }
110 | break;
111 | }
112 | }
113 |
114 | function getData(callback) {
115 | if (!input) {
116 | if (files.length <= 2) {
117 | return getStdin(callback);
118 | }
119 | input = files.pop();
120 | }
121 | return fs.readFile(input, 'utf8', callback);
122 | }
123 |
124 | return getData(function(err, data) {
125 | if (err) return callback(err);
126 |
127 | data = tokens
128 | ? JSON.stringify(marked.lexer(data, options), null, 2)
129 | : marked(data, options);
130 |
131 | if (!output) {
132 | process.stdout.write(data + '\n');
133 | return callback();
134 | }
135 |
136 | return fs.writeFile(output, data, callback);
137 | });
138 | }
139 |
140 | /**
141 | * Helpers
142 | */
143 |
144 | function getStdin(callback) {
145 | var stdin = process.stdin
146 | , buff = '';
147 |
148 | stdin.setEncoding('utf8');
149 |
150 | stdin.on('data', function(data) {
151 | buff += data;
152 | });
153 |
154 | stdin.on('error', function(err) {
155 | return callback(err);
156 | });
157 |
158 | stdin.on('end', function() {
159 | return callback(null, buff);
160 | });
161 |
162 | try {
163 | stdin.resume();
164 | } catch (e) {
165 | callback(e);
166 | }
167 | }
168 |
169 | function camelize(text) {
170 | return text.replace(/(\w)-(\w)/g, function(_, a, b) {
171 | return a + b.toUpperCase();
172 | });
173 | }
174 |
175 | /**
176 | * Expose / Entry Point
177 | */
178 |
179 | if (!module.parent) {
180 | process.title = 'marked';
181 | main(process.argv.slice(), function(err, code) {
182 | if (err) throw err;
183 | return process.exit(code || 0);
184 | });
185 | } else {
186 | module.exports = main;
187 | }
188 |
--------------------------------------------------------------------------------
/docs/fp.md:
--------------------------------------------------------------------------------
1 | # 函数式编程
2 |
3 | JavaScript 语言从一诞生,就具有函数式编程的烙印。它将函数作为一种独立的数据类型,与其他数据类型处于完全平等的地位。在 JavaScript 语言中,你可以采用面向对象编程,也可以采用函数式编程。有人甚至说,JavaScript 是有史以来第一种被大规模采用的函数式编程语言。
4 |
5 | ES6 的种种新增功能,使得函数式编程变得更方便、更强大。本章介绍 ES6 如何进行函数式编程。
6 |
7 | ## 柯里化
8 |
9 | 柯里化(currying)指的是将一个多参数的函数拆分成一系列函数,每个拆分后的函数都只接受一个参数(unary)。
10 |
11 | ```javascript
12 | function add (a, b) {
13 | return a + b;
14 | }
15 |
16 | add(1, 1) // 2
17 | ```
18 |
19 | 上面代码中,函数`add`接受两个参数`a`和`b`。
20 |
21 | 柯里化就是将上面的函数拆分成两个函数,每个函数都只接受一个参数。
22 |
23 | ```javascript
24 | function add (a) {
25 | return function (b) {
26 | return a + b;
27 | }
28 | }
29 | // 或者采用箭头函数写法
30 | const add = x => y => x + y;
31 |
32 | const f = add(1);
33 | f(1) // 2
34 | ```
35 |
36 | 上面代码中,函数`add`只接受一个参数`a`,返回一个函数`f`。函数`f`也只接受一个参数`b`。
37 |
38 | ## 函数合成
39 |
40 | 函数合成(function composition)指的是,将多个函数合成一个函数。
41 |
42 | ```javascript
43 | const compose = f => g => x => f(g(x));
44 |
45 | const f = compose (x => x * 4) (x => x + 3);
46 | f(2) // 20
47 | ```
48 |
49 | 上面代码中,`compose`就是一个函数合成器,用于将两个函数合成一个函数。
50 |
51 | 可以发现,柯里化与函数合成有着密切的联系。前者用于将一个函数拆成多个函数,后者用于将多个函数合并成一个函数。
52 |
53 | ## 参数倒置
54 |
55 | 参数倒置(flip)指的是改变函数前两个参数的顺序。
56 |
57 | ```javascript
58 | var divide = (a, b) => a / b;
59 | var flip = f.flip(divide);
60 |
61 | flip(10, 5) // 0.5
62 | flip(1, 10) // 10
63 |
64 | var three = (a, b, c) => [a, b, c];
65 | var flip = f.flip(three);
66 | flip(1, 2, 3); // => [2, 1, 3]
67 | ```
68 |
69 | 上面代码中,如果按照正常的参数顺序,10 除以 5 等于 2。但是,参数倒置以后得到的新函数,结果就是 5 除以 10,结果得到 0.5。如果原函数有 3 个参数,则只颠倒前两个参数的位置。
70 |
71 | 参数倒置的代码非常简单。
72 |
73 | ```javascript
74 | let f = {};
75 | f.flip =
76 | fn =>
77 | (a, b, ...args) => fn(b, a, ...args.reverse());
78 | ```
79 |
80 | ## 执行边界
81 |
82 | 执行边界(until)指的是函数执行到满足条件为止。
83 |
84 | ```javascript
85 | let condition = x => x > 100;
86 | let inc = x => x + 1;
87 | let until = f.until(condition, inc);
88 |
89 | until(0) // 101
90 |
91 | condition = x => x === 5;
92 | until = f.until(condition, inc);
93 |
94 | until(3) // 5
95 | ```
96 |
97 | 上面代码中,第一段的条件是执行到`x`大于 100 为止,所以`x`初值为 0 时,会一直执行到 101。第二段的条件是执行到等于 5 为止,所以`x`最后的值是 5。
98 |
99 | 执行边界的实现如下。
100 |
101 | ```javascript
102 | let f = {};
103 | f.until = (condition, f) =>
104 | (...args) => {
105 | var r = f.apply(null, args);
106 | return condition(r) ? r : f.until(condition, f)(r);
107 | };
108 | ```
109 |
110 | 上面代码的关键就是,如果满足条件就返回结果,否则不断递归执行。
111 |
112 | ## 队列操作
113 |
114 | 队列(list)操作包括以下几种。
115 |
116 | - `head`: 取出队列的第一个非空成员。
117 | - `last`: 取出有限队列的最后一个非空成员。
118 | - `tail`: 取出除了“队列头”以外的其他非空成员。
119 | - `init`: 取出除了“队列尾”以外的其他非空成员。
120 |
121 | 下面是例子。
122 |
123 | ```javascript
124 | f.head(5, 27, 3, 1) // 5
125 | f.last(5, 27, 3, 1) // 1
126 | f.tail(5, 27, 3, 1) // [27, 3, 1]
127 | f.init(5, 27, 3, 1) // [5, 27, 3]
128 | ```
129 |
130 | 这些方法的实现如下。
131 |
132 | ```javascript
133 | let f = {};
134 | f.head = (...xs) => xs[0];
135 | f.last = (...xs) => xs.slice(-1);
136 | f.tail = (...xs) => Array.prototype.slice.call(xs, 1);
137 | f.init = (...xs) => xs.slice(0, -1);
138 | ```
139 |
140 | ## 合并操作
141 |
142 | 合并操作分为`concat`和`concatMap`两种。前者就是将多个数组合成一个,后者则是先处理一下参数,然后再将处理结果合成一个数组。
143 |
144 | ```javascript
145 | f.concat([5], [27], [3]) // [5, 27, 3]
146 | f.concatMap(x => 'hi ' + x, 1, [[2]], 3) // ['hi 1', 'hi 2', 'hi 3']
147 | ```
148 |
149 | 这两种方法的实现代码如下。
150 |
151 | ```javascript
152 | let f = {};
153 | f.concat =
154 | (...xs) => xs.reduce((a, b) => a.concat(b));
155 | f.concatMap =
156 | (f, ...xs) => f.concat(xs.map(f));
157 | ```
158 |
159 | ## 配对操作
160 |
161 | 配对操作分为`zip`和`zipWith`两种方法。`zip`操作将两个队列的成员,一一配对,合成一个新的队列。如果两个队列不等长,较长的那个队列多出来的成员,会被忽略。`zipWith`操作的第一个参数是一个函数,然后会将后面的队列成员一一配对,输入该函数,返回值就组成一个新的队列。
162 |
163 | 下面是例子。
164 |
165 | ```javascript
166 | let a = [0, 1, 2];
167 | let b = [3, 4, 5];
168 | let c = [6, 7, 8];
169 |
170 | f.zip(a, b) // [[0, 3], [1, 4], [2, 5]]
171 | f.zipWith((a, b) => a + b, a, b, c) // [9, 12, 15]
172 | ```
173 |
174 | 上面代码中,`zipWith`方法的第一个参数是一个求和函数,它将后面三个队列的成员,一一配对进行相加。
175 |
176 | 这两个方法的实现如下。
177 |
178 | ```javascript
179 | let f = {};
180 |
181 | f.zip = (...xs) => {
182 | let r = [];
183 | let nple = [];
184 | let length = Math.min.apply(null, xs.map(x => x.length));
185 |
186 | for (var i = 0; i < length; i++) {
187 | xs.forEach(
188 | x => nple.push(x[i])
189 | );
190 |
191 | r.push(nple);
192 | nple = [];
193 | }
194 |
195 | return r;
196 | };
197 |
198 | f.zipWith = (op, ...xs) =>
199 | f.zip.apply(null, xs).map(
200 | (x) => x.reduce(op)
201 | );
202 | ```
203 |
204 | ## 参考链接
205 |
206 | - Mateo Gianolio, [Haskell in ES6: Part 1](http://casualjavascript.com/?1)
207 |
--------------------------------------------------------------------------------
/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")())
--------------------------------------------------------------------------------
/app/bower_components/marked/doc/broken.md:
--------------------------------------------------------------------------------
1 | # Markdown is broken
2 |
3 | I have a lot of scraps of markdown engine oddities that I've collected over the
4 | years. What you see below is slightly messy, but it's what I've managed to
5 | cobble together to illustrate the differences between markdown engines, and
6 | why, if there ever is a markdown specification, it has to be absolutely
7 | thorough. There are a lot more of these little differences I have documented
8 | elsewhere. I know I will find them lingering on my disk one day, but until
9 | then, I'll continue to add whatever strange nonsensical things I find.
10 |
11 | Some of these examples may only mention a particular engine compared to marked.
12 | However, the examples with markdown.pl could easily be swapped out for
13 | discount, upskirt, or markdown.js, and you would very easily see even more
14 | inconsistencies.
15 |
16 | A lot of this was written when I was very unsatisfied with the inconsistencies
17 | between markdown engines. Please excuse the frustration noticeable in my
18 | writing.
19 |
20 | ## Examples of markdown's "stupid" list parsing
21 |
22 | ```
23 | $ markdown.pl
24 |
25 | * item1
26 |
27 | * item2
28 |
29 | text
30 | ^D
31 |
32 | item1
33 |
34 |
37 |
38 |
text
39 |
40 | ```
41 |
42 |
43 | ```
44 | $ marked
45 | * item1
46 |
47 | * item2
48 |
49 | text
50 | ^D
51 |
52 | item1
53 |
56 | text
57 |
58 |
59 | ```
60 |
61 | Which looks correct to you?
62 |
63 | - - -
64 |
65 | ```
66 | $ markdown.pl
67 | * hello
68 | > world
69 | ^D
70 |
71 | hello
72 |
73 |
74 | world
75 |
76 |
77 | ```
78 |
79 | ```
80 | $ marked
81 | * hello
82 | > world
83 | ^D
84 |
85 | hello
86 | world
87 |
88 |
89 |
90 | ```
91 |
92 | Again, which looks correct to you?
93 |
94 | - - -
95 |
96 | EXAMPLE:
97 |
98 | ```
99 | $ markdown.pl
100 | * hello
101 | * world
102 | * hi
103 | code
104 | ^D
105 |
106 | hello
107 |
108 | world
109 | hi
110 | code
111 |
112 |
113 | ```
114 |
115 | The code isn't a code block even though it's after the bullet margin. I know,
116 | lets give it two more spaces, effectively making it 8 spaces past the bullet.
117 |
118 | ```
119 | $ markdown.pl
120 | * hello
121 | * world
122 | * hi
123 | code
124 | ^D
125 |
126 | hello
127 |
128 | world
129 | hi
130 | code
131 |
132 |
133 | ```
134 |
135 | And, it's still not a code block. Did you also notice that the 3rd item isn't
136 | even its own list? Markdown screws that up too because of its indentation
137 | unaware parsing.
138 |
139 | - - -
140 |
141 | Let's look at some more examples of markdown's list parsing:
142 |
143 | ```
144 | $ markdown.pl
145 |
146 | * item1
147 |
148 | * item2
149 |
150 | text
151 | ^D
152 |
153 | item1
154 |
155 |
158 |
159 |
text
160 |
161 | ```
162 |
163 | Misnested tags.
164 |
165 |
166 | ```
167 | $ marked
168 | * item1
169 |
170 | * item2
171 |
172 | text
173 | ^D
174 |
175 | item1
176 |
179 | text
180 |
181 |
182 | ```
183 |
184 | Which looks correct to you?
185 |
186 | - - -
187 |
188 | ```
189 | $ markdown.pl
190 | * hello
191 | > world
192 | ^D
193 |
194 | hello
195 |
196 |
197 | world
198 |
199 |
200 | ```
201 |
202 | More misnested tags.
203 |
204 |
205 | ```
206 | $ marked
207 | * hello
208 | > world
209 | ^D
210 |
211 | hello
212 | world
213 |
214 |
215 |
216 | ```
217 |
218 | Again, which looks correct to you?
219 |
220 | - - -
221 |
222 | # Why quality matters - Part 2
223 |
224 | ``` bash
225 | $ markdown.pl
226 | * hello
227 | > world
228 | ^D
229 |
230 | hello
231 |
232 |
233 | world
234 |
235 |
236 | ```
237 |
238 | ``` bash
239 | $ sundown # upskirt
240 | * hello
241 | > world
242 | ^D
243 |
244 | hello
245 | > world
246 |
247 | ```
248 |
249 | ``` bash
250 | $ marked
251 | * hello
252 | > world
253 | ^D
254 |
255 | ```
256 |
257 | Which looks correct to you?
258 |
259 | - - -
260 |
261 | See: https://github.com/evilstreak/markdown-js/issues/23
262 |
263 | ``` bash
264 | $ markdown.pl # upskirt/markdown.js/discount
265 | * hello
266 | var a = 1;
267 | * world
268 | ^D
269 |
270 | hello
271 | var a = 1;
272 | world
273 |
274 | ```
275 |
276 | ``` bash
277 | $ marked
278 | * hello
279 | var a = 1;
280 | * world
281 | ^D
282 | hello
283 | code>var a = 1;
284 | world
285 | ```
286 |
287 | Which looks more reasonable? Why shouldn't code blocks be able to appear in
288 | list items in a sane way?
289 |
290 | - - -
291 |
292 | ``` bash
293 | $ markdown.js
294 | hello
295 |
296 | hello
297 | ^D
298 | <div>hello</div>
299 |
300 | <span>hello</span>
301 | ```
302 |
303 | ``` bash
304 | $ marked
305 | hello
306 |
307 | hello
308 | ^D
309 | hello
310 |
311 |
312 | hello
313 |
314 | ```
315 |
316 | - - -
317 |
318 | See: https://github.com/evilstreak/markdown-js/issues/27
319 |
320 | ``` bash
321 | $ markdown.js
322 | [](/link)
323 | ^D
324 | ](/link)
330 | ^D
331 |
332 |
333 | ```
334 |
335 | - - -
336 |
337 | See: https://github.com/evilstreak/markdown-js/issues/24
338 |
339 | ``` bash
340 | $ markdown.js
341 | > a
342 |
343 | > b
344 |
345 | > c
346 | ^D
347 | a
bundefined> c
348 | ```
349 |
350 | ``` bash
351 | $ marked
352 | > a
353 |
354 | > b
355 |
356 | > c
357 | ^D
358 | a
359 |
360 |
361 | b
362 |
363 |
364 | c
365 |
366 | ```
367 |
368 | - - -
369 |
370 | ``` bash
371 | $ markdown.pl
372 | * hello
373 | * world
374 | how
375 |
376 | are
377 | you
378 |
379 | * today
380 | * hi
381 | ^D
382 |
383 | hello
384 |
385 |
386 | world
387 | how
388 |
389 |
390 | are
391 | you
392 |
393 |
396 | hi
397 |
398 | ```
399 |
400 | ``` bash
401 | $ marked
402 | * hello
403 | * world
404 | how
405 |
406 | are
407 | you
408 |
409 | * today
410 | * hi
411 | ^D
412 |
413 | hello
414 |
415 | world
416 | how
417 | are
418 | you
419 |
420 | today
421 |
422 |
423 |
424 | hi
425 |
426 | ```
427 |
--------------------------------------------------------------------------------
/docs/operator.md:
--------------------------------------------------------------------------------
1 | # 运算符的扩展
2 |
3 | 本章介绍 ES6 后续标准添加的一些运算符。
4 |
5 | ## 指数运算符
6 |
7 | ES2016 新增了一个指数运算符(`**`)。
8 |
9 | ```javascript
10 | 2 ** 2 // 4
11 | 2 ** 3 // 8
12 | ```
13 |
14 | 这个运算符的一个特点是右结合,而不是常见的左结合。多个指数运算符连用时,是从最右边开始计算的。
15 |
16 | ```javascript
17 | // 相当于 2 ** (3 ** 2)
18 | 2 ** 3 ** 2
19 | // 512
20 | ```
21 |
22 | 上面代码中,首先计算的是第二个指数运算符,而不是第一个。
23 |
24 | 指数运算符可以与等号结合,形成一个新的赋值运算符(`**=`)。
25 |
26 | ```javascript
27 | let a = 1.5;
28 | a **= 2;
29 | // 等同于 a = a * a;
30 |
31 | let b = 4;
32 | b **= 3;
33 | // 等同于 b = b * b * b;
34 | ```
35 |
36 | ## 链判断运算符
37 |
38 | 编程实务中,如果读取对象内部的某个属性,往往需要判断一下,属性的上层对象是否存在。比如,读取`message.body.user.firstName`这个属性,安全的写法是写成下面这样。
39 |
40 | ```javascript
41 | // 错误的写法
42 | const firstName = message.body.user.firstName || 'default';
43 |
44 | // 正确的写法
45 | const firstName = (message
46 | && message.body
47 | && message.body.user
48 | && message.body.user.firstName) || 'default';
49 | ```
50 |
51 | 上面例子中,`firstName`属性在对象的第四层,所以需要判断四次,每一层是否有值。
52 |
53 | 三元运算符`?:`也常用于判断对象是否存在。
54 |
55 | ```javascript
56 | const fooInput = myForm.querySelector('input[name=foo]')
57 | const fooValue = fooInput ? fooInput.value : undefined
58 | ```
59 |
60 | 上面例子中,必须先判断`fooInput`是否存在,才能读取`fooInput.value`。
61 |
62 | 这样的层层判断非常麻烦,因此 [ES2020](https://github.com/tc39/proposal-optional-chaining) 引入了“链判断运算符”(optional chaining operator)`?.`,简化上面的写法。
63 |
64 | ```javascript
65 | const firstName = message?.body?.user?.firstName || 'default';
66 | const fooValue = myForm.querySelector('input[name=foo]')?.value
67 | ```
68 |
69 | 上面代码使用了`?.`运算符,直接在链式调用的时候判断,左侧的对象是否为`null`或`undefined`。如果是的,就不再往下运算,而是返回`undefined`。
70 |
71 | 下面是判断对象方法是否存在,如果存在就立即执行的例子。
72 |
73 | ```javascript
74 | iterator.return?.()
75 | ```
76 |
77 | 上面代码中,`iterator.return`如果有定义,就会调用该方法,否则`iterator.return`直接返回`undefined`,不再执行`?.`后面的部分。
78 |
79 | 对于那些可能没有实现的方法,这个运算符尤其有用。
80 |
81 | ```javascript
82 | if (myForm.checkValidity?.() === false) {
83 | // 表单校验失败
84 | return;
85 | }
86 | ```
87 |
88 | 上面代码中,老式浏览器的表单对象可能没有`checkValidity()`这个方法,这时`?.`运算符就会返回`undefined`,判断语句就变成了`undefined === false`,所以就会跳过下面的代码。
89 |
90 | 链判断运算符`?.`有三种写法。
91 |
92 | - `obj?.prop` // 对象属性是否存在
93 | - `obj?.[expr]` // 同上
94 | - `func?.(...args)` // 函数或对象方法是否存在
95 |
96 | 下面是`obj?.[expr]`用法的一个例子。
97 |
98 | ```bash
99 | let hex = "#C0FFEE".match(/#([A-Z]+)/i)?.[1];
100 | ```
101 |
102 | 上面例子中,字符串的`match()`方法,如果没有发现匹配会返回`null`,如果发现匹配会返回一个数组,`?.`运算符起到了判断作用。
103 |
104 | 下面是`?.`运算符常见形式,以及不使用该运算符时的等价形式。
105 |
106 | ```javascript
107 | a?.b
108 | // 等同于
109 | a == null ? undefined : a.b
110 |
111 | a?.[x]
112 | // 等同于
113 | a == null ? undefined : a[x]
114 |
115 | a?.b()
116 | // 等同于
117 | a == null ? undefined : a.b()
118 |
119 | a?.()
120 | // 等同于
121 | a == null ? undefined : a()
122 | ```
123 |
124 | 上面代码中,特别注意后两种形式,如果`a?.b()`和`a?.()`。如果`a?.b()`里面的`a.b`有值,但不是函数,不可调用,那么`a?.b()`是会报错的。`a?.()`也是如此,如果`a`不是`null`或`undefined`,但也不是函数,那么`a?.()`会报错。
125 |
126 | 使用这个运算符,有几个注意点。
127 |
128 | (1)短路机制
129 |
130 | 本质上,`?.`运算符相当于一种短路机制,只要不满足条件,就不再往下执行。
131 |
132 | ```javascript
133 | a?.[++x]
134 | // 等同于
135 | a == null ? undefined : a[++x]
136 | ```
137 |
138 | 上面代码中,如果`a`是`undefined`或`null`,那么`x`不会进行递增运算。也就是说,链判断运算符一旦为真,右侧的表达式就不再求值。
139 |
140 | (2)括号的影响
141 |
142 | 如果属性链有圆括号,链判断运算符对圆括号外部没有影响,只对圆括号内部有影响。
143 |
144 | ```javascript
145 | (a?.b).c
146 | // 等价于
147 | (a == null ? undefined : a.b).c
148 | ```
149 |
150 | 上面代码中,`?.`对圆括号外部没有影响,不管`a`对象是否存在,圆括号后面的`.c`总是会执行。
151 |
152 | 一般来说,使用`?.`运算符的场合,不应该使用圆括号。
153 |
154 | (3)报错场合
155 |
156 | 以下写法是禁止的,会报错。
157 |
158 | ```javascript
159 | // 构造函数
160 | new a?.()
161 | new a?.b()
162 |
163 | // 链判断运算符的右侧有模板字符串
164 | a?.`{b}`
165 | a?.b`{c}`
166 |
167 | // 链判断运算符的左侧是 super
168 | super?.()
169 | super?.foo
170 |
171 | // 链运算符用于赋值运算符左侧
172 | a?.b = c
173 | ```
174 |
175 | (4)右侧不得为十进制数值
176 |
177 | 为了保证兼容以前的代码,允许`foo?.3:0`被解析成`foo ? .3 : 0`,因此规定如果`?.`后面紧跟一个十进制数字,那么`?.`不再被看成是一个完整的运算符,而会按照三元运算符进行处理,也就是说,那个小数点会归属于后面的十进制数字,形成一个小数。
178 |
179 | ## Null 判断运算符
180 |
181 | 读取对象属性的时候,如果某个属性的值是`null`或`undefined`,有时候需要为它们指定默认值。常见做法是通过`||`运算符指定默认值。
182 |
183 | ```javascript
184 | const headerText = response.settings.headerText || 'Hello, world!';
185 | const animationDuration = response.settings.animationDuration || 300;
186 | const showSplashScreen = response.settings.showSplashScreen || true;
187 | ```
188 |
189 | 上面的三行代码都通过`||`运算符指定默认值,但是这样写是错的。开发者的原意是,只要属性的值为`null`或`undefined`,默认值就会生效,但是属性的值如果为空字符串或`false`或`0`,默认值也会生效。
190 |
191 | 为了避免这种情况,[ES2020](https://github.com/tc39/proposal-nullish-coalescing) 引入了一个新的 Null 判断运算符`??`。它的行为类似`||`,但是只有运算符左侧的值为`null`或`undefined`时,才会返回右侧的值。
192 |
193 | ```javascript
194 | const headerText = response.settings.headerText ?? 'Hello, world!';
195 | const animationDuration = response.settings.animationDuration ?? 300;
196 | const showSplashScreen = response.settings.showSplashScreen ?? true;
197 | ```
198 |
199 | 上面代码中,默认值只有在左侧属性值为`null`或`undefined`时,才会生效。
200 |
201 | 这个运算符的一个目的,就是跟链判断运算符`?.`配合使用,为`null`或`undefined`的值设置默认值。
202 |
203 | ```javascript
204 | const animationDuration = response.settings?.animationDuration ?? 300;
205 | ```
206 |
207 | 上面代码中,如果`response.settings`是`null`或`undefined`,或者`response.settings.animationDuration`是`null`或`undefined`,就会返回默认值300。也就是说,这一行代码包括了两级属性的判断。
208 |
209 | 这个运算符很适合判断函数参数是否赋值。
210 |
211 | ```javascript
212 | function Component(props) {
213 | const enable = props.enabled ?? true;
214 | // …
215 | }
216 | ```
217 |
218 | 上面代码判断`props`参数的`enabled`属性是否赋值,基本等同于下面的写法。
219 |
220 | ```javascript
221 | function Component(props) {
222 | const {
223 | enabled: enable = true,
224 | } = props;
225 | // …
226 | }
227 | ```
228 |
229 | `??`本质上是逻辑运算,它与其他两个逻辑运算符`&&`和`||`有一个优先级问题,它们之间的优先级到底孰高孰低。优先级的不同,往往会导致逻辑运算的结果不同。
230 |
231 | 现在的规则是,如果多个逻辑运算符一起使用,必须用括号表明优先级,否则会报错。
232 |
233 | ```javascript
234 | // 报错
235 | lhs && middle ?? rhs
236 | lhs ?? middle && rhs
237 | lhs || middle ?? rhs
238 | lhs ?? middle || rhs
239 | ```
240 |
241 | 上面四个表达式都会报错,必须加入表明优先级的括号。
242 |
243 | ```javascript
244 | (lhs && middle) ?? rhs;
245 | lhs && (middle ?? rhs);
246 |
247 | (lhs ?? middle) && rhs;
248 | lhs ?? (middle && rhs);
249 |
250 | (lhs || middle) ?? rhs;
251 | lhs || (middle ?? rhs);
252 |
253 | (lhs ?? middle) || rhs;
254 | lhs ?? (middle || rhs);
255 | ```
256 |
257 | ## 逻辑赋值运算符
258 |
259 | ES2021 引入了三个新的[逻辑赋值运算符](https://github.com/tc39/proposal-logical-assignment)(logical assignment operators),将逻辑运算符与赋值运算符进行结合。
260 |
261 | ```javascript
262 | // 或赋值运算符
263 | x ||= y
264 | // 等同于
265 | x || (x = y)
266 |
267 | // 与赋值运算符
268 | x &&= y
269 | // 等同于
270 | x && (x = y)
271 |
272 | // Null 赋值运算符
273 | x ??= y
274 | // 等同于
275 | x ?? (x = y)
276 | ```
277 |
278 | 这三个运算符`||=`、`&&=`、`??=`相当于先进行逻辑运算,然后根据运算结果,再视情况进行赋值运算。
279 |
280 | 它们的一个用途是,为变量或属性设置默认值。
281 |
282 | ```javascript
283 | // 老的写法
284 | user.id = user.id || 1;
285 |
286 | // 新的写法
287 | user.id ||= 1;
288 | ```
289 |
290 | 上面示例中,`user.id`属性如果不存在,则设为`1`,新的写法比老的写法更紧凑一些。
291 |
292 | 下面是另一个例子。
293 |
294 | ```javascript
295 | function example(opts) {
296 | opts.foo = opts.foo ?? 'bar';
297 | opts.baz ?? (opts.baz = 'qux');
298 | }
299 | ```
300 |
301 | 上面示例中,参数对象`opts`如果不存在属性`foo`和属性`baz`,则为这两个属性设置默认值。有了“Null 赋值运算符”以后,就可以统一写成下面这样。
302 |
303 | ```javascript
304 | function example(opts) {
305 | opts.foo ??= 'bar';
306 | opts.baz ??= 'qux';
307 | }
308 | ```
309 |
310 | ## `#!`命令
311 |
312 | Unix 的命令行脚本都支持`#!`命令,又称为 Shebang 或 Hashbang。这个命令放在脚本的第一行,用来指定脚本的执行器。
313 |
314 | 比如 Bash 脚本的第一行。
315 |
316 | ```bash
317 | #!/bin/sh
318 | ```
319 |
320 | Python 脚本的第一行。
321 |
322 | ```python
323 | #!/usr/bin/env python
324 | ```
325 |
326 | [ES2023](https://github.com/tc39/proposal-hashbang) 为 JavaScript 脚本引入了`#!`命令,写在脚本文件或者模块文件的第一行。
327 |
328 | ```javascript
329 | // 写在脚本文件第一行
330 | #!/usr/bin/env node
331 | 'use strict';
332 | console.log(1);
333 |
334 | // 写在模块文件第一行
335 | #!/usr/bin/env node
336 | export {};
337 | console.log(1);
338 | ```
339 |
340 | 有了这一行以后,Unix 命令行就可以直接执行脚本。
341 |
342 | ```bash
343 | # 以前执行脚本的方式
344 | $ node hello.js
345 |
346 | # hashbang 的方式
347 | $ ./hello.js
348 | ```
349 |
350 | 对于 JavaScript 引擎来说,会把`#!`理解成注释,忽略掉这一行。
351 |
352 |
--------------------------------------------------------------------------------
/docs/intro.md:
--------------------------------------------------------------------------------
1 | # ECMAScript 6 简介
2 |
3 | ECMAScript 6.0(以下简称 ES6)是 JavaScript 语言的下一代标准,已经在 2015 年 6 月正式发布了。它的目标,是使得 JavaScript 语言可以用来编写复杂的大型应用程序,成为企业级开发语言。
4 |
5 | ## ECMAScript 和 JavaScript 的关系
6 |
7 | 一个常见的问题是,ECMAScript 和 JavaScript 到底是什么关系?
8 |
9 | 要讲清楚这个问题,需要回顾历史。1996 年 11 月,JavaScript 的创造者 Netscape 公司,决定将 JavaScript 提交给标准化组织 ECMA,希望这种语言能够成为国际标准。次年,ECMA 发布 262 号标准文件(ECMA-262)的第一版,规定了浏览器脚本语言的标准,并将这种语言称为 ECMAScript,这个版本就是 1.0 版。
10 |
11 | 该标准从一开始就是针对 JavaScript 语言制定的,但是之所以不叫 JavaScript,有两个原因。一是商标,Java 是 Sun 公司的商标,根据授权协议,只有 Netscape 公司可以合法地使用 JavaScript 这个名字,且 JavaScript 本身也已经被 Netscape 公司注册为商标。二是想体现这门语言的制定者是 ECMA,不是 Netscape,这样有利于保证这门语言的开放性和中立性。
12 |
13 | 因此,ECMAScript 和 JavaScript 的关系是,前者是后者的规格,后者是前者的一种实现(另外的 ECMAScript 方言还有 JScript 和 ActionScript)。日常场合,这两个词是可以互换的。
14 |
15 | ## ES6 与 ECMAScript 2015 的关系
16 |
17 | ECMAScript 2015(简称 ES2015)这个词,也是经常可以看到的。它与 ES6 是什么关系呢?
18 |
19 | 2011 年,ECMAScript 5.1 版发布后,就开始制定 6.0 版了。因此,ES6 这个词的原意,就是指 JavaScript 语言的下一个版本。
20 |
21 | 但是,因为这个版本引入的语法功能太多,而且制定过程当中,还有很多组织和个人不断提交新功能。事情很快就变得清楚了,不可能在一个版本里面包括所有将要引入的功能。常规的做法是先发布 6.0 版,过一段时间再发 6.1 版,然后是 6.2 版、6.3 版等等。
22 |
23 | 但是,标准的制定者不想这样做。他们想让标准的升级成为常规流程:任何人在任何时候,都可以向标准委员会提交新语法的提案,然后标准委员会每个月开一次会,评估这些提案是否可以接受,需要哪些改进。如果经过多次会议以后,一个提案足够成熟了,就可以正式进入标准了。这就是说,标准的版本升级成为了一个不断滚动的流程,每个月都会有变动。
24 |
25 | 标准委员会最终决定,标准在每年的 6 月份正式发布一次,作为当年的正式版本。接下来的时间,就在这个版本的基础上做改动,直到下一年的 6 月份,草案就自然变成了新一年的版本。这样一来,就不需要以前的版本号了,只要用年份标记就可以了。
26 |
27 | ES6 的第一个版本,就这样在 2015 年 6 月发布了,正式名称就是《ECMAScript 2015 标准》(简称 ES2015)。2016 年 6 月,小幅修订的《ECMAScript 2016 标准》(简称 ES2016)如期发布,这个版本可以看作是 ES6.1 版,因为两者的差异非常小(只新增了数组实例的`includes`方法和指数运算符),基本上是同一个标准。根据计划,2017 年 6 月发布 ES2017 标准。
28 |
29 | 因此,ES6 既是一个历史名词,也是一个泛指,含义是 5.1 版以后的 JavaScript 的下一代标准,涵盖了 ES2015、ES2016、ES2017 等等,而 ES2015 则是正式名称,特指该年发布的正式版本的语言标准。本书中提到 ES6 的地方,一般是指 ES2015 标准,但有时也是泛指“下一代 JavaScript 语言”。
30 |
31 | ## 语法提案的批准流程
32 |
33 | 任何人都可以向标准委员会(又称 TC39 委员会)提案,要求修改语言标准。
34 |
35 | 一种新的语法从提案到变成正式标准,需要经历五个阶段。每个阶段的变动都需要由 TC39 委员会批准。
36 |
37 | - Stage 0 - Strawman(展示阶段)
38 | - Stage 1 - Proposal(征求意见阶段)
39 | - Stage 2 - Draft(草案阶段)
40 | - Stage 3 - Candidate(候选人阶段)
41 | - Stage 4 - Finished(定案阶段)
42 |
43 | 一个提案只要能进入 Stage 2,就差不多肯定会包括在以后的正式标准里面。ECMAScript 当前的所有提案,可以在 TC39 的官方网站[GitHub.com/tc39/ecma262](https://github.com/tc39/ecma262)查看。
44 |
45 | 本书的写作目标之一,是跟踪 ECMAScript 语言的最新进展,介绍 5.1 版本以后所有的新语法。对于那些明确或很有希望,将要列入标准的新语法,都将予以介绍。
46 |
47 | ## ECMAScript 的历史
48 |
49 | ES6 从开始制定到最后发布,整整用了 15 年。
50 |
51 | 前面提到,ECMAScript 1.0 是 1997 年发布的,接下来的两年,连续发布了 ECMAScript 2.0(1998 年 6 月)和 ECMAScript 3.0(1999 年 12 月)。3.0 版是一个巨大的成功,在业界得到广泛支持,成为通行标准,奠定了 JavaScript 语言的基本语法,以后的版本完全继承。直到今天,初学者一开始学习 JavaScript,其实就是在学 3.0 版的语法。
52 |
53 | 2000 年,ECMAScript 4.0 开始酝酿。这个版本最后没有通过,但是它的大部分内容被 ES6 继承了。因此,ES6 制定的起点其实是 2000 年。
54 |
55 | 为什么 ES4 没有通过呢?因为这个版本太激进了,对 ES3 做了彻底升级,导致标准委员会的一些成员不愿意接受。ECMA 的第 39 号技术专家委员会(Technical Committee 39,简称 TC39)负责制订 ECMAScript 标准,成员包括 Microsoft、Mozilla、Google 等大公司。
56 |
57 | 2007 年 10 月,ECMAScript 4.0 版草案发布,本来预计次年 8 月发布正式版本。但是,各方对于是否通过这个标准,发生了严重分歧。以 Yahoo、Microsoft、Google 为首的大公司,反对 JavaScript 的大幅升级,主张小幅改动;以 JavaScript 创造者 Brendan Eich 为首的 Mozilla 公司,则坚持当前的草案。
58 |
59 | 2008 年 7 月,由于对于下一个版本应该包括哪些功能,各方分歧太大,争论过于激烈,ECMA 开会决定,中止 ECMAScript 4.0 的开发,将其中涉及现有功能改善的一小部分,发布为 ECMAScript 3.1,而将其他激进的设想扩大范围,放入以后的版本,由于会议的气氛,该版本的项目代号起名为 Harmony(和谐)。会后不久,ECMAScript 3.1 就改名为 ECMAScript 5。
60 |
61 | 2009 年 12 月,ECMAScript 5.0 版正式发布。Harmony 项目则一分为二,一些较为可行的设想定名为 JavaScript.next 继续开发,后来演变成 ECMAScript 6;一些不是很成熟的设想,则被视为 JavaScript.next.next,在更远的将来再考虑推出。TC39 委员会的总体考虑是,ES5 与 ES3 基本保持兼容,较大的语法修正和新功能加入,将由 JavaScript.next 完成。当时,JavaScript.next 指的是 ES6,第六版发布以后,就指 ES7。TC39 的判断是,ES5 会在 2013 年的年中成为 JavaScript 开发的主流标准,并在此后五年中一直保持这个位置。
62 |
63 | 2011 年 6 月,ECMAScript 5.1 版发布,并且成为 ISO 国际标准(ISO/IEC 16262:2011)。
64 |
65 | 2013 年 3 月,ECMAScript 6 草案冻结,不再添加新功能。新的功能设想将被放到 ECMAScript 7。
66 |
67 | 2013 年 12 月,ECMAScript 6 草案发布。然后是 12 个月的讨论期,听取各方反馈。
68 |
69 | 2015 年 6 月,ECMAScript 6 正式通过,成为国际标准。从 2000 年算起,这时已经过去了 15 年。
70 |
71 | 目前,各大浏览器对 ES6 的支持可以查看[https://compat-table.github.io/compat-table/es6/](https://compat-table.github.io/compat-table/es6/)。
72 |
73 | Node.js 是 JavaScript 的服务器运行环境(runtime)。它对 ES6 的支持度更高。除了那些默认打开的功能,还有一些语法功能已经实现了,但是默认没有打开。使用下面的命令,可以查看 Node.js 默认没有打开的实验性语法。
74 |
75 | ```bash
76 | // Linux & Mac
77 | $ node --v8-options | grep harmony
78 |
79 | // Windows
80 | $ node --v8-options | findstr harmony
81 | ```
82 |
83 | ## Babel 转码器
84 |
85 | [Babel](https://babeljs.io/) 是一个广泛使用的 ES6 转码器,可以将 ES6 代码转为 ES5 代码,从而在老版本的浏览器执行。这意味着,你可以用 ES6 的方式编写程序,又不用担心现有环境是否支持。下面是一个例子。
86 |
87 | ```javascript
88 | // 转码前
89 | input.map(item => item + 1);
90 |
91 | // 转码后
92 | input.map(function (item) {
93 | return item + 1;
94 | });
95 | ```
96 |
97 | 上面的原始代码用了箭头函数,Babel 将其转为普通函数,就能在不支持箭头函数的 JavaScript 环境执行了。
98 |
99 | 下面的命令在项目目录中,安装 Babel。
100 |
101 | ```bash
102 | $ npm install --save-dev @babel/core
103 | ```
104 |
105 | ### 配置文件`.babelrc`
106 |
107 | Babel 的配置文件是`.babelrc`,存放在项目的根目录下。使用 Babel 的第一步,就是配置这个文件。
108 |
109 | 该文件用来设置转码规则和插件,基本格式如下。
110 |
111 | ```javascript
112 | {
113 | "presets": [],
114 | "plugins": []
115 | }
116 | ```
117 |
118 | `presets`字段设定转码规则,官方提供以下的规则集,你可以根据需要安装。
119 |
120 | ```bash
121 | # 最新转码规则
122 | $ npm install --save-dev @babel/preset-env
123 |
124 | # react 转码规则
125 | $ npm install --save-dev @babel/preset-react
126 | ```
127 |
128 | 然后,将这些规则加入`.babelrc`。
129 |
130 | ```javascript
131 | {
132 | "presets": [
133 | "@babel/env",
134 | "@babel/preset-react"
135 | ],
136 | "plugins": []
137 | }
138 | ```
139 |
140 | 注意,以下所有 Babel 工具和模块的使用,都必须先写好`.babelrc`。
141 |
142 | ### 命令行转码
143 |
144 | Babel 提供命令行工具`@babel/cli`,用于命令行转码。
145 |
146 | 它的安装命令如下。
147 |
148 | ```bash
149 | $ npm install --save-dev @babel/cli
150 | ```
151 |
152 | 基本用法如下。
153 |
154 | ```bash
155 | # 转码结果输出到标准输出
156 | $ npx babel example.js
157 |
158 | # 转码结果写入一个文件
159 | # --out-file 或 -o 参数指定输出文件
160 | $ npx babel example.js --out-file compiled.js
161 | # 或者
162 | $ npx babel example.js -o compiled.js
163 |
164 | # 整个目录转码
165 | # --out-dir 或 -d 参数指定输出目录
166 | $ npx babel src --out-dir lib
167 | # 或者
168 | $ npx babel src -d lib
169 |
170 | # -s 参数生成source map文件
171 | $ npx babel src -d lib -s
172 | ```
173 |
174 | ### babel-node
175 |
176 | `@babel/node`模块的`babel-node`命令,提供一个支持 ES6 的 REPL 环境。它支持 Node 的 REPL 环境的所有功能,而且可以直接运行 ES6 代码。
177 |
178 | 首先,安装这个模块。
179 |
180 | ```bash
181 | $ npm install --save-dev @babel/node
182 | ```
183 |
184 | 然后,执行`babel-node`就进入 REPL 环境。
185 |
186 | ```bash
187 | $ npx babel-node
188 | > (x => x * 2)(1)
189 | 2
190 | ```
191 |
192 | `babel-node`命令可以直接运行 ES6 脚本。将上面的代码放入脚本文件`es6.js`,然后直接运行。
193 |
194 | ```bash
195 | # es6.js 的代码
196 | # console.log((x => x * 2)(1));
197 | $ npx babel-node es6.js
198 | 2
199 | ```
200 |
201 | ### @babel/register 模块
202 |
203 | `@babel/register`模块改写`require`命令,为它加上一个钩子。此后,每当使用`require`加载`.js`、`.jsx`、`.es`和`.es6`后缀名的文件,就会先用 Babel 进行转码。
204 |
205 | ```bash
206 | $ npm install --save-dev @babel/register
207 | ```
208 |
209 | 使用时,必须首先加载`@babel/register`。
210 |
211 | ```bash
212 | // index.js
213 | require('@babel/register');
214 | require('./es6.js');
215 | ```
216 |
217 | 然后,就不需要手动对`index.js`转码了。
218 |
219 | ```bash
220 | $ node index.js
221 | 2
222 | ```
223 |
224 | 需要注意的是,`@babel/register`只会对`require`命令加载的文件转码,而不会对当前文件转码。另外,由于它是实时转码,所以只适合在开发环境使用。
225 |
226 | ### polyfill
227 |
228 | Babel 默认只转换新的 JavaScript 句法(syntax),而不转换新的 API,比如`Iterator`、`Generator`、`Set`、`Map`、`Proxy`、`Reflect`、`Symbol`、`Promise`等全局对象,以及一些定义在全局对象上的方法(比如`Object.assign`)都不会转码。
229 |
230 | 举例来说,ES6 在`Array`对象上新增了`Array.from`方法。Babel 就不会转码这个方法。如果想让这个方法运行,可以使用`core-js`和`regenerator-runtime`(后者提供generator函数的转码),为当前环境提供一个垫片。
231 |
232 | 安装命令如下。
233 |
234 | ```bash
235 | $ npm install --save-dev core-js regenerator-runtime
236 | ```
237 |
238 | 然后,在脚本头部,加入如下两行代码。
239 |
240 | ```javascript
241 | import 'core-js';
242 | import 'regenerator-runtime/runtime';
243 | // 或者
244 | require('core-js');
245 | require('regenerator-runtime/runtime');
246 | ```
247 |
248 | Babel 默认不转码的 API 非常多,详细清单可以查看`babel-plugin-transform-runtime`模块的[definitions.js](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-runtime/src/runtime-corejs3-definitions.js)文件。
249 |
250 | ### 浏览器环境
251 |
252 | Babel 也可以用于浏览器环境,使用[@babel/standalone](https://babeljs.io/docs/en/next/babel-standalone.html)模块提供的浏览器版本,将其插入网页。
253 |
254 | ```html
255 |
256 |
259 | ```
260 |
261 | 注意,网页实时将 ES6 代码转为 ES5,对性能会有影响。生产环境需要加载已经转码完成的脚本。
262 |
263 | Babel 提供一个[REPL 在线编译器](https://babeljs.io/repl/),可以在线将 ES6 代码转为 ES5 代码。转换后的代码,可以直接作为 ES5 代码插入网页运行。
264 |
265 |
--------------------------------------------------------------------------------
/docs/temporal.md:
--------------------------------------------------------------------------------
1 | # Temporal API
2 |
3 | Temporal 是一个表示日期时间的全新 API,对目前的 Date API 的诸多问题进行修正。
4 |
5 | 它有几个核心概念。
6 |
7 | - 当前时间:表示此时此刻的时间,位于 Temporal.now 对象。
8 | - 时点(instant),表示历史上某个唯一时间,其中 Temporal.Instant 对象表示时间戳,Temporal.ZonedDateTime 表示带有时区的日期时间。
9 | - 时钟时间(wall-clock times),表示本地时间,包含以下几个对象,不涉及时区。
10 | - Temporal.PlainDateTime:完整的日期和时间。
11 | - Temporal.PlainDate:仅限于日期。
12 | - Temporal.PlainYearMonth:仅限于年月。
13 | - Temporal.PlainMonthDay:仅限于月和日。
14 | - Temporal.PlainTime:不包含日期的时间。
15 | - 持续时间(durations),表示两个时间点之间的差异,位于 Temporal.Duration 对象。
16 |
17 | ## Temporal.Now
18 |
19 | `Temporal.Now`表示当前系统的准确时间。
20 |
21 | - Temporal.Now.instant()- 获取当前系统准确时间
22 | - Temporal.Now.timeZoneId()- 获取当前系统时区
23 | - Temporal.Now.zonedDateTimeISO()- 获取系统时区和 ISO-8601 日历中的当前日期和挂钟时间
24 | - Temporal.Now.plainDateISO()- 获取系统时区和 ISO-8601 日历中的当前日期
25 | - Temporal.Now.plainTimeISO()- 获取系统时区和 ISO-8601 日历中的当前挂钟时间
26 | - Temporal.Now.plainDateTimeISO()- 与上面相同,但返回 ISO-8601 日历中的日期时间
27 |
28 | ```javascript
29 | // 返回 UTC 的当前时间
30 | Temporal.Now.instant().toString()
31 |
32 | // 系统时区的当前时间
33 | Temporal.Now.plainDateTimeISO() // 2025-01-22T11:46:36.144
34 |
35 | // 当前时间对应 America/New_York 时区的时间
36 | Temporal.Now.plainDateTimeISO("America/New_York") // 2025-01-22T05:47:02.555
37 |
38 | // 返回某个时区的当前日期时间
39 | Temporal.Now.zonedDateTimeISO('Asia/Shanghai').toString()
40 |
41 | // 返回 ISO 格式当前日期时间
42 | Temporal.Now.plainDateTimeISO().toString()
43 |
44 | // 返回 ISO 格式的当前时间,不含日期
45 | Temporal.Now.plainTimeISO().toString()
46 | ```
47 |
48 | 下面的例子是获取指定时区的当前时间。
49 |
50 | ```javascript
51 | const now = Temporal.Now.zonedDateTimeISO('America/New_York');
52 | console.log(now.toString());
53 | ```
54 |
55 | 下面的例子是获取当前时间对应的农历年。
56 |
57 | ```javascript
58 | const currentYear = Temporal.Now.plainDateISO().withCalendar("chinese").year;
59 | ```
60 |
61 | ## Temporal.Instant
62 |
63 | `Temporal.Instant`表示某个固定的时点。
64 |
65 | ```javascript
66 | const instant = Temporal.Instant.from('1969-07-20T20:17Z');
67 | instant.toString(); // => '1969-07-20T20:17:00Z'
68 | instant.epochMilliseconds; // => -14182980000
69 |
70 | // 某个 Unix 时间戳对应的时点
71 | const launch = Temporal.Instant.fromEpochMilliseconds(1851222399924);
72 | const now = Temporal.Now.instant();
73 | const duration = now.until(launch, { smallestUnit: "hour" });
74 | ```
75 |
76 | ## Temporal.ZonedDateTime
77 |
78 | `Temporal.ZonedDateTime`表示某个时区的时间。它会在 ISO8601 的标准格式后面,添加时区后缀和历法后缀。
79 |
80 | ```javascript
81 | 2020-08-05T20:06:13+09:00[Asia/Tokyo][u-ca=japanese]
82 | ```
83 |
84 | 上面示例中,`2020-08-05T20:06:13+09:00`是 ISO8601 标准格式,`[Asia/Tokyo]`是时区后缀,`[u-ca=japanese]`是历法后缀,表示采用日本历法。
85 |
86 | 默认的历法是 ISO8601 规定的公历,可以省略不写。
87 |
88 | 下面是使用`Temporal.ZonedDateTime.from()`新建 ZonedDateTime 实例对象的例子。
89 |
90 | ```javascript
91 | const zonedDateTime = Temporal.ZonedDateTime.from({
92 | timeZone: 'America/Los_Angeles',
93 | year: 1995,
94 | month: 12,
95 | day: 7,
96 | hour: 3,
97 | minute: 24,
98 | second: 30,
99 | millisecond: 0,
100 | microsecond: 3,
101 | nanosecond: 500
102 | }); // => 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles]
103 | ```
104 |
105 | 下面是使用`Temporal.ZonedDateTime.compare()`比较两个 ZonedDateTime 实例对象的例子。
106 |
107 | ```javascript
108 | const one = Temporal.ZonedDateTime.from('2020-11-01T01:45-07:00[America/Los_Angeles]');
109 | const two = Temporal.ZonedDateTime.from('2020-11-01T01:15-08:00[America/Los_Angeles]');
110 |
111 | Temporal.ZonedDateTime.compare(one, two);
112 | // -1
113 | ```
114 |
115 | 上面示例中,`Temporal.ZonedDateTime.compare()`返回`-1`,表示第一个时间小于(即早于)第二个时间。如果返回`1`,表示第一个时间大于第二个时间;返回`0`,表示两个时间相等。
116 |
117 | ZonedDateTime 实例对象有以下属性。
118 |
119 | - hoursInDay:指定时区的某一天一共有多少个小时,主要用来处理夏令时。
120 |
121 | ```javascript
122 | Temporal.ZonedDateTime.from('2020-01-01T12:00-08:00[America/Los_Angeles]').hoursInDay;
123 | // 24
124 | Temporal.ZonedDateTime.from('2020-03-08T12:00-07:00[America/Los_Angeles]').hoursInDay;
125 | // 23
126 | Temporal.ZonedDateTime.from('2020-11-01T12:00-08:00[America/Los_Angeles]').hoursInDay;
127 | // 25
128 | ```
129 |
130 | - daysInYear
131 | - inLeapYear
132 |
133 | ZonedDateTime 实例对象有以下方法。
134 |
135 | - .withTimeZone():切换时区。
136 |
137 | ```javascript
138 | zdt = Temporal.ZonedDateTime.from('1995-12-07T03:24:30+09:00[Asia/Tokyo]');
139 | zdt.toString(); // => '1995-12-07T03:24:30+09:00[Asia/Tokyo]'
140 | zdt.withTimeZone('Africa/Accra').toString(); // => '1995-12-06T18:24:30+00:00[Africa/Accra]'
141 | ```
142 |
143 | - add():增加时间。
144 |
145 | ```javascript
146 | zdt = Temporal.ZonedDateTime.from('2020-03-08T00:00-08:00[America/Los_Angeles]');
147 |
148 | // 增加一天
149 | laterDay = zdt.add({ days: 1 });
150 | // 2020-03-09T00:00:00-07:00[America/Los_Angeles]
151 | // 注意:时区改变了,表示洛杉矶这个日期处于夏令时,比正常情况早一个小时
152 |
153 | laterDay.since(zdt, { largestUnit: 'hour' }).hours;
154 | // 23
155 | // 当天只有23小时
156 |
157 | laterHours = zdt.add({ hours: 24 });
158 | // 2020-03-09T01:00:00-07:00[America/Los_Angeles]
159 | laterHours.since(zdt, { largestUnit: 'hour' }).hours; // 24
160 | ```
161 |
162 | - .until():计算两个时间之间的差异。
163 |
164 | ## Temporal.PlainDate
165 |
166 | `Temporal.PlainDate`表示与时区无关的日期。
167 |
168 | ```javascript
169 | const date = Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }); // => 2006-08-24
170 | date.year; // => 2006
171 | date.inLeapYear; // => false
172 | date.toString(); // => '2006-08-24'
173 | ```
174 |
175 | 下面的例子是计算某个日期以后的时间。
176 |
177 | ```javascript
178 | const date = Temporal.PlainDate.from('2024-01-01');
179 | const newDate = date.add({ days: 10 });
180 | console.log(newDate.toString()); // Outputs '2024-01-11'
181 | ```
182 |
183 | ## Temporal.PlainTime
184 |
185 | `Temporal.PlainTime`表示与时区无关的某个时点。
186 |
187 | ```javascript
188 | const time = Temporal.PlainTime.from({
189 | hour: 19,
190 | minute: 39,
191 | second: 9,
192 | millisecond: 68,
193 | microsecond: 346,
194 | nanosecond: 205
195 | }); // => 19:39:09.068346205time.second; // => 9
196 | time.toString(); // => '19:39:09.068346205'
197 | ```
198 |
199 | ## Temporal.PlainDateTime
200 |
201 | `Temporal.PlainDateTime`表示时区无关的日期时间。
202 |
203 | ```javascript
204 | const dateTime = Temporal.PlainDateTime.from({
205 | year: 1995,
206 | month: 12,
207 | day: 7,
208 | hour: 15
209 | }); // => 1995-12-07T15:00:00
210 | const dateTime1 = dateTime.with({
211 | minute: 17,
212 | second: 19
213 | }); // => 1995-12-07T15:17:19
214 | ```
215 |
216 | ## Temporal.PlainYearMonth
217 |
218 | `Temporal.PlainYearMonth`表示不含日期的年月。
219 |
220 | ```javascript
221 | const yearMonth = Temporal.PlainYearMonth.from({ year: 2020, month: 10 }); // => 2020-10
222 | yearMonth.daysInMonth; // => 31
223 | yearMonth.daysInYear; // => 366
224 | ```
225 |
226 | ## Temporal.PlainMonthDay
227 |
228 | `Temporal.PlainMonthDay`表示没有年份的月和日。
229 |
230 | 下面是计算生日的例子。
231 |
232 | ```javascript
233 | const birthday = Temporal.PlainMonthDay.from("12-15");
234 | // 或者写成
235 | // const birthday = Temporal.PlainMonthDay.from({ month: 12, day: 15 })
236 |
237 | const birthdayIn2030 = birthday.toPlainDate({ year: 2030 });
238 |
239 | birthdayIn2030.toString() // 2030-12-15
240 | birthdayIn2030.dayOfWeek // 7
241 | ```
242 |
243 | 下面是农历一月一日(大年初一)的例子。
244 |
245 | ```javascript
246 | const chineseNewYear = Temporal.PlainMonthDay.from({
247 | monthCode: "M01",
248 | day: 1,
249 | calendar: "chinese",
250 | });
251 |
252 | const currentYear = Temporal.Now.plainDateISO().withCalendar("chinese").year;
253 |
254 | // 获取下一个春节
255 | let nextCNY = chineseNewYear.toPlainDate({ year: currentYear });
256 | // 如果 nextCNY 早于当前时间,则向后移动一年
257 | if (Temporal.PlainDate.compare(nextCNY, Temporal.Now.plainDateISO()) <= 0) {
258 | nextCNY = nextCNY.add({ years: 1 });
259 | }
260 |
261 | nextCNY.withCalendar("iso8601").toLocaleString() // 1/29/2025
262 | ```
263 |
264 | ## Temporal.Duration
265 |
266 | `Temporal.Duration`表示时长。
267 |
268 | ```javascript
269 | const duration = Temporal.Duration.from({
270 | hours: 130,
271 | minutes: 20
272 | });
273 |
274 | duration.total({ unit: 'second' }); // => 469200
275 | ```
276 |
277 | ## Temporal.TimeZone
278 |
279 | `Temporal.TimeZone`表示某个时区。
280 |
281 | ```javascript
282 | const timeZone = Temporal.TimeZone.from('Africa/Cairo');
283 | timeZone.getInstantFor('2000-01-01T00:00'); // => 1999-12-31T22:00:00Z
284 | timeZone.getPlainDateTimeFor('2000-01-01T00:00Z'); // => 2000-01-01T02:00:00
285 | timeZone.getPreviousTransition(Temporal.Now.instant()); // => 2014-09-25T21:00:00Z
286 | timeZone.getNextTransition(Temporal.Now.instant()); // => null
287 | ```
288 |
289 | ## Temporal.Calendar
290 |
291 | `Temporal.Calendar`表示某个日历系统。
292 |
293 | ```javascript
294 | const cal = Temporal.Calendar.from('iso8601');
295 | const date = cal.dateFromFields({ year: 1999, month: 12, day: 31 }, {});
296 | date.monthsInYear; // => 12
297 | date.daysInYear; // => 365
298 | ```
299 |
300 | ## Temporal.Duration
301 |
302 | Temporal.Duration 表示一个持续的时间对象。
303 |
304 | ```javascript
305 | const durations = [
306 | Temporal.Duration.from({ hours: 1 }),
307 | Temporal.Duration.from({ hours: 2 }),
308 | Temporal.Duration.from({ hours: 1, minutes: 30 }),
309 | Temporal.Duration.from({ hours: 1, minutes: 45 }),
310 | ];
311 |
312 | durations.sort(Temporal.Duration.compare);
313 | console.log(durations.map((d) => d.toString()));
314 | // [ 'PT1H', 'PT1H30M', 'PT1H45M', 'PT2H' ]
315 | ````
316 |
317 | ## 参考链接
318 |
319 | - [Temporal documentation](https://tc39.es/proposal-temporal/docs/)
320 | - [JS Dates Are About to Be Fixed](https://docs.timetime.in/blog/js-dates-finally-fixed/)
321 | - [JavaScript Temporal is coming](https://developer.mozilla.org/en-US/blog/javascript-temporal-is-coming/)
322 |
323 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/original/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/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/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 |
--------------------------------------------------------------------------------
/app/bower_components/marked/test/original/markdown_documentation_basics.html:
--------------------------------------------------------------------------------
1 | Markdown: Basics
2 |
3 |
10 |
11 | Getting the Gist of Markdown's Formatting Syntax
12 |
13 | This page offers a brief overview of what it's like to use Markdown.
14 | The syntax page provides complete, detailed documentation for
15 | every feature, but Markdown should be very easy to pick up simply by
16 | looking at a few examples of it in action. The examples on this page
17 | are written in a before/after style, showing example syntax and the
18 | HTML output produced by Markdown.
19 |
20 | It's also helpful to simply try Markdown out; the Dingus is a
21 | web application that allows you type your own Markdown-formatted text
22 | and translate it to XHTML.
23 |
24 | Note: This document is itself written using Markdown; you
25 | can see the source for it by adding '.text' to the URL .
26 |
27 | Paragraphs, Headers, Blockquotes
28 |
29 | A paragraph is simply one or more consecutive lines of text, separated
30 | by one or more blank lines. (A blank line is any line that looks like a
31 | blank line -- a line containing nothing spaces or tabs is considered
32 | blank.) Normal paragraphs should not be intended with spaces or tabs.
33 |
34 | Markdown offers two styles of headers: Setext and atx .
35 | Setext-style headers for <h1> and <h2> are created by
36 | "underlining" with equal signs (=) and hyphens (-), respectively.
37 | To create an atx-style header, you put 1-6 hash marks (#) at the
38 | beginning of the line -- the number of hashes equals the resulting
39 | HTML header level.
40 |
41 | Blockquotes are indicated using email-style '>' angle brackets.
42 |
43 | Markdown:
44 |
45 | A First Level Header
46 | ====================
47 |
48 | A Second Level Header
49 | ---------------------
50 |
51 | Now is the time for all good men to come to
52 | the aid of their country. This is just a
53 | regular paragraph.
54 |
55 | The quick brown fox jumped over the lazy
56 | dog's back.
57 |
58 | ### Header 3
59 |
60 | > This is a blockquote.
61 | >
62 | > This is the second paragraph in the blockquote.
63 | >
64 | > ## This is an H2 in a blockquote
65 |
66 |
67 | Output:
68 |
69 | <h1>A First Level Header</h1>
70 |
71 | <h2>A Second Level Header</h2>
72 |
73 | <p>Now is the time for all good men to come to
74 | the aid of their country. This is just a
75 | regular paragraph.</p>
76 |
77 | <p>The quick brown fox jumped over the lazy
78 | dog's back.</p>
79 |
80 | <h3>Header 3</h3>
81 |
82 | <blockquote>
83 | <p>This is a blockquote.</p>
84 |
85 | <p>This is the second paragraph in the blockquote.</p>
86 |
87 | <h2>This is an H2 in a blockquote</h2>
88 | </blockquote>
89 |
90 |
91 | Phrase Emphasis
92 |
93 | Markdown uses asterisks and underscores to indicate spans of emphasis.
94 |
95 | Markdown:
96 |
97 | Some of these words *are emphasized*.
98 | Some of these words _are emphasized also_.
99 |
100 | Use two asterisks for **strong emphasis**.
101 | Or, if you prefer, __use two underscores instead__.
102 |
103 |
104 | Output:
105 |
106 | <p>Some of these words <em>are emphasized</em>.
107 | Some of these words <em>are emphasized also</em>.</p>
108 |
109 | <p>Use two asterisks for <strong>strong emphasis</strong>.
110 | Or, if you prefer, <strong>use two underscores instead</strong>.</p>
111 |
112 |
113 | Lists
114 |
115 | Unordered (bulleted) lists use asterisks, pluses, and hyphens (*,
116 | +, and -) as list markers. These three markers are
117 | interchangable; this:
118 |
119 | * Candy.
120 | * Gum.
121 | * Booze.
122 |
123 |
124 | this:
125 |
126 | + Candy.
127 | + Gum.
128 | + Booze.
129 |
130 |
131 | and this:
132 |
133 | - Candy.
134 | - Gum.
135 | - Booze.
136 |
137 |
138 | all produce the same output:
139 |
140 | <ul>
141 | <li>Candy.</li>
142 | <li>Gum.</li>
143 | <li>Booze.</li>
144 | </ul>
145 |
146 |
147 | Ordered (numbered) lists use regular numbers, followed by periods, as
148 | list markers:
149 |
150 | 1. Red
151 | 2. Green
152 | 3. Blue
153 |
154 |
155 | Output:
156 |
157 | <ol>
158 | <li>Red</li>
159 | <li>Green</li>
160 | <li>Blue</li>
161 | </ol>
162 |
163 |
164 | If you put blank lines between items, you'll get <p> tags for the
165 | list item text. You can create multi-paragraph list items by indenting
166 | the paragraphs by 4 spaces or 1 tab:
167 |
168 | * A list item.
169 |
170 | With multiple paragraphs.
171 |
172 | * Another item in the list.
173 |
174 |
175 | Output:
176 |
177 | <ul>
178 | <li><p>A list item.</p>
179 | <p>With multiple paragraphs.</p></li>
180 | <li><p>Another item in the list.</p></li>
181 | </ul>
182 |
183 |
184 | Links
185 |
186 | Markdown supports two styles for creating links: inline and
187 | reference . With both styles, you use square brackets to delimit the
188 | text you want to turn into a link.
189 |
190 | Inline-style links use parentheses immediately after the link text.
191 | For example:
192 |
193 | This is an [example link](http://example.com/).
194 |
195 |
196 | Output:
197 |
198 | <p>This is an <a href="http://example.com/">
199 | example link</a>.</p>
200 |
201 |
202 | Optionally, you may include a title attribute in the parentheses:
203 |
204 | This is an [example link](http://example.com/ "With a Title").
205 |
206 |
207 | Output:
208 |
209 | <p>This is an <a href="http://example.com/" title="With a Title">
210 | example link</a>.</p>
211 |
212 |
213 | Reference-style links allow you to refer to your links by names, which
214 | you define elsewhere in your document:
215 |
216 | I get 10 times more traffic from [Google][1] than from
217 | [Yahoo][2] or [MSN][3].
218 |
219 | [1]: http://google.com/ "Google"
220 | [2]: http://search.yahoo.com/ "Yahoo Search"
221 | [3]: http://search.msn.com/ "MSN Search"
222 |
223 |
224 | Output:
225 |
226 | <p>I get 10 times more traffic from <a href="http://google.com/"
227 | title="Google">Google</a> than from <a href="http://search.yahoo.com/"
228 | title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
229 | title="MSN Search">MSN</a>.</p>
230 |
231 |
232 | The title attribute is optional. Link names may contain letters,
233 | numbers and spaces, but are not case sensitive:
234 |
235 | I start my morning with a cup of coffee and
236 | [The New York Times][NY Times].
237 |
238 | [ny times]: http://www.nytimes.com/
239 |
240 |
241 | Output:
242 |
243 | <p>I start my morning with a cup of coffee and
244 | <a href="http://www.nytimes.com/">The New York Times</a>.</p>
245 |
246 |
247 | Images
248 |
249 | Image syntax is very much like link syntax.
250 |
251 | Inline (titles are optional):
252 |
253 | 
254 |
255 |
256 | Reference-style:
257 |
258 | ![alt text][id]
259 |
260 | [id]: /path/to/img.jpg "Title"
261 |
262 |
263 | Both of the above examples produce the same output:
264 |
265 | <img src="/path/to/img.jpg" alt="alt text" title="Title" />
266 |
267 |
268 | Code
269 |
270 | In a regular paragraph, you can create code span by wrapping text in
271 | backtick quotes. Any ampersands (&) and angle brackets (< or
272 | >) will automatically be translated into HTML entities. This makes
273 | it easy to use Markdown to write about HTML example code:
274 |
275 | I strongly recommend against using any `<blink>` tags.
276 |
277 | I wish SmartyPants used named entities like `—`
278 | instead of decimal-encoded entites like `—`.
279 |
280 |
281 | Output:
282 |
283 | <p>I strongly recommend against using any
284 | <code><blink></code> tags.</p>
285 |
286 | <p>I wish SmartyPants used named entities like
287 | <code>&mdash;</code> instead of decimal-encoded
288 | entites like <code>&#8212;</code>.</p>
289 |
290 |
291 | To specify an entire block of pre-formatted code, indent every line of
292 | the block by 4 spaces or 1 tab. Just like with code spans, &, <,
293 | and > characters will be escaped automatically.
294 |
295 | Markdown:
296 |
297 | If you want your page to validate under XHTML 1.0 Strict,
298 | you've got to put paragraph tags in your blockquotes:
299 |
300 | <blockquote>
301 | <p>For example.</p>
302 | </blockquote>
303 |
304 |
305 | Output:
306 |
307 | <p>If you want your page to validate under XHTML 1.0 Strict,
308 | you've got to put paragraph tags in your blockquotes:</p>
309 |
310 | <pre><code><blockquote>
311 | <p>For example.</p>
312 | </blockquote>
313 | </code></pre>
314 |
315 |
--------------------------------------------------------------------------------