1
- - [ Flatdoc] ( #flatdoc )
2
- - [ Flatdoc.run()] ( #flatdocrun )
3
- - [ Flatdoc.file()] ( #flatdocfile )
4
- - [ Flatdoc.github()] ( #flatdocgithub )
5
- - [ Parser] ( #parser )
6
- - [ Parser.parse()] ( #parserparse )
7
- - [ Transformer] ( #transformer )
8
- - [ Transformer.mangle()] ( #transformermangle )
9
- - [ Transformer.addIDs()] ( #transformeraddids )
10
- - [ Transformer.getMenu()] ( #transformergetmenu )
11
- - [ Transformer.buttonize()] ( #transformerbuttonize )
12
- - [ Transformer.smartquotes()] ( #transformersmartquotes )
13
- - [ Highlighters] ( #highlighters )
14
- - [ MenuView] ( #menuview )
15
- - [ Runner] ( #runner )
16
- - [ Runner.run()] ( #runnerrun )
17
- - [ Runner.applyData()] ( #runnerapplydata )
18
-
19
- ## Flatdoc
20
-
21
- Flatdoc.
1
+ Flatdoc
2
+ =======
3
+
4
+ Basic Flatdoc module.
5
+
6
+ The main entry point is ` Flatdoc.run() ` , which invokes the [ Runner] .
7
+
8
+ ``` js
9
+ Flatdoc .run ({
10
+ fetcher: Flatdoc .github (' rstacruz/backbone-patterns' );
11
+ });
12
+ ```
13
+
14
+
22
15
23
16
### Flatdoc.run()
24
17
25
- Runs.
18
+ Creates a runner.
19
+ See [ Flatdoc] .
26
20
27
21
### Flatdoc.file()
28
22
29
- File fetcher function.
30
-
31
- Fetches a given ` url ` via AJAX.
32
- See [ Runner#run()] for a description of fetcher functions.
23
+ File fetcher function.
24
+
25
+ Fetches a given ` url ` via AJAX.
26
+ See [ Runner#run()] for a description of fetcher functions.
33
27
34
28
### Flatdoc.github()
35
29
36
- Github fetcher.
37
- Fetches from repo ` repo ` (in format 'user/repo').
38
-
39
- If the parameter ` filepath ` is supplied, it fetches the contents of that
40
- given file in the repo.
41
-
42
- See [ Runner#run()] for a description of fetcher functions.
43
-
44
- See: http://developer.github.com/v3/repos/contents/
30
+ Github fetcher.
31
+ Fetches from repo ` repo ` (in format 'user/repo').
45
32
46
- ## Parser
33
+ If the parameter ` filepath ` is supplied, it fetches the contents of that
34
+ given file in the repo.
35
+
36
+ See [ Runner#run()] for a description of fetcher functions.
37
+
38
+ See: http://developer.github.com/v3/repos/contents/
39
+
40
+ Parser
41
+ ------
42
+
43
+ Parser module.
44
+ Parses a given Markdown document and returns a JSON object with data
45
+ on the Markdown document.
47
46
48
- Parser module.
49
- Parses a given Markdown document and returns a JSON object with data
50
- on the Markdown document.
51
-
52
47
``` js
53
48
var data = Flatdoc .parser .parse (' markdown source here' );
54
49
console .log (data);
@@ -63,41 +58,43 @@ data == {
63
58
}
64
59
```
65
60
61
+
62
+
66
63
### Parser.parse()
67
64
68
- Parses a given Markdown document.
69
- See ` Parser ` for more info.
65
+ Parses a given Markdown document.
66
+ See ` Parser ` for more info.
70
67
71
- ## Transformer
68
+ Transformer
69
+ -----------
70
+
71
+ Transformer module.
72
+ This takes care of any HTML mangling needed. The main entry point is
73
+ ` .mangle() ` which applies all transformations needed.
72
74
73
- Transformer module.
74
- This takes care of any HTML mangling needed. The main entry point is
75
- ` .mangle() ` which applies all transformations needed.
76
-
77
75
``` js
78
76
var $content = $ (" <p>Hello there, this is a docu..." );
79
77
Flatdoc .transformer .mangle ($content);
80
78
```
81
79
82
-
83
- If you would like to change any of the transformations, decorate any of
84
- the functions in ` Flatdoc.transformer ` .
80
+ If you would like to change any of the transformations, decorate any of
81
+ the functions in ` Flatdoc.transformer ` .
85
82
86
83
### Transformer.mangle()
87
84
88
- Takes a given HTML ` $content ` and improves the markup of it by executing
89
- the transformations.
90
-
91
- > See: [ Transformer] ( #transformer )
85
+ Takes a given HTML ` $content ` and improves the markup of it by executing
86
+ the transformations.
87
+
88
+ > See: [ Transformer] ( #transformer )
92
89
93
90
### Transformer.addIDs()
94
91
95
- Adds IDs to headings.
92
+ Adds IDs to headings.
96
93
97
94
### Transformer.getMenu()
98
95
99
- Returns menu data for a given HTML.
100
-
96
+ Returns menu data for a given HTML.
97
+
101
98
``` js
102
99
menu = Flatdoc .transformer .getMenu ($content);
103
100
menu == {
@@ -108,61 +105,87 @@ menu == {
108
105
items: [... ]}, ... ]}
109
106
```
110
107
108
+
109
+
111
110
### Transformer.buttonize()
112
111
113
- Changes "button >" text to buttons.
112
+ Changes "button >" text to buttons.
114
113
115
114
### Transformer.smartquotes()
116
115
117
- Applies smart quotes to a given element.
118
- It leaves ` code ` and ` pre ` blocks alone.
116
+ Applies smart quotes to a given element.
117
+ It leaves ` code ` and ` pre ` blocks alone.
119
118
120
- ## Highlighters
119
+ Highlighters
120
+ ------------
121
+
122
+ Syntax highlighters.
123
+
124
+ You may add or change more highlighters via the ` Flatdoc.highlighters `
125
+ object.
121
126
122
- Syntax highlighters.
123
-
124
- You may add or change more highlighters via the ` Flatdoc.highlighters `
125
- object.
126
-
127
127
``` js
128
128
Flatdoc .highlighters .js = function (code ) {
129
129
};
130
130
```
131
131
132
-
133
- Each of these functions
132
+ Each of these functions
134
133
135
- ## MenuView
134
+ ### Highlighters.js
136
135
137
- Menu view. Renders menus
136
+ JavaScript syntax highlighter.
138
137
139
- ## Runner
138
+ Thanks @visionmedia !
139
+
140
+ MenuView
141
+ --------
142
+
143
+ Menu view. Renders menus
144
+
145
+ Runner
146
+ ------
147
+
148
+ A runner module that fetches via a ` fetcher ` function.
140
149
141
- A runner module that fetches via a ` fetcher ` function.
142
-
143
150
``` js
144
151
var runner = new Flatdoc.runner ({
145
152
fetcher: Flatdoc .url (' readme.txt' )
146
153
});
147
154
runner .run ();
148
155
```
149
156
150
-
151
- The following options are available:
152
-
153
- - ` fetcher ` - a function that takes a callback as an argument and
154
- ``` js
155
- executes that callback when data is returned.
156
- ```
157
+ The following options are available:
157
158
158
-
159
- See: [ Flatdoc.run()]
159
+ - ` fetcher ` - a function that takes a callback as an argument and
160
+ executes that callback when data is returned.
161
+
162
+ See: [ Flatdoc.run()]
163
+
164
+ ### Runner#run()
165
+
166
+ Loads the Markdown document (via the fetcher), parses it, and applies it
167
+ to the elements.
160
168
161
- ### Runner.run ()
169
+ ### Runner#applyData ()
162
170
163
- Loads the Markdown document (via the fetcher), parses it, and applies it
164
- to the elements.
171
+ Applies given doc data ` data ` to elements in object ` elements ` .
165
172
166
- ### Runner.applyData()
167
173
168
- Applies given doc data ` data ` to elements in object ` elements ` .
174
+ [ Flatdoc ] : #flatdoc
175
+ [ Flatdoc.run() ] : #flatdoc-run
176
+ [ Flatdoc.file() ] : #flatdoc-file
177
+ [ Flatdoc.github() ] : #flatdoc-github
178
+ [ Parser ] : #parser
179
+ [ Parser.parse() ] : #parser-parse
180
+ [ Transformer ] : #transformer
181
+ [ Transformer.mangle() ] : #transformer-mangle
182
+ [ Transformer.addIDs() ] : #transformer-addids
183
+ [ Transformer.getMenu() ] : #transformer-getmenu
184
+ [ Transformer.buttonize() ] : #transformer-buttonize
185
+ [ Transformer.smartquotes() ] : #transformer-smartquotes
186
+ [ Highlighters ] : #highlighters
187
+ [ Highlighters.js ] : #highlighters-js
188
+ [ MenuView ] : #menuview
189
+ [ Runner ] : #runner
190
+ [ Runner#run() ] : #runner-run
191
+ [ Runner#applyData() ] : #runner-applydata
0 commit comments