|
12 | 12 | return item[0].concat(item[1].join('')); |
13 | 13 | } |
14 | 14 | function trim({desc, str, first, last}) { |
15 | | - if ( str[0].match(first) && str[str.length - 1].match(last || first) ) { |
16 | | - return str.slice(1, -1); |
| 15 | + if ( str[0].match(first) && str[str.length - 1].match(last || first) ) { |
| 16 | + return str.slice(1, -1); |
17 | 17 | } |
18 | 18 | console.log('Error. Could not parse ' + desc + ' in ' + str); |
19 | | - return str; |
| 19 | + return str; |
20 | 20 | } |
21 | 21 | function trimBrackets(str) { |
22 | | - return trim({ |
23 | | - desc: 'bracket', |
| 22 | + return trim({ |
| 23 | + desc: 'bracket', |
24 | 24 | str: str, |
25 | 25 | first: /\(/, |
26 | 26 | last: /\)/, |
27 | 27 | }); |
28 | 28 | } |
29 | 29 | function trimQuotes(str) { |
30 | | - return trim({ |
31 | | - desc: 'quote', |
| 30 | + return trim({ |
| 31 | + desc: 'quote', |
32 | 32 | str, |
33 | 33 | first: /[\"\'\`]/ |
34 | 34 | }); |
35 | 35 | } |
36 | 36 | function trimBracketsAndQuotes(str) { |
37 | 37 | return trimQuotes(trimBrackets(str)); |
38 | 38 | } |
| 39 | + |
| 40 | + |
39 | 41 | } |
40 | 42 |
|
41 | 43 | start |
@@ -81,13 +83,11 @@ page_task |
81 | 83 |
|
82 | 84 | page_actions |
83 | 85 | = on_page_complete |
84 | | - / page_import |
85 | 86 |
|
86 | 87 | task_actions |
87 | 88 | = test: task_test |
88 | 89 | / hint: task_hint |
89 | 90 | / action: task_action |
90 | | - / onPageComplete: on_page_complete |
91 | 91 |
|
92 | 92 | info_title |
93 | 93 | = '#' |
@@ -125,6 +125,26 @@ task_hint |
125 | 125 | return { type: 'hints', value: h }; |
126 | 126 | } |
127 | 127 |
|
| 128 | + |
| 129 | +on_page_complete |
| 130 | + = '@onPageComplete' |
| 131 | + '(' |
| 132 | + quote |
| 133 | + content: .+ |
| 134 | + quote |
| 135 | + ')' |
| 136 | + { return { type: 'onPageComplete', value: content.join('') }; } |
| 137 | + |
| 138 | +page_import |
| 139 | + = '@import' |
| 140 | + '(' |
| 141 | + quote |
| 142 | + filePath: file_path |
| 143 | + quote |
| 144 | + ')' |
| 145 | + break |
| 146 | + { return filePath.join(''); } |
| 147 | + |
128 | 148 | task_action |
129 | 149 | = '@action' |
130 | 150 | '(' |
@@ -183,30 +203,9 @@ action_write_from_file |
183 | 203 | quote |
184 | 204 | ')' |
185 | 205 |
|
186 | | -on_page_complete |
187 | | - = '@onPageComplete' |
188 | | - '(' |
189 | | - quote |
190 | | - content: .+ |
191 | | - quote |
192 | | - ')' |
193 | | - { return { type: 'onPageComplete', value: content.join('') }; } |
194 | | - |
195 | | -page_import |
196 | | - = '@import' |
197 | | - '(' |
198 | | - quote |
199 | | - filePath: file_path |
200 | | - quote |
201 | | - ')' |
202 | | - break |
203 | | - { return filePath.join(''); } |
204 | | - |
205 | | - |
206 | | -// characters |
207 | | - |
208 | 206 | content = [^#^@^+] [^\n^\r]+ [\n\r] |
209 | 207 | space = [ \s] |
210 | 208 | break = [\n\r]? |
211 | 209 | file_path = [a-z_\-\s0-9\.]+ |
212 | 210 | quote = [\"\'\`] |
| 211 | + |
0 commit comments