OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// The line contains only whitespace or is empty. | 5 /// The line contains only whitespace or is empty. |
6 const _RE_EMPTY = const RegExp(r'^([ \t]*)$'); | 6 const _RE_EMPTY = const RegExp(r'^([ \t]*)$'); |
7 | 7 |
8 /// A series of `=` or `-` (on the next line) define setext-style headers. | 8 /// A series of `=` or `-` (on the next line) define setext-style headers. |
9 const _RE_SETEXT = const RegExp(r'^((=+)|(-+))$'); | 9 const _RE_SETEXT = const RegExp(r'^((=+)|(-+))$'); |
10 | 10 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } else if (tryMatch(_RE_INDENT)) { | 293 } else if (tryMatch(_RE_INDENT)) { |
294 // Strip off indent and add to current item. | 294 // Strip off indent and add to current item. |
295 childLines.add(match[1]); | 295 childLines.add(match[1]); |
296 } else if (BlockSyntax.isAtBlockEnd(parser)) { | 296 } else if (BlockSyntax.isAtBlockEnd(parser)) { |
297 // Done with the list. | 297 // Done with the list. |
298 break; | 298 break; |
299 } else { | 299 } else { |
300 // Anything else is paragraph text or other stuff that can be in a list | 300 // Anything else is paragraph text or other stuff that can be in a list |
301 // item. However, if the previous item is a blank line, this means we're | 301 // item. However, if the previous item is a blank line, this means we're |
302 // done with the list and are starting a new top-level paragraph. | 302 // done with the list and are starting a new top-level paragraph. |
303 if ((childLines.length > 0) && (childLines.last() == '')) break; | 303 if ((childLines.length > 0) && (childLines.last == '')) break; |
304 childLines.add(parser.current); | 304 childLines.add(parser.current); |
305 } | 305 } |
306 parser.advance(); | 306 parser.advance(); |
307 } | 307 } |
308 | 308 |
309 endItem(); | 309 endItem(); |
310 | 310 |
311 // Markdown, because it hates us, specifies two kinds of list items. If you | 311 // Markdown, because it hates us, specifies two kinds of list items. If you |
312 // have a list like: | 312 // have a list like: |
313 // | 313 // |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 while (!BlockSyntax.isAtBlockEnd(parser)) { | 427 while (!BlockSyntax.isAtBlockEnd(parser)) { |
428 childLines.add(parser.current); | 428 childLines.add(parser.current); |
429 parser.advance(); | 429 parser.advance(); |
430 } | 430 } |
431 | 431 |
432 final contents = parser.document.parseInline( | 432 final contents = parser.document.parseInline( |
433 Strings.join(childLines, '\n')); | 433 Strings.join(childLines, '\n')); |
434 return new Element('p', contents); | 434 return new Element('p', contents); |
435 } | 435 } |
436 } | 436 } |
OLD | NEW |