| 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 part of markdown; | 5 part of markdown; |
| 6 | 6 |
| 7 /// The line contains only whitespace or is empty. | 7 /// The line contains only whitespace or is empty. |
| 8 final _RE_EMPTY = new RegExp(r'^([ \t]*)$'); | 8 final _RE_EMPTY = new RegExp(r'^([ \t]*)$'); |
| 9 | 9 |
| 10 /// A series of `=` or `-` (on the next line) define setext-style headers. | 10 /// A series of `=` or `-` (on the next line) define setext-style headers. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 childLines.add(match[1]); | 128 childLines.add(match[1]); |
| 129 parser.advance(); | 129 parser.advance(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 return childLines; | 132 return childLines; |
| 133 } | 133 } |
| 134 | 134 |
| 135 /// Gets whether or not [parser]'s current line should end the previous block. | 135 /// Gets whether or not [parser]'s current line should end the previous block. |
| 136 static bool isAtBlockEnd(BlockParser parser) { | 136 static bool isAtBlockEnd(BlockParser parser) { |
| 137 if (parser.isDone) return true; | 137 if (parser.isDone) return true; |
| 138 return syntaxes.some((s) => s.canParse(parser) && s.canEndBlock); | 138 return syntaxes.any((s) => s.canParse(parser) && s.canEndBlock); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 class EmptyBlockSyntax extends BlockSyntax { | 142 class EmptyBlockSyntax extends BlockSyntax { |
| 143 RegExp get pattern => _RE_EMPTY; | 143 RegExp get pattern => _RE_EMPTY; |
| 144 | 144 |
| 145 Node parse(BlockParser parser) { | 145 Node parse(BlockParser parser) { |
| 146 parser.advance(); | 146 parser.advance(); |
| 147 | 147 |
| 148 // Don't actually emit anything. | 148 // Don't actually emit anything. |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 while (!BlockSyntax.isAtBlockEnd(parser)) { | 429 while (!BlockSyntax.isAtBlockEnd(parser)) { |
| 430 childLines.add(parser.current); | 430 childLines.add(parser.current); |
| 431 parser.advance(); | 431 parser.advance(); |
| 432 } | 432 } |
| 433 | 433 |
| 434 final contents = parser.document.parseInline( | 434 final contents = parser.document.parseInline( |
| 435 Strings.join(childLines, '\n')); | 435 Strings.join(childLines, '\n')); |
| 436 return new Element('p', contents); | 436 return new Element('p', contents); |
| 437 } | 437 } |
| 438 } | 438 } |
| OLD | NEW |