Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Side by Side Diff: Source/devtools/front_end/documentation/WikiParser.js

Issue 539353004: DevTools: [Documentation] Update parser for WikiText (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: comments addressed Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/devtools/front_end/documentation/JSArticle.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @param {string} wikiMarkupText 7 * @param {string} wikiMarkupText
8 */ 8 */
9 WebInspector.WikiParser = function(wikiMarkupText) 9 WebInspector.WikiParser = function(wikiMarkupText)
10 { 10 {
11 this._position = 0; 11 var text = wikiMarkupText.unescapeHTML();
lushnikov 2014/09/12 11:03:31 we shouldn't unescape prior to parsing. This kills
12 this._wikiMarkupText = wikiMarkupText; 12 this._tokenizer = new WebInspector.WikiParser.Tokenizer(text);
13 this._document = this._parse(); 13 this._document = this._parse();
14 /** @type {?WebInspector.WikiParser.Tokenizer} */
15 this._tokenizer;
16 } 14 }
17 15
18 /** 16 /**
19 * @package 17 * @constructor
20 * @enum {string}
21 */ 18 */
22 WebInspector.WikiParser.State = { 19 WebInspector.WikiParser.Section = function()
23 Error: "Error", 20 {
24 FirstOpen: "FirstOpen", 21 /** @type {string} */
25 SecondOpen: "SecondOpen", 22 this.title;
26 Title: "Title", 23
27 PropertyName: "PropertyName", 24 /** @type {?WebInspector.WikiParser.Values} */
28 PropertyValue: "PropertyValue", 25 this.values;
29 FirstClose: "FirstClose", 26
30 SecondClose: "SecondClose" 27 /** @type {?WebInspector.WikiParser.ArticleElement} */
28 this.singleValue;
31 } 29 }
32 30
33 /** 31 /**
34 * @package 32 * @constructor
35 * @enum {string}
36 */ 33 */
37 WebInspector.WikiParser.LinkStates = { 34 WebInspector.WikiParser.Field = function()
38 Error: "Error", 35 {
39 LinkUrl: "LinkUrl", 36 /** @type {string} */
40 LinkName: "LinkName" 37 this.name;
38
39 /** @type {?WebInspector.WikiParser.FieldValue} */
40 this.value;
41 } 41 }
42 42
43 /** 43 /** @typedef {(?WebInspector.WikiParser.ArticleElement|!Array.<!WebInspector.Wik iParser.Section>)} */
44 * @package 44 WebInspector.WikiParser.FieldValue;
45 * @enum {string}
46 */
47 WebInspector.WikiParser.HtmlStates = {
48 Error: "Error",
49 Entry: "Entry",
50 InsideTag: "InsideTag",
51 Exit: "Exit"
52 }
53 45
54 /** 46 /** @typedef {?Object.<string, !WebInspector.WikiParser.FieldValue>} */
55 * @package 47 WebInspector.WikiParser.Values;
56 * @enum {string} 48
57 */ 49 /** @typedef {(?WebInspector.WikiParser.Value|?WebInspector.WikiParser.ArticleEl ement)} */
58 WebInspector.WikiParser.ValueState = { 50 WebInspector.WikiParser.Value;
59 Error: "Error",
60 Outside: "Outside",
61 InsideSquare: "InsideSquare"
62 }
63 51
64 /** 52 /**
65 * @package 53 * @package
66 * @enum {string} 54 * @enum {string}
67 */ 55 */
68 WebInspector.WikiParser.TokenType = { 56 WebInspector.WikiParser.TokenType = {
57 Text: "Text",
58 Table: "Table",
59 OpeningBraces: "OpeningBraces",
60 ClosingBraces: "ClosingBraces",
61 Exclamation: "Exclamation",
62 OpeningBrackets: "OpeningBrackets",
63 ClosingBrackets: "ClosingBrackets",
64 EqualSign: "EqualSign",
65 EqualSignInBraces: "EqualSignInBraces",
66 VerticalLine: "VerticalLine",
69 TripleQuotes: "TripleQuotes", 67 TripleQuotes: "TripleQuotes",
70 OpeningBrackets: "OpeningBrackets",
71 OpeningCodeTag: "OpeningCodeTag", 68 OpeningCodeTag: "OpeningCodeTag",
72 ClosingBrackets: "ClosingBrackets",
73 ClosingCodeTag: "ClosingCodeTag", 69 ClosingCodeTag: "ClosingCodeTag",
74 Bullet: "Bullet", 70 Bullet: "Bullet",
75 Text: "Text",
76 VerticalLine: "VerticalLine",
77 LineEnd: "LineEnd", 71 LineEnd: "LineEnd",
78 CodeBlock: "CodeBlock" 72 CodeBlock: "CodeBlock"
79 } 73 }
80 74
81 /** 75 /**
82 * @constructor 76 * @constructor
83 * @param {string} result 77 * @param {string} result
84 * @param {!WebInspector.WikiParser.TokenType} type 78 * @param {!WebInspector.WikiParser.TokenType} type
85 */ 79 */
86 WebInspector.WikiParser.Token = function(result, type) 80 WebInspector.WikiParser.Token = function(result, type)
(...skipping 20 matching lines...) Expand all
107 } 101 }
108 } 102 }
109 103
110 /** 104 /**
111 * @constructor 105 * @constructor
112 * @param {string} str 106 * @param {string} str
113 */ 107 */
114 WebInspector.WikiParser.Tokenizer = function(str) 108 WebInspector.WikiParser.Tokenizer = function(str)
115 { 109 {
116 this._text = str; 110 this._text = str;
111 this._token = this._internalNextToken();
117 } 112 }
118 113
119 WebInspector.WikiParser.Tokenizer.prototype = { 114 WebInspector.WikiParser.Tokenizer.prototype = {
120 /** 115 /**
121 * @return {!WebInspector.WikiParser.Token} 116 * @return {!WebInspector.WikiParser.Token}
122 */ 117 */
123 _nextToken: function() 118 peekToken: function()
119 {
120 return this._token;
121 },
122
123 /**
124 * @return {!WebInspector.WikiParser.Token}
125 */
126 nextToken: function()
127 {
128 var token = this._token;
129 this._token = this._internalNextToken();
130 return token;
131 },
132
133 /**
134 * @return {!WebInspector.WikiParser.Token}
135 */
136 _internalNextToken: function()
124 { 137 {
125 if (WebInspector.WikiParser.newLineWithSpace.test(this._text)) { 138 if (WebInspector.WikiParser.newLineWithSpace.test(this._text)) {
126 var result = WebInspector.WikiParser.newLineWithSpace.exec(this._tex t); 139 var result = WebInspector.WikiParser.newLineWithSpace.exec(this._tex t);
127 var begin = result.index + result[0].length; 140 var begin = result.index;
128 var end = this._text.length; 141 var end = this._text.length;
129 var lineEnd = WebInspector.WikiParser.newLineWithoutSpace.exec(this. _text); 142 var lineEnd = WebInspector.WikiParser.newLineWithoutSpace.exec(this. _text);
130 if (lineEnd) 143 if (lineEnd)
131 end = lineEnd.index; 144 end = lineEnd.index;
132 var token = this._text.substring(begin, end).replace(/\n */g, "\n"); 145 var token = this._text.substring(begin, end).replace(/\n /g, "\n").r eplace(/{{=}}/g, "=");
133 this._text = this._text.substring(end + 1); 146 this._text = this._text.substring(end + 1);
134 return new WebInspector.WikiParser.Token(token, WebInspector.WikiPar ser.TokenType.CodeBlock); 147 return new WebInspector.WikiParser.Token(token, WebInspector.WikiPar ser.TokenType.CodeBlock);
135 } 148 }
136 149
137 for (var i = 0; i < WebInspector.WikiParser._tokenDescriptors.length; ++ i) { 150 for (var i = 0; i < WebInspector.WikiParser._tokenDescriptors.length; ++ i) {
138 var result = WebInspector.WikiParser._tokenDescriptors[i].regex.exec (this._text); 151 var result = WebInspector.WikiParser._tokenDescriptors[i].regex.exec (this._text);
139 if (result) { 152 if (result) {
140 this._text = this._text.substring(result.index + result[0].lengt h); 153 this._text = this._text.substring(result.index + result[0].lengt h);
141 return new WebInspector.WikiParser.Token(result[0], WebInspector .WikiParser._tokenDescriptors[i].type); 154 return new WebInspector.WikiParser.Token(result[0], WebInspector .WikiParser._tokenDescriptors[i].type);
142 } 155 }
143 } 156 }
144 157
145 for (var lastIndex = 0; lastIndex < this._text.length; ++lastIndex) { 158 for (var lastIndex = 0; lastIndex < this._text.length; ++lastIndex) {
146 var testString = this._text.substring(lastIndex); 159 var testString = this._text.substring(lastIndex);
147 for (var i = 0; i < WebInspector.WikiParser._tokenDescriptors.length ; ++i) { 160 for (var i = 0; i < WebInspector.WikiParser._tokenDescriptors.length ; ++i) {
148 if (WebInspector.WikiParser._tokenDescriptors[i].regex.test(test String)) { 161 if (WebInspector.WikiParser._tokenDescriptors[i].regex.test(test String)) {
149 var token = this._text.substring(0, lastIndex); 162 var token = this._text.substring(0, lastIndex);
150 this._text = this._text.substring(lastIndex); 163 this._text = this._text.substring(lastIndex);
151 return new WebInspector.WikiParser.Token(token, WebInspector .WikiParser.TokenType.Text); 164 return new WebInspector.WikiParser.Token(token, WebInspector .WikiParser.TokenType.Text);
152 } 165 }
153 } 166 }
154 } 167 }
155 168
156 var token = this._text; 169 var token = this._text;
157 this._text = ""; 170 this._text = "";
158 return new WebInspector.WikiParser.Token(token, WebInspector.WikiParser. TokenType.Text); 171 return new WebInspector.WikiParser.Token(token, WebInspector.WikiParser. TokenType.Text);
159 }, 172 },
160 173
161 /** 174 /**
175 * @return {!WebInspector.WikiParser.Tokenizer}
176 */
177 clone: function()
178 {
179 var tokenizer = new WebInspector.WikiParser.Tokenizer(this._text);
180 tokenizer._token = this._token;
181 tokenizer._text = this._text;
182 return tokenizer;
183 },
184
185 /**
162 * @return {boolean} 186 * @return {boolean}
163 */ 187 */
164 _hasMoreTokens: function() 188 hasMoreTokens: function()
165 { 189 {
166 return !!this._text.length; 190 return !!this._text.length;
167 } 191 }
168 } 192 }
169 193
194 WebInspector.WikiParser.table = /^{{{!}}/;
195 WebInspector.WikiParser.exclamation = /^{{!}}/;
196 WebInspector.WikiParser.openingBraces = /^{{/;
197 WebInspector.WikiParser.equalSign = /^=/;
198 WebInspector.WikiParser.equalSignInBraces = /^{{=}}/;
199 WebInspector.WikiParser.closingBraces = /^\s*}}/;
200 WebInspector.WikiParser.oneOpeningBracketWithSpace = /^\n* \[/;
201 WebInspector.WikiParser.twoOpeningBracketsWithSpace = /^\n* \[\[/;
202 WebInspector.WikiParser.oneClosingBracket = /^\n*\]/;
203 WebInspector.WikiParser.twoClosingBrackets = /^\n*\]\]/;
204 WebInspector.WikiParser.tripleQuotes = /^\n*'''/;
205 WebInspector.WikiParser.openingCodeTag = /^<code\s*>/;
206 WebInspector.WikiParser.closingCodeTag = /^<\/code\s*>/;
207 WebInspector.WikiParser.closingBullet = /^\*/;
208 WebInspector.WikiParser.lineEnd = /^\n/;
209 WebInspector.WikiParser.verticalLine = /^\n*\|/;
210 WebInspector.WikiParser.newLineWithSpace = /^\n [^ ]/;
211 WebInspector.WikiParser.newLineWithoutSpace = /\n[^ ]/;
212
213 /**
214 * @constructor
215 * @param {!RegExp} regex
216 * @param {!WebInspector.WikiParser.TokenType} type
217 */
218 WebInspector.WikiParser.TokenDescriptor = function(regex, type)
219 {
220 this.regex = regex;
221 this.type = type;
222 }
223
224 WebInspector.WikiParser._tokenDescriptors = [
225 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.exclamat ion, WebInspector.WikiParser.TokenType.Exclamation),
226 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.equalSig nInBraces, WebInspector.WikiParser.TokenType.EqualSignInBraces),
227 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.equalSig n, WebInspector.WikiParser.TokenType.EqualSign),
228 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.table, W ebInspector.WikiParser.TokenType.Table),
229 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.openingB races, WebInspector.WikiParser.TokenType.OpeningBraces),
230 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.vertical Line, WebInspector.WikiParser.TokenType.VerticalLine),
231 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.closingB races, WebInspector.WikiParser.TokenType.ClosingBraces),
232 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.twoOpeni ngBracketsWithSpace, WebInspector.WikiParser.TokenType.OpeningBrackets),
233 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.twoClosi ngBrackets, WebInspector.WikiParser.TokenType.ClosingBrackets),
234 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.oneOpeni ngBracketWithSpace, WebInspector.WikiParser.TokenType.OpeningBrackets),
235 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.oneClosi ngBracket, WebInspector.WikiParser.TokenType.ClosingBrackets),
236 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.newLineW ithSpace, WebInspector.WikiParser.TokenType.CodeBlock),
237 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.tripleQu otes, WebInspector.WikiParser.TokenType.TripleQuotes),
238 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.openingC odeTag, WebInspector.WikiParser.TokenType.OpeningCodeTag),
239 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.closingC odeTag, WebInspector.WikiParser.TokenType.ClosingCodeTag),
240 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.closingB ullet, WebInspector.WikiParser.TokenType.Bullet),
241 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.lineEnd, WebInspector.WikiParser.TokenType.LineEnd)
242 ]
243
170 WebInspector.WikiParser.prototype = { 244 WebInspector.WikiParser.prototype = {
171 /** 245 /**
172 * @return {!Object} 246 * @return {!Object}
173 */ 247 */
174 document: function() 248 document: function()
175 { 249 {
176 return this._document; 250 return this._document;
177 }, 251 },
178 252
179 /** 253 /**
180 * @return {!Object} 254 * @return {?WebInspector.WikiParser.TokenType}
255 */
256 _secondTokenType: function()
257 {
258 var tokenizer = this._tokenizer.clone();
259 if (!tokenizer.hasMoreTokens())
260 return null;
261 tokenizer.nextToken();
262 if (!tokenizer.hasMoreTokens())
263 return null;
264 return tokenizer.nextToken().type();
265 },
266
267 /**
268 * @return {!Object.<string, ?WebInspector.WikiParser.Value>}
181 */ 269 */
182 _parse: function() 270 _parse: function()
183 { 271 {
184 var obj = {}; 272 var obj = {};
185 this._wikiMarkupText = this._wikiMarkupText.replace(/&lt;/g, "<") 273 while (this._tokenizer.hasMoreTokens()) {
186 .replace(/&gt;/g, ">") 274 var section = this._parseSection();
187 .replace(/&#58;/g, ":") 275 if (section.title)
188 .replace(/&quot;/g, "\"") 276 obj[section.title] = section.singleValue || section.values;
189 .replace(/&#60;/g, "<")
190 .replace(/&#62;/g, ">")
191 .replace(/{{=}}/g, "=")
192 .replace(/{{!}}/g, "|")
193 .replace(/&amp;/g, "&");
194 while (this._position < this._wikiMarkupText.length) {
195 var field = this._parseField();
196 for (var key in field) {
197 console.assert(typeof obj[key] === "undefined", "Duplicate key: " + key);
198 obj[key] = field[key];
199 }
200 } 277 }
201 return obj; 278 return obj;
202 }, 279 },
203 280
204 /** 281 /**
282 * @return {!WebInspector.WikiParser.Section}
283 */
284 _parseSection: function()
285 {
286 var section = new WebInspector.WikiParser.Section();
287 if (!this._tokenizer.hasMoreTokens() || this._tokenizer.nextToken().type () !== WebInspector.WikiParser.TokenType.OpeningBraces)
288 return section;
289
290 var title = this._deleteTrailingSpaces(this._parseSectionTitle());
291 if (!title.length)
292 return section;
293 section.title = title;
294 if (this._tokenizer.peekToken().type() === WebInspector.WikiParser.Token Type.ClosingBraces) {
295 this._tokenizer.nextToken();
296 return section;
297 }
298 var secondTokenType = this._secondTokenType();
299 if (!secondTokenType || secondTokenType !== WebInspector.WikiParser.Toke nType.EqualSign) {
300 section.singleValue = this._parseMarkupText();
301 } else {
302 section.values = {};
303 while (this._tokenizer.hasMoreTokens()) {
304 var field = this._parseField();
305 section.values[field.name] = field.value;
306 if (this._tokenizer.peekToken().type() === WebInspector.WikiPars er.TokenType.ClosingBraces) {
307 this._tokenizer.nextToken();
308 return section;
309 }
310 }
311 }
312 var token = this._tokenizer.nextToken();
313 if (token.type() !== WebInspector.WikiParser.TokenType.ClosingBraces)
314 throw new Error("Two closing braces expected; found " + token.value( ));
315
316 return section;
317 },
318
319 /**
320 * @return {!WebInspector.WikiParser.Field}
321 */
322 _parseField: function()
323 {
324 var field = new WebInspector.WikiParser.Field();
325 field.name = this._parseFieldName();
326 var token = this._tokenizer.peekToken();
327 switch (token.type()) {
328 case WebInspector.WikiParser.TokenType.OpeningBraces:
329 field.value = this._parseArray();
330 break;
331 case WebInspector.WikiParser.TokenType.LineEnd:
332 this._tokenizer.nextToken();
333 break;
334 case WebInspector.WikiParser.TokenType.ClosingBraces:
335 return field;
336 default:
337 if (field.name.toUpperCase() === "CODE")
338 field.value = this._parseExampleCode();
339 else
340 field.value = this._parseMarkupText();
341 }
342 return field;
343 },
344
345 /**
346 * @return {!Array.<!WebInspector.WikiParser.Section>}
347 */
348 _parseArray: function()
349 {
350 var array = [];
351 while (this._tokenizer.peekToken().type() === WebInspector.WikiParser.To kenType.OpeningBraces)
352 array.push(this._parseSection());
353 if (this._tokenizer.peekToken().type() === WebInspector.WikiParser.Token Type.VerticalLine)
354 this._tokenizer.nextToken();
355 return array;
356 },
357
358 /**
205 * @return {string} 359 * @return {string}
206 */ 360 */
207 _parseValue: function() { 361 _parseSectionTitle: function()
208 var states = WebInspector.WikiParser.ValueState; 362 {
209 var state = states.Outside;
210 var value = "";
211 while (this._position < this._wikiMarkupText.length) {
212 switch (state) {
213 case states.Outside:
214 if (this._wikiMarkupText[this._position] === "|" || (this._wikiM arkupText[this._position] === "}" && this._wikiMarkupText[this._position + 1] == = "}"))
215 return value;
216 switch (this._wikiMarkupText[this._position]) {
217 case "<":
218 var indexClose = this._wikiMarkupText.indexOf(">", this._pos ition);
219 if (indexClose !== -1) {
220 value += this._wikiMarkupText.substring(this._position, indexClose + 1);
221 this._position = indexClose;
222 }
223 break;
224 case "[":
225 state = states.InsideSquare;
226 value += this._wikiMarkupText[this._position];
227 break;
228 default:
229 value += this._wikiMarkupText[this._position];
230 }
231 break;
232 case states.InsideSquare:
233 if (this._wikiMarkupText[this._position] === "[") {
234 var indexClose = this._wikiMarkupText.indexOf("]]", this._po sition);
235 if (indexClose !== -1) {
236 value += this._wikiMarkupText.substring(this._position, indexClose + 2);
237 this._position = indexClose + 1;
238 }
239 } else {
240 var indexClose = this._wikiMarkupText.indexOf("]", this._pos ition);
241 if (indexClose !== -1) {
242 value += this._wikiMarkupText.substring(this._position, indexClose + 1);
243 this._position = indexClose;
244 }
245 }
246 state = states.Outside;
247 break;
248 }
249 this._position++;
250 }
251 return value;
252 },
253
254 /**
255 * @return {!Object}
256 */
257 _parseField: function()
258 {
259 var obj = {};
260 var title = ""; 363 var title = "";
261 var propertyName = ""; 364 while (this._tokenizer.hasMoreTokens()) {
262 var propertyValue = ""; 365 var token = this._tokenizer.peekToken();
263 var states = WebInspector.WikiParser.State; 366 switch (token.type()) {
264 var state = states.FirstOpen; 367 case WebInspector.WikiParser.TokenType.ClosingBraces:
265 while (this._position < this._wikiMarkupText.length) { 368 return title;
266 var skipIncrement = false; 369 case WebInspector.WikiParser.TokenType.VerticalLine:
267 switch (state) { 370 this._tokenizer.nextToken();
268 case states.FirstOpen: 371 return title;
269 if (this._wikiMarkupText[this._position] === "{") 372 case WebInspector.WikiParser.TokenType.Text:
270 state = states.SecondOpen; 373 title += this._tokenizer.nextToken().value();
271 else 374 break;
272 state = states.Error; 375 default:
273 break; 376 throw new Error("Title could not be parsed. Unexpected token " + token.value());
274 case states.SecondOpen: 377 }
275 if (this._wikiMarkupText[this._position] === "{") 378 }
276 state = states.Title; 379 return title;
277 else 380 },
278 state = states.Error; 381
279 break; 382 /**
280 case states.Title: 383 * @return {string}
281 if (this._wikiMarkupText[this._position] === "|") { 384 */
282 title = this._deleteTrailingSpaces(title); 385 _parseFieldName: function()
283 if (title !== "") 386 {
284 obj[title] = {}; 387 var name = "";
285 state = states.PropertyName; 388 while (this._tokenizer.hasMoreTokens()) {
286 } else if (this._wikiMarkupText[this._position] === "}") { 389 var token = this._tokenizer.peekToken();
287 title = this._deleteTrailingSpaces(title); 390 switch (token.type()) {
288 if (title !== "") 391 case WebInspector.WikiParser.TokenType.ClosingBraces:
289 obj[title] = {}; 392 return name;
290 state = states.FirstClose; 393 case WebInspector.WikiParser.TokenType.EqualSign:
291 } else { 394 this._tokenizer.nextToken();
292 title += (this._wikiMarkupText[this._position] === "\n" ? "" : this._wikiMarkupText[this._position]); 395 return name;
293 } 396 case WebInspector.WikiParser.TokenType.VerticalLine:
294 break; 397 case WebInspector.WikiParser.TokenType.Text:
295 case states.PropertyName: 398 name += this._tokenizer.nextToken().value();
296 if (this._wikiMarkupText[this._position] === "=") { 399 break;
297 state = states.PropertyValue; 400 default:
298 this._deleteTrailingSpaces(propertyName); 401 throw new Error("Name could not be parsed. Unexpected token " + token.value());
299 if (propertyName !== "") 402 }
300 obj[title][propertyName] = []; 403 }
301 } else { 404 return name;
302 if (this._wikiMarkupText[this._position] === "}") { 405 },
303 propertyName = this._deleteTrailingSpaces(propertyName); 406
304 obj[title] = propertyName; 407 /**
305 state = states.FirstClose; 408 * @return {!WebInspector.WikiParser.Block}
306 } else { 409 */
307 propertyName += this._wikiMarkupText[this._position]; 410 _parseExampleCode: function()
308 } 411 {
309 } 412 var code = "";
310 break; 413
311 case states.PropertyValue: 414 /**
312 if (this._wikiMarkupText[this._position] === "{" && this._wikiMa rkupText[this._position + 1] === "{") { 415 * @return {!WebInspector.WikiParser.Block}
313 propertyValue = this._parseField(); 416 */
314 obj[title][propertyName].push(propertyValue); 417 function wrapIntoArticleElement()
315 propertyValue = ""; 418 {
316 skipIncrement = true; 419 var plainText = new WebInspector.WikiParser.PlainText(code);
317 } else if (this._wikiMarkupText[this._position] === "|") { 420 var block = new WebInspector.WikiParser.Block([plainText])
318 propertyValue = this._deleteTrailingSpaces(propertyValue); 421 var articleElement = new WebInspector.WikiParser.Block([block]);
319 if (propertyValue !== "") 422 return articleElement;
320 obj[title][propertyName] = propertyValue; 423 }
321 424
322 state = states.PropertyName; 425 while (this._tokenizer.hasMoreTokens()) {
323 if (Array.isArray(obj[title][propertyName]) && obj[title][pr opertyName].length === 1) { 426 var token = this._tokenizer.peekToken();
324 var newObj = obj[title][propertyName][0]; 427 switch (token.type()) {
325 obj[title][propertyName] = newObj; 428 case WebInspector.WikiParser.TokenType.ClosingBraces:
326 } 429 return wrapIntoArticleElement();
327 430 case WebInspector.WikiParser.TokenType.VerticalLine:
328 propertyName = ""; 431 this._tokenizer.nextToken();
329 propertyValue = ""; 432 return wrapIntoArticleElement();
330 } else if (this._position + 1 < this._wikiMarkupText.length && t his._wikiMarkupText[this._position] === "}" && this._wikiMarkupText[this._positi on + 1] === "}") { 433 case WebInspector.WikiParser.TokenType.Exclamation:
331 propertyValue = this._deleteTrailingSpaces(propertyValue); 434 this._tokenizer.nextToken();
332 if (propertyValue !== "") 435 code += "|";
333 obj[title][propertyName].push(propertyValue); 436 break;
334 if (Array.isArray(obj[title][propertyName]) && obj[title][pr opertyName].length === 1) { 437 case WebInspector.WikiParser.TokenType.EqualSignInBraces:
335 var newObj = obj[title][propertyName][0]; 438 this._tokenizer.nextToken();
336 obj[title][propertyName] = newObj; 439 code += "=";
337 } 440 break;
338 441 default:
339 propertyValue = ""; 442 this._tokenizer.nextToken();
340 state = states.FirstClose; 443 code += token.value();
341 } else { 444 }
342 propertyValue = this._parseValue(); 445 }
343 skipIncrement = true; 446 return wrapIntoArticleElement();
344 } 447 },
345 break; 448
346 case states.FirstClose: 449 /**
347 if (this._wikiMarkupText[this._position] === "}")
348 state = states.SecondClose;
349 else
350 state = states.Error;
351 break;
352 case states.SecondClose:
353 while (this._position < this._wikiMarkupText.length && this._wik iMarkupText[this._position] === "\n")
354 this._position++;
355 return obj;
356 case states.Error:
357 this._position = this._wikiMarkupText.length;
358 return {};
359 }
360 if (!skipIncrement)
361 this._position++;
362 }
363 return obj;
364 },
365
366 /**
367 * @param {string} str
368 * @return {?WebInspector.WikiParser.Block} 450 * @return {?WebInspector.WikiParser.Block}
369 */ 451 */
370 parseString: function(str) 452 _parseMarkupText: function()
371 { 453 {
372 this._tokenizer = new WebInspector.WikiParser.Tokenizer(str);
373 var children = []; 454 var children = [];
374 var blockChildren = []; 455 var blockChildren = [];
375 var text = ""; 456 var text = "";
376 var self = this; 457 var self = this;
377 458
378 function processSimpleText() 459 function processSimpleText()
379 { 460 {
380 var currentText = self._deleteTrailingSpaces(text); 461 var currentText = self._deleteTrailingSpaces(text);
381 if (!currentText.length) 462 if (!currentText.length)
382 return; 463 return;
383 var simpleText = new WebInspector.WikiParser.PlainText(currentText, false); 464 var simpleText = new WebInspector.WikiParser.PlainText(currentText);
384 blockChildren.push(simpleText); 465 blockChildren.push(simpleText);
385 text = ""; 466 text = "";
386 } 467 }
387 468
388 function processBlock() 469 function processBlock()
389 { 470 {
390 if (blockChildren.length) { 471 if (blockChildren.length) {
391 children.push(new WebInspector.WikiParser.Block(blockChildren, f alse)); 472 children.push(new WebInspector.WikiParser.Block(blockChildren));
392 blockChildren = []; 473 blockChildren = [];
393 } 474 }
394 } 475 }
395 while (this._tokenizer._hasMoreTokens()) { 476
396 var token = this._tokenizer._nextToken(); 477 while (this._tokenizer.hasMoreTokens()) {
478 var token = this._tokenizer.peekToken();
397 switch (token.type()) { 479 switch (token.type()) {
480 case WebInspector.WikiParser.TokenType.VerticalLine:
481 case WebInspector.WikiParser.TokenType.ClosingBraces:
482 if (token.type() === WebInspector.WikiParser.TokenType.VerticalL ine)
483 this._tokenizer.nextToken();
484 processSimpleText();
485 processBlock();
486 return new WebInspector.WikiParser.Block(children);
398 case WebInspector.WikiParser.TokenType.TripleQuotes: 487 case WebInspector.WikiParser.TokenType.TripleQuotes:
488 this._tokenizer.nextToken();
399 processSimpleText(); 489 processSimpleText();
400 var highlightText = this._parseHighlight(); 490 var highlightText = this._parseHighlight();
401 blockChildren.push(highlightText) 491 blockChildren.push(highlightText)
402 break; 492 break;
403 case WebInspector.WikiParser.TokenType.OpeningBrackets: 493 case WebInspector.WikiParser.TokenType.OpeningBrackets:
494 this._tokenizer.nextToken();
404 processSimpleText(); 495 processSimpleText();
405 var link = this._parseLink(); 496 var link = this._parseLink();
406 blockChildren.push(link); 497 blockChildren.push(link);
407 break; 498 break;
408 case WebInspector.WikiParser.TokenType.OpeningCodeTag: 499 case WebInspector.WikiParser.TokenType.OpeningCodeTag:
500 this._tokenizer.nextToken();
409 processSimpleText(); 501 processSimpleText();
410 var code = this._parseCode(); 502 var code = this._parseCode();
411 blockChildren.push(code); 503 blockChildren.push(code);
412 break; 504 break;
413 case WebInspector.WikiParser.TokenType.Bullet: 505 case WebInspector.WikiParser.TokenType.Bullet:
506 this._tokenizer.nextToken();
414 processSimpleText(); 507 processSimpleText();
415 processBlock(); 508 processBlock();
416 var bulletText = this._parseBullet(); 509 var bulletText = this._parseBullet();
417 children.push(bulletText); 510 children.push(bulletText);
418 break; 511 break;
419 case WebInspector.WikiParser.TokenType.CodeBlock: 512 case WebInspector.WikiParser.TokenType.CodeBlock:
513 this._tokenizer.nextToken();
420 processSimpleText(); 514 processSimpleText();
421 processBlock(); 515 processBlock();
422 var code = new WebInspector.WikiParser.CodeBlock(token.value()); 516 var code = new WebInspector.WikiParser.CodeBlock(this._trimLeadi ngNewLines(token.value()));
423 children.push(code); 517 children.push(code);
424 break; 518 break;
425 case WebInspector.WikiParser.TokenType.LineEnd: 519 case WebInspector.WikiParser.TokenType.LineEnd:
520 this._tokenizer.nextToken();
426 processSimpleText(); 521 processSimpleText();
427 processBlock(); 522 processBlock();
428 break; 523 break;
429 case WebInspector.WikiParser.TokenType.VerticalLine: 524 case WebInspector.WikiParser.TokenType.EqualSignInBraces:
525 this._tokenizer.nextToken();
526 text += "=";
527 break;
528 case WebInspector.WikiParser.TokenType.Exclamation:
529 this._tokenizer.nextToken();
530 text += "|";
531 break;
532 case WebInspector.WikiParser.TokenType.ClosingBrackets:
430 case WebInspector.WikiParser.TokenType.Text: 533 case WebInspector.WikiParser.TokenType.Text:
534 case WebInspector.WikiParser.TokenType.EqualSign:
535 case WebInspector.WikiParser.TokenType.Table:
536 this._tokenizer.nextToken();
431 text += token.value(); 537 text += token.value();
432 break; 538 break;
433 default: 539 default:
540 this._tokenizer.nextToken();
434 return null; 541 return null;
435 } 542 }
436 } 543 }
437 544
438 processSimpleText(); 545 processSimpleText();
439 processBlock(); 546 processBlock();
440 547
441 return new WebInspector.WikiParser.Block(children, false); 548 return new WebInspector.WikiParser.Block(children);
442 }, 549 },
443 550
444 /** 551 /**
445 * @return {!WebInspector.WikiParser.Link} 552 * @return {!WebInspector.WikiParser.Link}
446 */ 553 */
447 _parseLink: function() 554 _parseLink: function()
448 { 555 {
449 var url = ""; 556 var url = "";
450 var children = []; 557 var children = [];
451 while (this._tokenizer._hasMoreTokens()) { 558 while (this._tokenizer.hasMoreTokens()) {
452 var token = this._tokenizer._nextToken(); 559 var token = this._tokenizer.nextToken();
453 switch (token.type()) { 560 switch (token.type()) {
454 case WebInspector.WikiParser.TokenType.ClosingBrackets: 561 case WebInspector.WikiParser.TokenType.ClosingBrackets:
455 return new WebInspector.WikiParser.Link(url, children); 562 return new WebInspector.WikiParser.Link(url, children);
456 case WebInspector.WikiParser.TokenType.VerticalLine: 563 case WebInspector.WikiParser.TokenType.VerticalLine:
564 case WebInspector.WikiParser.TokenType.Exclamation:
457 children.push(this._parseLinkName()); 565 children.push(this._parseLinkName());
458 return new WebInspector.WikiParser.Link(url, children); 566 return new WebInspector.WikiParser.Link(url, children);
459 default: 567 default:
460 url += token.value(); 568 url += token.value();
461 } 569 }
462 } 570 }
463 571
464 return new WebInspector.WikiParser.Link(url, children); 572 return new WebInspector.WikiParser.Link(url, children);
465 }, 573 },
466 574
467 /** 575 /**
468 * @return {!WebInspector.WikiParser.Inline} 576 * @return {!WebInspector.WikiParser.Inline}
469 */ 577 */
470 _parseLinkName: function() 578 _parseLinkName: function()
471 { 579 {
472 var children = []; 580 var children = [];
473 while (this._tokenizer._hasMoreTokens()) { 581 var text = "";
474 var token = this._tokenizer._nextToken(); 582 var self = this;
583 function processSimpleText()
584 {
585 text = self._deleteTrailingSpaces(text);
586 if (!text.length)
587 return;
588 var simpleText = new WebInspector.WikiParser.PlainText(text);
589 children.push(simpleText);
590 text = "";
591 }
592
593 while (this._tokenizer.hasMoreTokens()) {
594 var token = this._tokenizer.nextToken();
475 switch (token.type()) { 595 switch (token.type()) {
476 case WebInspector.WikiParser.TokenType.ClosingBrackets: 596 case WebInspector.WikiParser.TokenType.ClosingBrackets:
597 processSimpleText();
477 return new WebInspector.WikiParser.Inline(WebInspector.WikiParse r.ArticleElement.Type.Inline, children); 598 return new WebInspector.WikiParser.Inline(WebInspector.WikiParse r.ArticleElement.Type.Inline, children);
478 case WebInspector.WikiParser.TokenType.OpeningCodeTag: 599 case WebInspector.WikiParser.TokenType.OpeningCodeTag:
600 processSimpleText();
479 children.push(this._parseCode()); 601 children.push(this._parseCode());
480 break; 602 break;
481 default: 603 default:
482 children.push(new WebInspector.WikiParser.PlainText(token.value( ), false)); 604 text += token.value();
483 break; 605 break;
484 } 606 }
485 } 607 }
486 608
487 return new WebInspector.WikiParser.Inline(WebInspector.WikiParser.Articl eElement.Type.Inline, children); 609 return new WebInspector.WikiParser.Inline(WebInspector.WikiParser.Articl eElement.Type.Inline, children);
488 }, 610 },
489 611
490 /** 612 /**
491 * @return {!WebInspector.WikiParser.Inline} 613 * @return {!WebInspector.WikiParser.Inline}
492 */ 614 */
493 _parseCode : function() 615 _parseCode : function()
494 { 616 {
495 var children = []; 617 var children = [];
496 var text = ""; 618 var text = "";
497 while (this._tokenizer._hasMoreTokens()) { 619 while (this._tokenizer.hasMoreTokens()) {
498 var token = this._tokenizer._nextToken(); 620 var token = this._tokenizer.nextToken();
499 switch (token.type()) { 621 switch (token.type()) {
500 case WebInspector.WikiParser.TokenType.ClosingCodeTag: 622 case WebInspector.WikiParser.TokenType.ClosingCodeTag:
501 text = this._deleteTrailingSpaces(text); 623 text = this._deleteTrailingSpaces(text);
502 if (text.length) { 624 if (text.length) {
503 var simpleText = new WebInspector.WikiParser.PlainText(text, false); 625 var simpleText = new WebInspector.WikiParser.PlainText(text) ;
504 children.push(simpleText); 626 children.push(simpleText);
505 text = ""; 627 text = "";
506 } 628 }
507 var code = new WebInspector.WikiParser.Inline(WebInspector.WikiP arser.ArticleElement.Type.Code, children); 629 var code = new WebInspector.WikiParser.Inline(WebInspector.WikiP arser.ArticleElement.Type.Code, children);
508 return code; 630 return code;
509 case WebInspector.WikiParser.TokenType.OpeningBrackets: 631 case WebInspector.WikiParser.TokenType.OpeningBrackets:
510 var link = this._parseLink(); 632 var link = this._parseLink();
511 children.push(link); 633 children.push(link);
512 break; 634 break;
513 default: 635 default:
514 text += token.value(); 636 text += token.value();
515 } 637 }
516 } 638 }
517 639
518 text = this._deleteTrailingSpaces(text); 640 text = this._deleteTrailingSpaces(text);
519 if (text.length) 641 if (text.length)
520 children.push(new WebInspector.WikiParser.PlainText(text, false)); 642 children.push(new WebInspector.WikiParser.PlainText(text));
521 643
522 return new WebInspector.WikiParser.Inline(WebInspector.WikiParser.Articl eElement.Type.Code, children); 644 return new WebInspector.WikiParser.Inline(WebInspector.WikiParser.Articl eElement.Type.Code, children);
523 }, 645 },
524 646
525 /** 647 /**
526 * @return {!WebInspector.WikiParser.Block} 648 * @return {!WebInspector.WikiParser.Block}
527 */ 649 */
528 _parseBullet: function() 650 _parseBullet: function()
529 { 651 {
530 var children = []; 652 var children = [];
531 while (this._tokenizer._hasMoreTokens()) { 653 while (this._tokenizer.hasMoreTokens()) {
532 var token = this._tokenizer._nextToken() 654 var token = this._tokenizer.nextToken()
533 switch (token.type()) { 655 switch (token.type()) {
534 case WebInspector.WikiParser.TokenType.OpeningBrackets: 656 case WebInspector.WikiParser.TokenType.OpeningBrackets:
535 children.push(this._parseLink()); 657 children.push(this._parseLink());
536 break; 658 break;
537 case WebInspector.WikiParser.TokenType.OpeningCodeTag: 659 case WebInspector.WikiParser.TokenType.OpeningCodeTag:
538 children.push(this._parseCode()); 660 children.push(this._parseCode());
539 break; 661 break;
540 case WebInspector.WikiParser.TokenType.LineEnd: 662 case WebInspector.WikiParser.TokenType.LineEnd:
541 return new WebInspector.WikiParser.Block(children, true); 663 return new WebInspector.WikiParser.Block(children, true);
542 default: 664 default:
543 var text = this._deleteTrailingSpaces(token.value()); 665 var text = this._deleteTrailingSpaces(token.value());
544 if (text.length) { 666 if (text.length) {
545 var simpleText = new WebInspector.WikiParser.PlainText(text, false); 667 var simpleText = new WebInspector.WikiParser.PlainText(text) ;
546 children.push(simpleText); 668 children.push(simpleText);
547 text = ""; 669 text = "";
548 } 670 }
549 } 671 }
550 } 672 }
551 673
552 return new WebInspector.WikiParser.Block(children, true); 674 return new WebInspector.WikiParser.Block(children, true);
553 }, 675 },
554 676
555 /** 677 /**
556 * @return {!WebInspector.WikiParser.PlainText} 678 * @return {!WebInspector.WikiParser.PlainText}
557 */ 679 */
558 _parseHighlight: function() 680 _parseHighlight: function()
559 { 681 {
560 var text = ""; 682 var text = "";
561 while (this._tokenizer._hasMoreTokens()) { 683 while (this._tokenizer.hasMoreTokens()) {
562 var token = this._tokenizer._nextToken() 684 var token = this._tokenizer.nextToken()
563 switch (token.type()) { 685 switch (token.type()) {
564 case WebInspector.WikiParser.TokenType.TripleQuotes: 686 case WebInspector.WikiParser.TokenType.TripleQuotes:
565 text = this._deleteTrailingSpaces(text); 687 text = this._deleteTrailingSpaces(text);
566 return new WebInspector.WikiParser.PlainText(text, true); 688 return new WebInspector.WikiParser.PlainText(text, true);
567 default: 689 default:
568 text += token.value(); 690 text += token.value();
569 } 691 }
570 } 692 }
571 return new WebInspector.WikiParser.PlainText(text, true); 693 return new WebInspector.WikiParser.PlainText(text, true);
572 }, 694 },
573 695
574 /** 696 /**
575 * @param {string} str 697 * @param {string} str
576 * @return {string} 698 * @return {string}
577 */ 699 */
578 _deleteTrailingSpaces: function(str) 700 _deleteTrailingSpaces: function(str)
579 { 701 {
580 return str.replace(/[\n\r]*$/gm, ""); 702 return str.replace(/[\n\r]*$/gm, "");
703 },
704
705 /**
706 * @param {string} str
707 * @return {string}
708 */
709 _trimLeadingNewLines: function(str)
710 {
711 return str.replace(/^\n*/, "");
581 } 712 }
582 } 713 }
583 714
584 WebInspector.WikiParser.oneOpeningBracket = /^\n* \[[^\[]/;
585 WebInspector.WikiParser.twoOpeningBrackets = /^\n* \[\[/;
586 WebInspector.WikiParser.oneClosingBracket = /^\n*\][^\]] /;
587 WebInspector.WikiParser.twoClosingBrackets = /^\n*\]\]/;
588 WebInspector.WikiParser.tripleQuotes = /^\n*'''/;
589 WebInspector.WikiParser.openingCodeTag = /^<\s*code\s*>/;
590 WebInspector.WikiParser.closingCodeTag = /^<\s*\/\s*code\s*>/;
591 WebInspector.WikiParser.closingBullet = /^\*/;
592 WebInspector.WikiParser.lineEnd = /^\n/;
593 WebInspector.WikiParser.verticalLine = /^\|/;
594 WebInspector.WikiParser.newLineWithSpace = /^\n /;
595 WebInspector.WikiParser.newLineWithoutSpace = /\n[^ ]/;
596
597 /**
598 * @constructor
599 * @param {!RegExp} regex
600 * @param {!WebInspector.WikiParser.TokenType} type
601 */
602 WebInspector.WikiParser.TokenDescriptor = function(regex, type)
603 {
604 this.regex = regex;
605 this.type = type;
606 }
607
608 WebInspector.WikiParser._tokenDescriptors = [
609 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.newLineW ithSpace, WebInspector.WikiParser.TokenType.CodeBlock),
610 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.tripleQu otes, WebInspector.WikiParser.TokenType.TripleQuotes),
611 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.oneOpeni ngBracket, WebInspector.WikiParser.TokenType.OpeningBrackets),
612 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.twoOpeni ngBrackets, WebInspector.WikiParser.TokenType.OpeningBrackets),
613 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.oneClosi ngBracket, WebInspector.WikiParser.TokenType.ClosingBrackets),
614 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.twoClosi ngBrackets, WebInspector.WikiParser.TokenType.ClosingBrackets),
615 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.openingC odeTag, WebInspector.WikiParser.TokenType.OpeningCodeTag),
616 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.closingC odeTag, WebInspector.WikiParser.TokenType.ClosingCodeTag),
617 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.closingB ullet, WebInspector.WikiParser.TokenType.Bullet),
618 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.vertical Line, WebInspector.WikiParser.TokenType.VerticalLine),
619 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.lineEnd, WebInspector.WikiParser.TokenType.LineEnd)
620 ];
621
622 /** 715 /**
623 * @constructor 716 * @constructor
624 * @param {!WebInspector.WikiParser.ArticleElement.Type} type 717 * @param {!WebInspector.WikiParser.ArticleElement.Type} type
625 */ 718 */
626 WebInspector.WikiParser.ArticleElement = function(type) 719 WebInspector.WikiParser.ArticleElement = function(type)
627 { 720 {
628 this._type = type; 721 this._type = type;
629 } 722 }
630 723
631 WebInspector.WikiParser.ArticleElement.prototype = { 724 WebInspector.WikiParser.ArticleElement.prototype = {
(...skipping 15 matching lines...) Expand all
647 Code: "Code", 740 Code: "Code",
648 Block: "Block", 741 Block: "Block",
649 CodeBlock: "CodeBlock", 742 CodeBlock: "CodeBlock",
650 Inline: "Inline" 743 Inline: "Inline"
651 }; 744 };
652 745
653 /** 746 /**
654 * @constructor 747 * @constructor
655 * @extends {WebInspector.WikiParser.ArticleElement} 748 * @extends {WebInspector.WikiParser.ArticleElement}
656 * @param {string} text 749 * @param {string} text
657 * @param {boolean} highlight 750 * @param {boolean=} highlight
658 */ 751 */
659 WebInspector.WikiParser.PlainText = function(text, highlight) 752 WebInspector.WikiParser.PlainText = function(text, highlight)
660 { 753 {
661 WebInspector.WikiParser.ArticleElement.call(this, WebInspector.WikiParser.Ar ticleElement.Type.PlainText); 754 WebInspector.WikiParser.ArticleElement.call(this, WebInspector.WikiParser.Ar ticleElement.Type.PlainText);
662 this._text = text; 755 this._text = text;
663 this._isHighlighted = highlight; 756 this._isHighlighted = highlight || false;
664 } 757 }
665 758
666 WebInspector.WikiParser.PlainText.prototype = { 759 WebInspector.WikiParser.PlainText.prototype = {
667 /** 760 /**
668 * @return {string} 761 * @return {string}
669 */ 762 */
670 text : function() 763 text: function()
671 { 764 {
672 return this._text; 765 return this._text;
673 }, 766 },
674 767
675 /** 768 /**
676 * @return {boolean} 769 * @return {boolean}
677 */ 770 */
678 isHighlighted: function() 771 isHighlighted: function()
679 { 772 {
680 return this._isHighlighted; 773 return this._isHighlighted;
681 }, 774 },
682 775
683 __proto__: WebInspector.WikiParser.ArticleElement.prototype 776 __proto__: WebInspector.WikiParser.ArticleElement.prototype
684 } 777 }
685 778
686 /** 779 /**
687 * @constructor 780 * @constructor
688 * @extends {WebInspector.WikiParser.ArticleElement} 781 * @extends {WebInspector.WikiParser.ArticleElement}
689 * @param {!Array.<!WebInspector.WikiParser.ArticleElement>} children 782 * @param {!Array.<!WebInspector.WikiParser.ArticleElement>} children
690 * @param {boolean} hasBullet 783 * @param {boolean=} hasBullet
691 */ 784 */
692 WebInspector.WikiParser.Block = function(children, hasBullet) 785 WebInspector.WikiParser.Block = function(children, hasBullet)
693 { 786 {
694 WebInspector.WikiParser.ArticleElement.call(this, WebInspector.WikiParser.Ar ticleElement.Type.Block); 787 WebInspector.WikiParser.ArticleElement.call(this, WebInspector.WikiParser.Ar ticleElement.Type.Block);
695 this._children = children; 788 this._children = children;
696 this._hasBullet = hasBullet 789 this._hasBullet = hasBullet || false;
697 } 790 }
698 791
699 WebInspector.WikiParser.Block.prototype = { 792 WebInspector.WikiParser.Block.prototype = {
700 /** 793 /**
701 * @return {!Array.<!WebInspector.WikiParser.ArticleElement>} 794 * @return {!Array.<!WebInspector.WikiParser.ArticleElement>}
702 */ 795 */
703 children: function() 796 children: function()
704 { 797 {
705 return this._children; 798 return this._children;
706 }, 799 },
707 800
708 /** 801 /**
709 * @return {boolean} 802 * @return {boolean}
710 */ 803 */
804 hasChildren: function()
805 {
806 return !!this._children && !!this._children.length;
807 },
808
809 /**
810 * @return {boolean}
811 */
711 hasBullet: function() 812 hasBullet: function()
712 { 813 {
713 return this._hasBullet; 814 return this._hasBullet;
714 }, 815 },
715 816
716 __proto__: WebInspector.WikiParser.ArticleElement.prototype 817 __proto__: WebInspector.WikiParser.ArticleElement.prototype
717 } 818 }
718 819
719 /** 820 /**
720 * @constructor 821 * @constructor
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 /** 880 /**
780 * @return {string} 881 * @return {string}
781 */ 882 */
782 url : function() 883 url : function()
783 { 884 {
784 return this._url; 885 return this._url;
785 }, 886 },
786 887
787 __proto__: WebInspector.WikiParser.Inline.prototype 888 __proto__: WebInspector.WikiParser.Inline.prototype
788 } 889 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/documentation/JSArticle.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698